mutation.go 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/batchmsg"
  13. "wechat-api/ent/category"
  14. "wechat-api/ent/chatrecords"
  15. "wechat-api/ent/chatsession"
  16. "wechat-api/ent/contact"
  17. "wechat-api/ent/custom_types"
  18. "wechat-api/ent/employee"
  19. "wechat-api/ent/employeeconfig"
  20. "wechat-api/ent/label"
  21. "wechat-api/ent/labelrelationship"
  22. "wechat-api/ent/message"
  23. "wechat-api/ent/messagerecords"
  24. "wechat-api/ent/msg"
  25. "wechat-api/ent/predicate"
  26. "wechat-api/ent/server"
  27. "wechat-api/ent/sopnode"
  28. "wechat-api/ent/sopstage"
  29. "wechat-api/ent/soptask"
  30. "wechat-api/ent/token"
  31. "wechat-api/ent/tutorial"
  32. "wechat-api/ent/usagedetail"
  33. "wechat-api/ent/usagestatisticday"
  34. "wechat-api/ent/usagestatistichour"
  35. "wechat-api/ent/usagestatisticmonth"
  36. "wechat-api/ent/usagetotal"
  37. "wechat-api/ent/workexperience"
  38. "wechat-api/ent/wpchatroom"
  39. "wechat-api/ent/wpchatroommember"
  40. "wechat-api/ent/wx"
  41. "wechat-api/ent/wxcard"
  42. "wechat-api/ent/wxcarduser"
  43. "wechat-api/ent/wxcardvisit"
  44. "entgo.io/ent"
  45. "entgo.io/ent/dialect/sql"
  46. )
  47. const (
  48. // Operation types.
  49. OpCreate = ent.OpCreate
  50. OpDelete = ent.OpDelete
  51. OpDeleteOne = ent.OpDeleteOne
  52. OpUpdate = ent.OpUpdate
  53. OpUpdateOne = ent.OpUpdateOne
  54. // Node types.
  55. TypeAgent = "Agent"
  56. TypeAgentBase = "AgentBase"
  57. TypeAliyunAvatar = "AliyunAvatar"
  58. TypeBatchMsg = "BatchMsg"
  59. TypeCategory = "Category"
  60. TypeChatRecords = "ChatRecords"
  61. TypeChatSession = "ChatSession"
  62. TypeContact = "Contact"
  63. TypeEmployee = "Employee"
  64. TypeEmployeeConfig = "EmployeeConfig"
  65. TypeLabel = "Label"
  66. TypeLabelRelationship = "LabelRelationship"
  67. TypeMessage = "Message"
  68. TypeMessageRecords = "MessageRecords"
  69. TypeMsg = "Msg"
  70. TypeServer = "Server"
  71. TypeSopNode = "SopNode"
  72. TypeSopStage = "SopStage"
  73. TypeSopTask = "SopTask"
  74. TypeToken = "Token"
  75. TypeTutorial = "Tutorial"
  76. TypeUsageDetail = "UsageDetail"
  77. TypeUsageStatisticDay = "UsageStatisticDay"
  78. TypeUsageStatisticHour = "UsageStatisticHour"
  79. TypeUsageStatisticMonth = "UsageStatisticMonth"
  80. TypeUsageTotal = "UsageTotal"
  81. TypeWorkExperience = "WorkExperience"
  82. TypeWpChatroom = "WpChatroom"
  83. TypeWpChatroomMember = "WpChatroomMember"
  84. TypeWx = "Wx"
  85. TypeWxCard = "WxCard"
  86. TypeWxCardUser = "WxCardUser"
  87. TypeWxCardVisit = "WxCardVisit"
  88. )
  89. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  90. type AgentMutation struct {
  91. config
  92. op Op
  93. typ string
  94. id *uint64
  95. created_at *time.Time
  96. updated_at *time.Time
  97. deleted_at *time.Time
  98. name *string
  99. role *string
  100. status *int
  101. addstatus *int
  102. background *string
  103. examples *string
  104. organization_id *uint64
  105. addorganization_id *int64
  106. dataset_id *string
  107. collection_id *string
  108. clearedFields map[string]struct{}
  109. wx_agent map[uint64]struct{}
  110. removedwx_agent map[uint64]struct{}
  111. clearedwx_agent bool
  112. token_agent map[uint64]struct{}
  113. removedtoken_agent map[uint64]struct{}
  114. clearedtoken_agent bool
  115. done bool
  116. oldValue func(context.Context) (*Agent, error)
  117. predicates []predicate.Agent
  118. }
  119. var _ ent.Mutation = (*AgentMutation)(nil)
  120. // agentOption allows management of the mutation configuration using functional options.
  121. type agentOption func(*AgentMutation)
  122. // newAgentMutation creates new mutation for the Agent entity.
  123. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  124. m := &AgentMutation{
  125. config: c,
  126. op: op,
  127. typ: TypeAgent,
  128. clearedFields: make(map[string]struct{}),
  129. }
  130. for _, opt := range opts {
  131. opt(m)
  132. }
  133. return m
  134. }
  135. // withAgentID sets the ID field of the mutation.
  136. func withAgentID(id uint64) agentOption {
  137. return func(m *AgentMutation) {
  138. var (
  139. err error
  140. once sync.Once
  141. value *Agent
  142. )
  143. m.oldValue = func(ctx context.Context) (*Agent, error) {
  144. once.Do(func() {
  145. if m.done {
  146. err = errors.New("querying old values post mutation is not allowed")
  147. } else {
  148. value, err = m.Client().Agent.Get(ctx, id)
  149. }
  150. })
  151. return value, err
  152. }
  153. m.id = &id
  154. }
  155. }
  156. // withAgent sets the old Agent of the mutation.
  157. func withAgent(node *Agent) agentOption {
  158. return func(m *AgentMutation) {
  159. m.oldValue = func(context.Context) (*Agent, error) {
  160. return node, nil
  161. }
  162. m.id = &node.ID
  163. }
  164. }
  165. // Client returns a new `ent.Client` from the mutation. If the mutation was
  166. // executed in a transaction (ent.Tx), a transactional client is returned.
  167. func (m AgentMutation) Client() *Client {
  168. client := &Client{config: m.config}
  169. client.init()
  170. return client
  171. }
  172. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  173. // it returns an error otherwise.
  174. func (m AgentMutation) Tx() (*Tx, error) {
  175. if _, ok := m.driver.(*txDriver); !ok {
  176. return nil, errors.New("ent: mutation is not running in a transaction")
  177. }
  178. tx := &Tx{config: m.config}
  179. tx.init()
  180. return tx, nil
  181. }
  182. // SetID sets the value of the id field. Note that this
  183. // operation is only accepted on creation of Agent entities.
  184. func (m *AgentMutation) SetID(id uint64) {
  185. m.id = &id
  186. }
  187. // ID returns the ID value in the mutation. Note that the ID is only available
  188. // if it was provided to the builder or after it was returned from the database.
  189. func (m *AgentMutation) ID() (id uint64, exists bool) {
  190. if m.id == nil {
  191. return
  192. }
  193. return *m.id, true
  194. }
  195. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  196. // That means, if the mutation is applied within a transaction with an isolation level such
  197. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  198. // or updated by the mutation.
  199. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  200. switch {
  201. case m.op.Is(OpUpdateOne | OpDeleteOne):
  202. id, exists := m.ID()
  203. if exists {
  204. return []uint64{id}, nil
  205. }
  206. fallthrough
  207. case m.op.Is(OpUpdate | OpDelete):
  208. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  209. default:
  210. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  211. }
  212. }
  213. // SetCreatedAt sets the "created_at" field.
  214. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  215. m.created_at = &t
  216. }
  217. // CreatedAt returns the value of the "created_at" field in the mutation.
  218. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  219. v := m.created_at
  220. if v == nil {
  221. return
  222. }
  223. return *v, true
  224. }
  225. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  226. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  228. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  229. if !m.op.Is(OpUpdateOne) {
  230. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  231. }
  232. if m.id == nil || m.oldValue == nil {
  233. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  234. }
  235. oldValue, err := m.oldValue(ctx)
  236. if err != nil {
  237. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  238. }
  239. return oldValue.CreatedAt, nil
  240. }
  241. // ResetCreatedAt resets all changes to the "created_at" field.
  242. func (m *AgentMutation) ResetCreatedAt() {
  243. m.created_at = nil
  244. }
  245. // SetUpdatedAt sets the "updated_at" field.
  246. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  247. m.updated_at = &t
  248. }
  249. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  250. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  251. v := m.updated_at
  252. if v == nil {
  253. return
  254. }
  255. return *v, true
  256. }
  257. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  258. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  260. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  261. if !m.op.Is(OpUpdateOne) {
  262. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  263. }
  264. if m.id == nil || m.oldValue == nil {
  265. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  266. }
  267. oldValue, err := m.oldValue(ctx)
  268. if err != nil {
  269. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  270. }
  271. return oldValue.UpdatedAt, nil
  272. }
  273. // ResetUpdatedAt resets all changes to the "updated_at" field.
  274. func (m *AgentMutation) ResetUpdatedAt() {
  275. m.updated_at = nil
  276. }
  277. // SetDeletedAt sets the "deleted_at" field.
  278. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  279. m.deleted_at = &t
  280. }
  281. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  282. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  283. v := m.deleted_at
  284. if v == nil {
  285. return
  286. }
  287. return *v, true
  288. }
  289. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  290. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  292. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  293. if !m.op.Is(OpUpdateOne) {
  294. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  295. }
  296. if m.id == nil || m.oldValue == nil {
  297. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  298. }
  299. oldValue, err := m.oldValue(ctx)
  300. if err != nil {
  301. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  302. }
  303. return oldValue.DeletedAt, nil
  304. }
  305. // ClearDeletedAt clears the value of the "deleted_at" field.
  306. func (m *AgentMutation) ClearDeletedAt() {
  307. m.deleted_at = nil
  308. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  309. }
  310. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  311. func (m *AgentMutation) DeletedAtCleared() bool {
  312. _, ok := m.clearedFields[agent.FieldDeletedAt]
  313. return ok
  314. }
  315. // ResetDeletedAt resets all changes to the "deleted_at" field.
  316. func (m *AgentMutation) ResetDeletedAt() {
  317. m.deleted_at = nil
  318. delete(m.clearedFields, agent.FieldDeletedAt)
  319. }
  320. // SetName sets the "name" field.
  321. func (m *AgentMutation) SetName(s string) {
  322. m.name = &s
  323. }
  324. // Name returns the value of the "name" field in the mutation.
  325. func (m *AgentMutation) Name() (r string, exists bool) {
  326. v := m.name
  327. if v == nil {
  328. return
  329. }
  330. return *v, true
  331. }
  332. // OldName returns the old "name" field's value of the Agent entity.
  333. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  335. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  336. if !m.op.Is(OpUpdateOne) {
  337. return v, errors.New("OldName is only allowed on UpdateOne operations")
  338. }
  339. if m.id == nil || m.oldValue == nil {
  340. return v, errors.New("OldName requires an ID field in the mutation")
  341. }
  342. oldValue, err := m.oldValue(ctx)
  343. if err != nil {
  344. return v, fmt.Errorf("querying old value for OldName: %w", err)
  345. }
  346. return oldValue.Name, nil
  347. }
  348. // ResetName resets all changes to the "name" field.
  349. func (m *AgentMutation) ResetName() {
  350. m.name = nil
  351. }
  352. // SetRole sets the "role" field.
  353. func (m *AgentMutation) SetRole(s string) {
  354. m.role = &s
  355. }
  356. // Role returns the value of the "role" field in the mutation.
  357. func (m *AgentMutation) Role() (r string, exists bool) {
  358. v := m.role
  359. if v == nil {
  360. return
  361. }
  362. return *v, true
  363. }
  364. // OldRole returns the old "role" field's value of the Agent entity.
  365. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  367. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  368. if !m.op.Is(OpUpdateOne) {
  369. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  370. }
  371. if m.id == nil || m.oldValue == nil {
  372. return v, errors.New("OldRole requires an ID field in the mutation")
  373. }
  374. oldValue, err := m.oldValue(ctx)
  375. if err != nil {
  376. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  377. }
  378. return oldValue.Role, nil
  379. }
  380. // ResetRole resets all changes to the "role" field.
  381. func (m *AgentMutation) ResetRole() {
  382. m.role = nil
  383. }
  384. // SetStatus sets the "status" field.
  385. func (m *AgentMutation) SetStatus(i int) {
  386. m.status = &i
  387. m.addstatus = nil
  388. }
  389. // Status returns the value of the "status" field in the mutation.
  390. func (m *AgentMutation) Status() (r int, exists bool) {
  391. v := m.status
  392. if v == nil {
  393. return
  394. }
  395. return *v, true
  396. }
  397. // OldStatus returns the old "status" field's value of the Agent entity.
  398. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  400. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  401. if !m.op.Is(OpUpdateOne) {
  402. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  403. }
  404. if m.id == nil || m.oldValue == nil {
  405. return v, errors.New("OldStatus requires an ID field in the mutation")
  406. }
  407. oldValue, err := m.oldValue(ctx)
  408. if err != nil {
  409. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  410. }
  411. return oldValue.Status, nil
  412. }
  413. // AddStatus adds i to the "status" field.
  414. func (m *AgentMutation) AddStatus(i int) {
  415. if m.addstatus != nil {
  416. *m.addstatus += i
  417. } else {
  418. m.addstatus = &i
  419. }
  420. }
  421. // AddedStatus returns the value that was added to the "status" field in this mutation.
  422. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  423. v := m.addstatus
  424. if v == nil {
  425. return
  426. }
  427. return *v, true
  428. }
  429. // ClearStatus clears the value of the "status" field.
  430. func (m *AgentMutation) ClearStatus() {
  431. m.status = nil
  432. m.addstatus = nil
  433. m.clearedFields[agent.FieldStatus] = struct{}{}
  434. }
  435. // StatusCleared returns if the "status" field was cleared in this mutation.
  436. func (m *AgentMutation) StatusCleared() bool {
  437. _, ok := m.clearedFields[agent.FieldStatus]
  438. return ok
  439. }
  440. // ResetStatus resets all changes to the "status" field.
  441. func (m *AgentMutation) ResetStatus() {
  442. m.status = nil
  443. m.addstatus = nil
  444. delete(m.clearedFields, agent.FieldStatus)
  445. }
  446. // SetBackground sets the "background" field.
  447. func (m *AgentMutation) SetBackground(s string) {
  448. m.background = &s
  449. }
  450. // Background returns the value of the "background" field in the mutation.
  451. func (m *AgentMutation) Background() (r string, exists bool) {
  452. v := m.background
  453. if v == nil {
  454. return
  455. }
  456. return *v, true
  457. }
  458. // OldBackground returns the old "background" field's value of the Agent entity.
  459. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  461. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  462. if !m.op.Is(OpUpdateOne) {
  463. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  464. }
  465. if m.id == nil || m.oldValue == nil {
  466. return v, errors.New("OldBackground requires an ID field in the mutation")
  467. }
  468. oldValue, err := m.oldValue(ctx)
  469. if err != nil {
  470. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  471. }
  472. return oldValue.Background, nil
  473. }
  474. // ClearBackground clears the value of the "background" field.
  475. func (m *AgentMutation) ClearBackground() {
  476. m.background = nil
  477. m.clearedFields[agent.FieldBackground] = struct{}{}
  478. }
  479. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  480. func (m *AgentMutation) BackgroundCleared() bool {
  481. _, ok := m.clearedFields[agent.FieldBackground]
  482. return ok
  483. }
  484. // ResetBackground resets all changes to the "background" field.
  485. func (m *AgentMutation) ResetBackground() {
  486. m.background = nil
  487. delete(m.clearedFields, agent.FieldBackground)
  488. }
  489. // SetExamples sets the "examples" field.
  490. func (m *AgentMutation) SetExamples(s string) {
  491. m.examples = &s
  492. }
  493. // Examples returns the value of the "examples" field in the mutation.
  494. func (m *AgentMutation) Examples() (r string, exists bool) {
  495. v := m.examples
  496. if v == nil {
  497. return
  498. }
  499. return *v, true
  500. }
  501. // OldExamples returns the old "examples" field's value of the Agent entity.
  502. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  504. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  505. if !m.op.Is(OpUpdateOne) {
  506. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  507. }
  508. if m.id == nil || m.oldValue == nil {
  509. return v, errors.New("OldExamples requires an ID field in the mutation")
  510. }
  511. oldValue, err := m.oldValue(ctx)
  512. if err != nil {
  513. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  514. }
  515. return oldValue.Examples, nil
  516. }
  517. // ClearExamples clears the value of the "examples" field.
  518. func (m *AgentMutation) ClearExamples() {
  519. m.examples = nil
  520. m.clearedFields[agent.FieldExamples] = struct{}{}
  521. }
  522. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  523. func (m *AgentMutation) ExamplesCleared() bool {
  524. _, ok := m.clearedFields[agent.FieldExamples]
  525. return ok
  526. }
  527. // ResetExamples resets all changes to the "examples" field.
  528. func (m *AgentMutation) ResetExamples() {
  529. m.examples = nil
  530. delete(m.clearedFields, agent.FieldExamples)
  531. }
  532. // SetOrganizationID sets the "organization_id" field.
  533. func (m *AgentMutation) SetOrganizationID(u uint64) {
  534. m.organization_id = &u
  535. m.addorganization_id = nil
  536. }
  537. // OrganizationID returns the value of the "organization_id" field in the mutation.
  538. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  539. v := m.organization_id
  540. if v == nil {
  541. return
  542. }
  543. return *v, true
  544. }
  545. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  546. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  548. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  549. if !m.op.Is(OpUpdateOne) {
  550. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  551. }
  552. if m.id == nil || m.oldValue == nil {
  553. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  554. }
  555. oldValue, err := m.oldValue(ctx)
  556. if err != nil {
  557. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  558. }
  559. return oldValue.OrganizationID, nil
  560. }
  561. // AddOrganizationID adds u to the "organization_id" field.
  562. func (m *AgentMutation) AddOrganizationID(u int64) {
  563. if m.addorganization_id != nil {
  564. *m.addorganization_id += u
  565. } else {
  566. m.addorganization_id = &u
  567. }
  568. }
  569. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  570. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  571. v := m.addorganization_id
  572. if v == nil {
  573. return
  574. }
  575. return *v, true
  576. }
  577. // ResetOrganizationID resets all changes to the "organization_id" field.
  578. func (m *AgentMutation) ResetOrganizationID() {
  579. m.organization_id = nil
  580. m.addorganization_id = nil
  581. }
  582. // SetDatasetID sets the "dataset_id" field.
  583. func (m *AgentMutation) SetDatasetID(s string) {
  584. m.dataset_id = &s
  585. }
  586. // DatasetID returns the value of the "dataset_id" field in the mutation.
  587. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  588. v := m.dataset_id
  589. if v == nil {
  590. return
  591. }
  592. return *v, true
  593. }
  594. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  595. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  597. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  598. if !m.op.Is(OpUpdateOne) {
  599. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  600. }
  601. if m.id == nil || m.oldValue == nil {
  602. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  603. }
  604. oldValue, err := m.oldValue(ctx)
  605. if err != nil {
  606. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  607. }
  608. return oldValue.DatasetID, nil
  609. }
  610. // ResetDatasetID resets all changes to the "dataset_id" field.
  611. func (m *AgentMutation) ResetDatasetID() {
  612. m.dataset_id = nil
  613. }
  614. // SetCollectionID sets the "collection_id" field.
  615. func (m *AgentMutation) SetCollectionID(s string) {
  616. m.collection_id = &s
  617. }
  618. // CollectionID returns the value of the "collection_id" field in the mutation.
  619. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  620. v := m.collection_id
  621. if v == nil {
  622. return
  623. }
  624. return *v, true
  625. }
  626. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  627. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  629. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  630. if !m.op.Is(OpUpdateOne) {
  631. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  632. }
  633. if m.id == nil || m.oldValue == nil {
  634. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  635. }
  636. oldValue, err := m.oldValue(ctx)
  637. if err != nil {
  638. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  639. }
  640. return oldValue.CollectionID, nil
  641. }
  642. // ResetCollectionID resets all changes to the "collection_id" field.
  643. func (m *AgentMutation) ResetCollectionID() {
  644. m.collection_id = nil
  645. }
  646. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  647. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  648. if m.wx_agent == nil {
  649. m.wx_agent = make(map[uint64]struct{})
  650. }
  651. for i := range ids {
  652. m.wx_agent[ids[i]] = struct{}{}
  653. }
  654. }
  655. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  656. func (m *AgentMutation) ClearWxAgent() {
  657. m.clearedwx_agent = true
  658. }
  659. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  660. func (m *AgentMutation) WxAgentCleared() bool {
  661. return m.clearedwx_agent
  662. }
  663. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  664. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  665. if m.removedwx_agent == nil {
  666. m.removedwx_agent = make(map[uint64]struct{})
  667. }
  668. for i := range ids {
  669. delete(m.wx_agent, ids[i])
  670. m.removedwx_agent[ids[i]] = struct{}{}
  671. }
  672. }
  673. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  674. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  675. for id := range m.removedwx_agent {
  676. ids = append(ids, id)
  677. }
  678. return
  679. }
  680. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  681. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  682. for id := range m.wx_agent {
  683. ids = append(ids, id)
  684. }
  685. return
  686. }
  687. // ResetWxAgent resets all changes to the "wx_agent" edge.
  688. func (m *AgentMutation) ResetWxAgent() {
  689. m.wx_agent = nil
  690. m.clearedwx_agent = false
  691. m.removedwx_agent = nil
  692. }
  693. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  694. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  695. if m.token_agent == nil {
  696. m.token_agent = make(map[uint64]struct{})
  697. }
  698. for i := range ids {
  699. m.token_agent[ids[i]] = struct{}{}
  700. }
  701. }
  702. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  703. func (m *AgentMutation) ClearTokenAgent() {
  704. m.clearedtoken_agent = true
  705. }
  706. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  707. func (m *AgentMutation) TokenAgentCleared() bool {
  708. return m.clearedtoken_agent
  709. }
  710. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  711. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  712. if m.removedtoken_agent == nil {
  713. m.removedtoken_agent = make(map[uint64]struct{})
  714. }
  715. for i := range ids {
  716. delete(m.token_agent, ids[i])
  717. m.removedtoken_agent[ids[i]] = struct{}{}
  718. }
  719. }
  720. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  721. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  722. for id := range m.removedtoken_agent {
  723. ids = append(ids, id)
  724. }
  725. return
  726. }
  727. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  728. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  729. for id := range m.token_agent {
  730. ids = append(ids, id)
  731. }
  732. return
  733. }
  734. // ResetTokenAgent resets all changes to the "token_agent" edge.
  735. func (m *AgentMutation) ResetTokenAgent() {
  736. m.token_agent = nil
  737. m.clearedtoken_agent = false
  738. m.removedtoken_agent = nil
  739. }
  740. // Where appends a list predicates to the AgentMutation builder.
  741. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  742. m.predicates = append(m.predicates, ps...)
  743. }
  744. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  745. // users can use type-assertion to append predicates that do not depend on any generated package.
  746. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  747. p := make([]predicate.Agent, len(ps))
  748. for i := range ps {
  749. p[i] = ps[i]
  750. }
  751. m.Where(p...)
  752. }
  753. // Op returns the operation name.
  754. func (m *AgentMutation) Op() Op {
  755. return m.op
  756. }
  757. // SetOp allows setting the mutation operation.
  758. func (m *AgentMutation) SetOp(op Op) {
  759. m.op = op
  760. }
  761. // Type returns the node type of this mutation (Agent).
  762. func (m *AgentMutation) Type() string {
  763. return m.typ
  764. }
  765. // Fields returns all fields that were changed during this mutation. Note that in
  766. // order to get all numeric fields that were incremented/decremented, call
  767. // AddedFields().
  768. func (m *AgentMutation) Fields() []string {
  769. fields := make([]string, 0, 11)
  770. if m.created_at != nil {
  771. fields = append(fields, agent.FieldCreatedAt)
  772. }
  773. if m.updated_at != nil {
  774. fields = append(fields, agent.FieldUpdatedAt)
  775. }
  776. if m.deleted_at != nil {
  777. fields = append(fields, agent.FieldDeletedAt)
  778. }
  779. if m.name != nil {
  780. fields = append(fields, agent.FieldName)
  781. }
  782. if m.role != nil {
  783. fields = append(fields, agent.FieldRole)
  784. }
  785. if m.status != nil {
  786. fields = append(fields, agent.FieldStatus)
  787. }
  788. if m.background != nil {
  789. fields = append(fields, agent.FieldBackground)
  790. }
  791. if m.examples != nil {
  792. fields = append(fields, agent.FieldExamples)
  793. }
  794. if m.organization_id != nil {
  795. fields = append(fields, agent.FieldOrganizationID)
  796. }
  797. if m.dataset_id != nil {
  798. fields = append(fields, agent.FieldDatasetID)
  799. }
  800. if m.collection_id != nil {
  801. fields = append(fields, agent.FieldCollectionID)
  802. }
  803. return fields
  804. }
  805. // Field returns the value of a field with the given name. The second boolean
  806. // return value indicates that this field was not set, or was not defined in the
  807. // schema.
  808. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  809. switch name {
  810. case agent.FieldCreatedAt:
  811. return m.CreatedAt()
  812. case agent.FieldUpdatedAt:
  813. return m.UpdatedAt()
  814. case agent.FieldDeletedAt:
  815. return m.DeletedAt()
  816. case agent.FieldName:
  817. return m.Name()
  818. case agent.FieldRole:
  819. return m.Role()
  820. case agent.FieldStatus:
  821. return m.Status()
  822. case agent.FieldBackground:
  823. return m.Background()
  824. case agent.FieldExamples:
  825. return m.Examples()
  826. case agent.FieldOrganizationID:
  827. return m.OrganizationID()
  828. case agent.FieldDatasetID:
  829. return m.DatasetID()
  830. case agent.FieldCollectionID:
  831. return m.CollectionID()
  832. }
  833. return nil, false
  834. }
  835. // OldField returns the old value of the field from the database. An error is
  836. // returned if the mutation operation is not UpdateOne, or the query to the
  837. // database failed.
  838. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  839. switch name {
  840. case agent.FieldCreatedAt:
  841. return m.OldCreatedAt(ctx)
  842. case agent.FieldUpdatedAt:
  843. return m.OldUpdatedAt(ctx)
  844. case agent.FieldDeletedAt:
  845. return m.OldDeletedAt(ctx)
  846. case agent.FieldName:
  847. return m.OldName(ctx)
  848. case agent.FieldRole:
  849. return m.OldRole(ctx)
  850. case agent.FieldStatus:
  851. return m.OldStatus(ctx)
  852. case agent.FieldBackground:
  853. return m.OldBackground(ctx)
  854. case agent.FieldExamples:
  855. return m.OldExamples(ctx)
  856. case agent.FieldOrganizationID:
  857. return m.OldOrganizationID(ctx)
  858. case agent.FieldDatasetID:
  859. return m.OldDatasetID(ctx)
  860. case agent.FieldCollectionID:
  861. return m.OldCollectionID(ctx)
  862. }
  863. return nil, fmt.Errorf("unknown Agent field %s", name)
  864. }
  865. // SetField sets the value of a field with the given name. It returns an error if
  866. // the field is not defined in the schema, or if the type mismatched the field
  867. // type.
  868. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  869. switch name {
  870. case agent.FieldCreatedAt:
  871. v, ok := value.(time.Time)
  872. if !ok {
  873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  874. }
  875. m.SetCreatedAt(v)
  876. return nil
  877. case agent.FieldUpdatedAt:
  878. v, ok := value.(time.Time)
  879. if !ok {
  880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  881. }
  882. m.SetUpdatedAt(v)
  883. return nil
  884. case agent.FieldDeletedAt:
  885. v, ok := value.(time.Time)
  886. if !ok {
  887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  888. }
  889. m.SetDeletedAt(v)
  890. return nil
  891. case agent.FieldName:
  892. v, ok := value.(string)
  893. if !ok {
  894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  895. }
  896. m.SetName(v)
  897. return nil
  898. case agent.FieldRole:
  899. v, ok := value.(string)
  900. if !ok {
  901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  902. }
  903. m.SetRole(v)
  904. return nil
  905. case agent.FieldStatus:
  906. v, ok := value.(int)
  907. if !ok {
  908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  909. }
  910. m.SetStatus(v)
  911. return nil
  912. case agent.FieldBackground:
  913. v, ok := value.(string)
  914. if !ok {
  915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  916. }
  917. m.SetBackground(v)
  918. return nil
  919. case agent.FieldExamples:
  920. v, ok := value.(string)
  921. if !ok {
  922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  923. }
  924. m.SetExamples(v)
  925. return nil
  926. case agent.FieldOrganizationID:
  927. v, ok := value.(uint64)
  928. if !ok {
  929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  930. }
  931. m.SetOrganizationID(v)
  932. return nil
  933. case agent.FieldDatasetID:
  934. v, ok := value.(string)
  935. if !ok {
  936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  937. }
  938. m.SetDatasetID(v)
  939. return nil
  940. case agent.FieldCollectionID:
  941. v, ok := value.(string)
  942. if !ok {
  943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  944. }
  945. m.SetCollectionID(v)
  946. return nil
  947. }
  948. return fmt.Errorf("unknown Agent field %s", name)
  949. }
  950. // AddedFields returns all numeric fields that were incremented/decremented during
  951. // this mutation.
  952. func (m *AgentMutation) AddedFields() []string {
  953. var fields []string
  954. if m.addstatus != nil {
  955. fields = append(fields, agent.FieldStatus)
  956. }
  957. if m.addorganization_id != nil {
  958. fields = append(fields, agent.FieldOrganizationID)
  959. }
  960. return fields
  961. }
  962. // AddedField returns the numeric value that was incremented/decremented on a field
  963. // with the given name. The second boolean return value indicates that this field
  964. // was not set, or was not defined in the schema.
  965. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  966. switch name {
  967. case agent.FieldStatus:
  968. return m.AddedStatus()
  969. case agent.FieldOrganizationID:
  970. return m.AddedOrganizationID()
  971. }
  972. return nil, false
  973. }
  974. // AddField adds the value to the field with the given name. It returns an error if
  975. // the field is not defined in the schema, or if the type mismatched the field
  976. // type.
  977. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  978. switch name {
  979. case agent.FieldStatus:
  980. v, ok := value.(int)
  981. if !ok {
  982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  983. }
  984. m.AddStatus(v)
  985. return nil
  986. case agent.FieldOrganizationID:
  987. v, ok := value.(int64)
  988. if !ok {
  989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  990. }
  991. m.AddOrganizationID(v)
  992. return nil
  993. }
  994. return fmt.Errorf("unknown Agent numeric field %s", name)
  995. }
  996. // ClearedFields returns all nullable fields that were cleared during this
  997. // mutation.
  998. func (m *AgentMutation) ClearedFields() []string {
  999. var fields []string
  1000. if m.FieldCleared(agent.FieldDeletedAt) {
  1001. fields = append(fields, agent.FieldDeletedAt)
  1002. }
  1003. if m.FieldCleared(agent.FieldStatus) {
  1004. fields = append(fields, agent.FieldStatus)
  1005. }
  1006. if m.FieldCleared(agent.FieldBackground) {
  1007. fields = append(fields, agent.FieldBackground)
  1008. }
  1009. if m.FieldCleared(agent.FieldExamples) {
  1010. fields = append(fields, agent.FieldExamples)
  1011. }
  1012. return fields
  1013. }
  1014. // FieldCleared returns a boolean indicating if a field with the given name was
  1015. // cleared in this mutation.
  1016. func (m *AgentMutation) FieldCleared(name string) bool {
  1017. _, ok := m.clearedFields[name]
  1018. return ok
  1019. }
  1020. // ClearField clears the value of the field with the given name. It returns an
  1021. // error if the field is not defined in the schema.
  1022. func (m *AgentMutation) ClearField(name string) error {
  1023. switch name {
  1024. case agent.FieldDeletedAt:
  1025. m.ClearDeletedAt()
  1026. return nil
  1027. case agent.FieldStatus:
  1028. m.ClearStatus()
  1029. return nil
  1030. case agent.FieldBackground:
  1031. m.ClearBackground()
  1032. return nil
  1033. case agent.FieldExamples:
  1034. m.ClearExamples()
  1035. return nil
  1036. }
  1037. return fmt.Errorf("unknown Agent nullable field %s", name)
  1038. }
  1039. // ResetField resets all changes in the mutation for the field with the given name.
  1040. // It returns an error if the field is not defined in the schema.
  1041. func (m *AgentMutation) ResetField(name string) error {
  1042. switch name {
  1043. case agent.FieldCreatedAt:
  1044. m.ResetCreatedAt()
  1045. return nil
  1046. case agent.FieldUpdatedAt:
  1047. m.ResetUpdatedAt()
  1048. return nil
  1049. case agent.FieldDeletedAt:
  1050. m.ResetDeletedAt()
  1051. return nil
  1052. case agent.FieldName:
  1053. m.ResetName()
  1054. return nil
  1055. case agent.FieldRole:
  1056. m.ResetRole()
  1057. return nil
  1058. case agent.FieldStatus:
  1059. m.ResetStatus()
  1060. return nil
  1061. case agent.FieldBackground:
  1062. m.ResetBackground()
  1063. return nil
  1064. case agent.FieldExamples:
  1065. m.ResetExamples()
  1066. return nil
  1067. case agent.FieldOrganizationID:
  1068. m.ResetOrganizationID()
  1069. return nil
  1070. case agent.FieldDatasetID:
  1071. m.ResetDatasetID()
  1072. return nil
  1073. case agent.FieldCollectionID:
  1074. m.ResetCollectionID()
  1075. return nil
  1076. }
  1077. return fmt.Errorf("unknown Agent field %s", name)
  1078. }
  1079. // AddedEdges returns all edge names that were set/added in this mutation.
  1080. func (m *AgentMutation) AddedEdges() []string {
  1081. edges := make([]string, 0, 2)
  1082. if m.wx_agent != nil {
  1083. edges = append(edges, agent.EdgeWxAgent)
  1084. }
  1085. if m.token_agent != nil {
  1086. edges = append(edges, agent.EdgeTokenAgent)
  1087. }
  1088. return edges
  1089. }
  1090. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1091. // name in this mutation.
  1092. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1093. switch name {
  1094. case agent.EdgeWxAgent:
  1095. ids := make([]ent.Value, 0, len(m.wx_agent))
  1096. for id := range m.wx_agent {
  1097. ids = append(ids, id)
  1098. }
  1099. return ids
  1100. case agent.EdgeTokenAgent:
  1101. ids := make([]ent.Value, 0, len(m.token_agent))
  1102. for id := range m.token_agent {
  1103. ids = append(ids, id)
  1104. }
  1105. return ids
  1106. }
  1107. return nil
  1108. }
  1109. // RemovedEdges returns all edge names that were removed in this mutation.
  1110. func (m *AgentMutation) RemovedEdges() []string {
  1111. edges := make([]string, 0, 2)
  1112. if m.removedwx_agent != nil {
  1113. edges = append(edges, agent.EdgeWxAgent)
  1114. }
  1115. if m.removedtoken_agent != nil {
  1116. edges = append(edges, agent.EdgeTokenAgent)
  1117. }
  1118. return edges
  1119. }
  1120. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1121. // the given name in this mutation.
  1122. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1123. switch name {
  1124. case agent.EdgeWxAgent:
  1125. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1126. for id := range m.removedwx_agent {
  1127. ids = append(ids, id)
  1128. }
  1129. return ids
  1130. case agent.EdgeTokenAgent:
  1131. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1132. for id := range m.removedtoken_agent {
  1133. ids = append(ids, id)
  1134. }
  1135. return ids
  1136. }
  1137. return nil
  1138. }
  1139. // ClearedEdges returns all edge names that were cleared in this mutation.
  1140. func (m *AgentMutation) ClearedEdges() []string {
  1141. edges := make([]string, 0, 2)
  1142. if m.clearedwx_agent {
  1143. edges = append(edges, agent.EdgeWxAgent)
  1144. }
  1145. if m.clearedtoken_agent {
  1146. edges = append(edges, agent.EdgeTokenAgent)
  1147. }
  1148. return edges
  1149. }
  1150. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1151. // was cleared in this mutation.
  1152. func (m *AgentMutation) EdgeCleared(name string) bool {
  1153. switch name {
  1154. case agent.EdgeWxAgent:
  1155. return m.clearedwx_agent
  1156. case agent.EdgeTokenAgent:
  1157. return m.clearedtoken_agent
  1158. }
  1159. return false
  1160. }
  1161. // ClearEdge clears the value of the edge with the given name. It returns an error
  1162. // if that edge is not defined in the schema.
  1163. func (m *AgentMutation) ClearEdge(name string) error {
  1164. switch name {
  1165. }
  1166. return fmt.Errorf("unknown Agent unique edge %s", name)
  1167. }
  1168. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1169. // It returns an error if the edge is not defined in the schema.
  1170. func (m *AgentMutation) ResetEdge(name string) error {
  1171. switch name {
  1172. case agent.EdgeWxAgent:
  1173. m.ResetWxAgent()
  1174. return nil
  1175. case agent.EdgeTokenAgent:
  1176. m.ResetTokenAgent()
  1177. return nil
  1178. }
  1179. return fmt.Errorf("unknown Agent edge %s", name)
  1180. }
  1181. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1182. type AgentBaseMutation struct {
  1183. config
  1184. op Op
  1185. typ string
  1186. id *string
  1187. q *string
  1188. a *string
  1189. chunk_index *uint64
  1190. addchunk_index *int64
  1191. indexes *[]string
  1192. appendindexes []string
  1193. dataset_id *string
  1194. collection_id *string
  1195. source_name *string
  1196. can_write *[]bool
  1197. appendcan_write []bool
  1198. is_owner *[]bool
  1199. appendis_owner []bool
  1200. clearedFields map[string]struct{}
  1201. wx_agent map[uint64]struct{}
  1202. removedwx_agent map[uint64]struct{}
  1203. clearedwx_agent bool
  1204. done bool
  1205. oldValue func(context.Context) (*AgentBase, error)
  1206. predicates []predicate.AgentBase
  1207. }
  1208. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1209. // agentbaseOption allows management of the mutation configuration using functional options.
  1210. type agentbaseOption func(*AgentBaseMutation)
  1211. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1212. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1213. m := &AgentBaseMutation{
  1214. config: c,
  1215. op: op,
  1216. typ: TypeAgentBase,
  1217. clearedFields: make(map[string]struct{}),
  1218. }
  1219. for _, opt := range opts {
  1220. opt(m)
  1221. }
  1222. return m
  1223. }
  1224. // withAgentBaseID sets the ID field of the mutation.
  1225. func withAgentBaseID(id string) agentbaseOption {
  1226. return func(m *AgentBaseMutation) {
  1227. var (
  1228. err error
  1229. once sync.Once
  1230. value *AgentBase
  1231. )
  1232. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1233. once.Do(func() {
  1234. if m.done {
  1235. err = errors.New("querying old values post mutation is not allowed")
  1236. } else {
  1237. value, err = m.Client().AgentBase.Get(ctx, id)
  1238. }
  1239. })
  1240. return value, err
  1241. }
  1242. m.id = &id
  1243. }
  1244. }
  1245. // withAgentBase sets the old AgentBase of the mutation.
  1246. func withAgentBase(node *AgentBase) agentbaseOption {
  1247. return func(m *AgentBaseMutation) {
  1248. m.oldValue = func(context.Context) (*AgentBase, error) {
  1249. return node, nil
  1250. }
  1251. m.id = &node.ID
  1252. }
  1253. }
  1254. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1255. // executed in a transaction (ent.Tx), a transactional client is returned.
  1256. func (m AgentBaseMutation) Client() *Client {
  1257. client := &Client{config: m.config}
  1258. client.init()
  1259. return client
  1260. }
  1261. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1262. // it returns an error otherwise.
  1263. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1264. if _, ok := m.driver.(*txDriver); !ok {
  1265. return nil, errors.New("ent: mutation is not running in a transaction")
  1266. }
  1267. tx := &Tx{config: m.config}
  1268. tx.init()
  1269. return tx, nil
  1270. }
  1271. // SetID sets the value of the id field. Note that this
  1272. // operation is only accepted on creation of AgentBase entities.
  1273. func (m *AgentBaseMutation) SetID(id string) {
  1274. m.id = &id
  1275. }
  1276. // ID returns the ID value in the mutation. Note that the ID is only available
  1277. // if it was provided to the builder or after it was returned from the database.
  1278. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1279. if m.id == nil {
  1280. return
  1281. }
  1282. return *m.id, true
  1283. }
  1284. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1285. // That means, if the mutation is applied within a transaction with an isolation level such
  1286. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1287. // or updated by the mutation.
  1288. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1289. switch {
  1290. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1291. id, exists := m.ID()
  1292. if exists {
  1293. return []string{id}, nil
  1294. }
  1295. fallthrough
  1296. case m.op.Is(OpUpdate | OpDelete):
  1297. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1298. default:
  1299. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1300. }
  1301. }
  1302. // SetQ sets the "q" field.
  1303. func (m *AgentBaseMutation) SetQ(s string) {
  1304. m.q = &s
  1305. }
  1306. // Q returns the value of the "q" field in the mutation.
  1307. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1308. v := m.q
  1309. if v == nil {
  1310. return
  1311. }
  1312. return *v, true
  1313. }
  1314. // OldQ returns the old "q" field's value of the AgentBase entity.
  1315. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1317. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1318. if !m.op.Is(OpUpdateOne) {
  1319. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1320. }
  1321. if m.id == nil || m.oldValue == nil {
  1322. return v, errors.New("OldQ requires an ID field in the mutation")
  1323. }
  1324. oldValue, err := m.oldValue(ctx)
  1325. if err != nil {
  1326. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1327. }
  1328. return oldValue.Q, nil
  1329. }
  1330. // ClearQ clears the value of the "q" field.
  1331. func (m *AgentBaseMutation) ClearQ() {
  1332. m.q = nil
  1333. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1334. }
  1335. // QCleared returns if the "q" field was cleared in this mutation.
  1336. func (m *AgentBaseMutation) QCleared() bool {
  1337. _, ok := m.clearedFields[agentbase.FieldQ]
  1338. return ok
  1339. }
  1340. // ResetQ resets all changes to the "q" field.
  1341. func (m *AgentBaseMutation) ResetQ() {
  1342. m.q = nil
  1343. delete(m.clearedFields, agentbase.FieldQ)
  1344. }
  1345. // SetA sets the "a" field.
  1346. func (m *AgentBaseMutation) SetA(s string) {
  1347. m.a = &s
  1348. }
  1349. // A returns the value of the "a" field in the mutation.
  1350. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1351. v := m.a
  1352. if v == nil {
  1353. return
  1354. }
  1355. return *v, true
  1356. }
  1357. // OldA returns the old "a" field's value of the AgentBase entity.
  1358. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1360. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1361. if !m.op.Is(OpUpdateOne) {
  1362. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1363. }
  1364. if m.id == nil || m.oldValue == nil {
  1365. return v, errors.New("OldA requires an ID field in the mutation")
  1366. }
  1367. oldValue, err := m.oldValue(ctx)
  1368. if err != nil {
  1369. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1370. }
  1371. return oldValue.A, nil
  1372. }
  1373. // ClearA clears the value of the "a" field.
  1374. func (m *AgentBaseMutation) ClearA() {
  1375. m.a = nil
  1376. m.clearedFields[agentbase.FieldA] = struct{}{}
  1377. }
  1378. // ACleared returns if the "a" field was cleared in this mutation.
  1379. func (m *AgentBaseMutation) ACleared() bool {
  1380. _, ok := m.clearedFields[agentbase.FieldA]
  1381. return ok
  1382. }
  1383. // ResetA resets all changes to the "a" field.
  1384. func (m *AgentBaseMutation) ResetA() {
  1385. m.a = nil
  1386. delete(m.clearedFields, agentbase.FieldA)
  1387. }
  1388. // SetChunkIndex sets the "chunk_index" field.
  1389. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1390. m.chunk_index = &u
  1391. m.addchunk_index = nil
  1392. }
  1393. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1394. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1395. v := m.chunk_index
  1396. if v == nil {
  1397. return
  1398. }
  1399. return *v, true
  1400. }
  1401. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1402. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1404. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1405. if !m.op.Is(OpUpdateOne) {
  1406. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1407. }
  1408. if m.id == nil || m.oldValue == nil {
  1409. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1410. }
  1411. oldValue, err := m.oldValue(ctx)
  1412. if err != nil {
  1413. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1414. }
  1415. return oldValue.ChunkIndex, nil
  1416. }
  1417. // AddChunkIndex adds u to the "chunk_index" field.
  1418. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1419. if m.addchunk_index != nil {
  1420. *m.addchunk_index += u
  1421. } else {
  1422. m.addchunk_index = &u
  1423. }
  1424. }
  1425. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1426. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1427. v := m.addchunk_index
  1428. if v == nil {
  1429. return
  1430. }
  1431. return *v, true
  1432. }
  1433. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1434. func (m *AgentBaseMutation) ResetChunkIndex() {
  1435. m.chunk_index = nil
  1436. m.addchunk_index = nil
  1437. }
  1438. // SetIndexes sets the "indexes" field.
  1439. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1440. m.indexes = &s
  1441. m.appendindexes = nil
  1442. }
  1443. // Indexes returns the value of the "indexes" field in the mutation.
  1444. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1445. v := m.indexes
  1446. if v == nil {
  1447. return
  1448. }
  1449. return *v, true
  1450. }
  1451. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1452. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1454. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1455. if !m.op.Is(OpUpdateOne) {
  1456. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1457. }
  1458. if m.id == nil || m.oldValue == nil {
  1459. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1460. }
  1461. oldValue, err := m.oldValue(ctx)
  1462. if err != nil {
  1463. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1464. }
  1465. return oldValue.Indexes, nil
  1466. }
  1467. // AppendIndexes adds s to the "indexes" field.
  1468. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1469. m.appendindexes = append(m.appendindexes, s...)
  1470. }
  1471. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1472. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1473. if len(m.appendindexes) == 0 {
  1474. return nil, false
  1475. }
  1476. return m.appendindexes, true
  1477. }
  1478. // ClearIndexes clears the value of the "indexes" field.
  1479. func (m *AgentBaseMutation) ClearIndexes() {
  1480. m.indexes = nil
  1481. m.appendindexes = nil
  1482. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1483. }
  1484. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1485. func (m *AgentBaseMutation) IndexesCleared() bool {
  1486. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1487. return ok
  1488. }
  1489. // ResetIndexes resets all changes to the "indexes" field.
  1490. func (m *AgentBaseMutation) ResetIndexes() {
  1491. m.indexes = nil
  1492. m.appendindexes = nil
  1493. delete(m.clearedFields, agentbase.FieldIndexes)
  1494. }
  1495. // SetDatasetID sets the "dataset_id" field.
  1496. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1497. m.dataset_id = &s
  1498. }
  1499. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1500. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1501. v := m.dataset_id
  1502. if v == nil {
  1503. return
  1504. }
  1505. return *v, true
  1506. }
  1507. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1508. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1510. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1511. if !m.op.Is(OpUpdateOne) {
  1512. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1513. }
  1514. if m.id == nil || m.oldValue == nil {
  1515. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1516. }
  1517. oldValue, err := m.oldValue(ctx)
  1518. if err != nil {
  1519. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1520. }
  1521. return oldValue.DatasetID, nil
  1522. }
  1523. // ClearDatasetID clears the value of the "dataset_id" field.
  1524. func (m *AgentBaseMutation) ClearDatasetID() {
  1525. m.dataset_id = nil
  1526. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1527. }
  1528. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1529. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1530. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1531. return ok
  1532. }
  1533. // ResetDatasetID resets all changes to the "dataset_id" field.
  1534. func (m *AgentBaseMutation) ResetDatasetID() {
  1535. m.dataset_id = nil
  1536. delete(m.clearedFields, agentbase.FieldDatasetID)
  1537. }
  1538. // SetCollectionID sets the "collection_id" field.
  1539. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1540. m.collection_id = &s
  1541. }
  1542. // CollectionID returns the value of the "collection_id" field in the mutation.
  1543. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1544. v := m.collection_id
  1545. if v == nil {
  1546. return
  1547. }
  1548. return *v, true
  1549. }
  1550. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1551. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1553. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1554. if !m.op.Is(OpUpdateOne) {
  1555. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1556. }
  1557. if m.id == nil || m.oldValue == nil {
  1558. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1559. }
  1560. oldValue, err := m.oldValue(ctx)
  1561. if err != nil {
  1562. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1563. }
  1564. return oldValue.CollectionID, nil
  1565. }
  1566. // ClearCollectionID clears the value of the "collection_id" field.
  1567. func (m *AgentBaseMutation) ClearCollectionID() {
  1568. m.collection_id = nil
  1569. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1570. }
  1571. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1572. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1573. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1574. return ok
  1575. }
  1576. // ResetCollectionID resets all changes to the "collection_id" field.
  1577. func (m *AgentBaseMutation) ResetCollectionID() {
  1578. m.collection_id = nil
  1579. delete(m.clearedFields, agentbase.FieldCollectionID)
  1580. }
  1581. // SetSourceName sets the "source_name" field.
  1582. func (m *AgentBaseMutation) SetSourceName(s string) {
  1583. m.source_name = &s
  1584. }
  1585. // SourceName returns the value of the "source_name" field in the mutation.
  1586. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1587. v := m.source_name
  1588. if v == nil {
  1589. return
  1590. }
  1591. return *v, true
  1592. }
  1593. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1594. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1596. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1597. if !m.op.Is(OpUpdateOne) {
  1598. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1599. }
  1600. if m.id == nil || m.oldValue == nil {
  1601. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1602. }
  1603. oldValue, err := m.oldValue(ctx)
  1604. if err != nil {
  1605. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1606. }
  1607. return oldValue.SourceName, nil
  1608. }
  1609. // ClearSourceName clears the value of the "source_name" field.
  1610. func (m *AgentBaseMutation) ClearSourceName() {
  1611. m.source_name = nil
  1612. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1613. }
  1614. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1615. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1616. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1617. return ok
  1618. }
  1619. // ResetSourceName resets all changes to the "source_name" field.
  1620. func (m *AgentBaseMutation) ResetSourceName() {
  1621. m.source_name = nil
  1622. delete(m.clearedFields, agentbase.FieldSourceName)
  1623. }
  1624. // SetCanWrite sets the "can_write" field.
  1625. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1626. m.can_write = &b
  1627. m.appendcan_write = nil
  1628. }
  1629. // CanWrite returns the value of the "can_write" field in the mutation.
  1630. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1631. v := m.can_write
  1632. if v == nil {
  1633. return
  1634. }
  1635. return *v, true
  1636. }
  1637. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1638. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1640. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1641. if !m.op.Is(OpUpdateOne) {
  1642. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1643. }
  1644. if m.id == nil || m.oldValue == nil {
  1645. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1646. }
  1647. oldValue, err := m.oldValue(ctx)
  1648. if err != nil {
  1649. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1650. }
  1651. return oldValue.CanWrite, nil
  1652. }
  1653. // AppendCanWrite adds b to the "can_write" field.
  1654. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1655. m.appendcan_write = append(m.appendcan_write, b...)
  1656. }
  1657. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1658. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1659. if len(m.appendcan_write) == 0 {
  1660. return nil, false
  1661. }
  1662. return m.appendcan_write, true
  1663. }
  1664. // ClearCanWrite clears the value of the "can_write" field.
  1665. func (m *AgentBaseMutation) ClearCanWrite() {
  1666. m.can_write = nil
  1667. m.appendcan_write = nil
  1668. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1669. }
  1670. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1671. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1672. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1673. return ok
  1674. }
  1675. // ResetCanWrite resets all changes to the "can_write" field.
  1676. func (m *AgentBaseMutation) ResetCanWrite() {
  1677. m.can_write = nil
  1678. m.appendcan_write = nil
  1679. delete(m.clearedFields, agentbase.FieldCanWrite)
  1680. }
  1681. // SetIsOwner sets the "is_owner" field.
  1682. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1683. m.is_owner = &b
  1684. m.appendis_owner = nil
  1685. }
  1686. // IsOwner returns the value of the "is_owner" field in the mutation.
  1687. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1688. v := m.is_owner
  1689. if v == nil {
  1690. return
  1691. }
  1692. return *v, true
  1693. }
  1694. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1695. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1697. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1698. if !m.op.Is(OpUpdateOne) {
  1699. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1700. }
  1701. if m.id == nil || m.oldValue == nil {
  1702. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1703. }
  1704. oldValue, err := m.oldValue(ctx)
  1705. if err != nil {
  1706. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1707. }
  1708. return oldValue.IsOwner, nil
  1709. }
  1710. // AppendIsOwner adds b to the "is_owner" field.
  1711. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1712. m.appendis_owner = append(m.appendis_owner, b...)
  1713. }
  1714. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1715. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1716. if len(m.appendis_owner) == 0 {
  1717. return nil, false
  1718. }
  1719. return m.appendis_owner, true
  1720. }
  1721. // ClearIsOwner clears the value of the "is_owner" field.
  1722. func (m *AgentBaseMutation) ClearIsOwner() {
  1723. m.is_owner = nil
  1724. m.appendis_owner = nil
  1725. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1726. }
  1727. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1728. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1729. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1730. return ok
  1731. }
  1732. // ResetIsOwner resets all changes to the "is_owner" field.
  1733. func (m *AgentBaseMutation) ResetIsOwner() {
  1734. m.is_owner = nil
  1735. m.appendis_owner = nil
  1736. delete(m.clearedFields, agentbase.FieldIsOwner)
  1737. }
  1738. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1739. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1740. if m.wx_agent == nil {
  1741. m.wx_agent = make(map[uint64]struct{})
  1742. }
  1743. for i := range ids {
  1744. m.wx_agent[ids[i]] = struct{}{}
  1745. }
  1746. }
  1747. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1748. func (m *AgentBaseMutation) ClearWxAgent() {
  1749. m.clearedwx_agent = true
  1750. }
  1751. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1752. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1753. return m.clearedwx_agent
  1754. }
  1755. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1756. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1757. if m.removedwx_agent == nil {
  1758. m.removedwx_agent = make(map[uint64]struct{})
  1759. }
  1760. for i := range ids {
  1761. delete(m.wx_agent, ids[i])
  1762. m.removedwx_agent[ids[i]] = struct{}{}
  1763. }
  1764. }
  1765. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1766. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1767. for id := range m.removedwx_agent {
  1768. ids = append(ids, id)
  1769. }
  1770. return
  1771. }
  1772. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1773. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1774. for id := range m.wx_agent {
  1775. ids = append(ids, id)
  1776. }
  1777. return
  1778. }
  1779. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1780. func (m *AgentBaseMutation) ResetWxAgent() {
  1781. m.wx_agent = nil
  1782. m.clearedwx_agent = false
  1783. m.removedwx_agent = nil
  1784. }
  1785. // Where appends a list predicates to the AgentBaseMutation builder.
  1786. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1787. m.predicates = append(m.predicates, ps...)
  1788. }
  1789. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1790. // users can use type-assertion to append predicates that do not depend on any generated package.
  1791. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1792. p := make([]predicate.AgentBase, len(ps))
  1793. for i := range ps {
  1794. p[i] = ps[i]
  1795. }
  1796. m.Where(p...)
  1797. }
  1798. // Op returns the operation name.
  1799. func (m *AgentBaseMutation) Op() Op {
  1800. return m.op
  1801. }
  1802. // SetOp allows setting the mutation operation.
  1803. func (m *AgentBaseMutation) SetOp(op Op) {
  1804. m.op = op
  1805. }
  1806. // Type returns the node type of this mutation (AgentBase).
  1807. func (m *AgentBaseMutation) Type() string {
  1808. return m.typ
  1809. }
  1810. // Fields returns all fields that were changed during this mutation. Note that in
  1811. // order to get all numeric fields that were incremented/decremented, call
  1812. // AddedFields().
  1813. func (m *AgentBaseMutation) Fields() []string {
  1814. fields := make([]string, 0, 9)
  1815. if m.q != nil {
  1816. fields = append(fields, agentbase.FieldQ)
  1817. }
  1818. if m.a != nil {
  1819. fields = append(fields, agentbase.FieldA)
  1820. }
  1821. if m.chunk_index != nil {
  1822. fields = append(fields, agentbase.FieldChunkIndex)
  1823. }
  1824. if m.indexes != nil {
  1825. fields = append(fields, agentbase.FieldIndexes)
  1826. }
  1827. if m.dataset_id != nil {
  1828. fields = append(fields, agentbase.FieldDatasetID)
  1829. }
  1830. if m.collection_id != nil {
  1831. fields = append(fields, agentbase.FieldCollectionID)
  1832. }
  1833. if m.source_name != nil {
  1834. fields = append(fields, agentbase.FieldSourceName)
  1835. }
  1836. if m.can_write != nil {
  1837. fields = append(fields, agentbase.FieldCanWrite)
  1838. }
  1839. if m.is_owner != nil {
  1840. fields = append(fields, agentbase.FieldIsOwner)
  1841. }
  1842. return fields
  1843. }
  1844. // Field returns the value of a field with the given name. The second boolean
  1845. // return value indicates that this field was not set, or was not defined in the
  1846. // schema.
  1847. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1848. switch name {
  1849. case agentbase.FieldQ:
  1850. return m.Q()
  1851. case agentbase.FieldA:
  1852. return m.A()
  1853. case agentbase.FieldChunkIndex:
  1854. return m.ChunkIndex()
  1855. case agentbase.FieldIndexes:
  1856. return m.Indexes()
  1857. case agentbase.FieldDatasetID:
  1858. return m.DatasetID()
  1859. case agentbase.FieldCollectionID:
  1860. return m.CollectionID()
  1861. case agentbase.FieldSourceName:
  1862. return m.SourceName()
  1863. case agentbase.FieldCanWrite:
  1864. return m.CanWrite()
  1865. case agentbase.FieldIsOwner:
  1866. return m.IsOwner()
  1867. }
  1868. return nil, false
  1869. }
  1870. // OldField returns the old value of the field from the database. An error is
  1871. // returned if the mutation operation is not UpdateOne, or the query to the
  1872. // database failed.
  1873. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1874. switch name {
  1875. case agentbase.FieldQ:
  1876. return m.OldQ(ctx)
  1877. case agentbase.FieldA:
  1878. return m.OldA(ctx)
  1879. case agentbase.FieldChunkIndex:
  1880. return m.OldChunkIndex(ctx)
  1881. case agentbase.FieldIndexes:
  1882. return m.OldIndexes(ctx)
  1883. case agentbase.FieldDatasetID:
  1884. return m.OldDatasetID(ctx)
  1885. case agentbase.FieldCollectionID:
  1886. return m.OldCollectionID(ctx)
  1887. case agentbase.FieldSourceName:
  1888. return m.OldSourceName(ctx)
  1889. case agentbase.FieldCanWrite:
  1890. return m.OldCanWrite(ctx)
  1891. case agentbase.FieldIsOwner:
  1892. return m.OldIsOwner(ctx)
  1893. }
  1894. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1895. }
  1896. // SetField sets the value of a field with the given name. It returns an error if
  1897. // the field is not defined in the schema, or if the type mismatched the field
  1898. // type.
  1899. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1900. switch name {
  1901. case agentbase.FieldQ:
  1902. v, ok := value.(string)
  1903. if !ok {
  1904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1905. }
  1906. m.SetQ(v)
  1907. return nil
  1908. case agentbase.FieldA:
  1909. v, ok := value.(string)
  1910. if !ok {
  1911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1912. }
  1913. m.SetA(v)
  1914. return nil
  1915. case agentbase.FieldChunkIndex:
  1916. v, ok := value.(uint64)
  1917. if !ok {
  1918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1919. }
  1920. m.SetChunkIndex(v)
  1921. return nil
  1922. case agentbase.FieldIndexes:
  1923. v, ok := value.([]string)
  1924. if !ok {
  1925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1926. }
  1927. m.SetIndexes(v)
  1928. return nil
  1929. case agentbase.FieldDatasetID:
  1930. v, ok := value.(string)
  1931. if !ok {
  1932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1933. }
  1934. m.SetDatasetID(v)
  1935. return nil
  1936. case agentbase.FieldCollectionID:
  1937. v, ok := value.(string)
  1938. if !ok {
  1939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1940. }
  1941. m.SetCollectionID(v)
  1942. return nil
  1943. case agentbase.FieldSourceName:
  1944. v, ok := value.(string)
  1945. if !ok {
  1946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1947. }
  1948. m.SetSourceName(v)
  1949. return nil
  1950. case agentbase.FieldCanWrite:
  1951. v, ok := value.([]bool)
  1952. if !ok {
  1953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1954. }
  1955. m.SetCanWrite(v)
  1956. return nil
  1957. case agentbase.FieldIsOwner:
  1958. v, ok := value.([]bool)
  1959. if !ok {
  1960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1961. }
  1962. m.SetIsOwner(v)
  1963. return nil
  1964. }
  1965. return fmt.Errorf("unknown AgentBase field %s", name)
  1966. }
  1967. // AddedFields returns all numeric fields that were incremented/decremented during
  1968. // this mutation.
  1969. func (m *AgentBaseMutation) AddedFields() []string {
  1970. var fields []string
  1971. if m.addchunk_index != nil {
  1972. fields = append(fields, agentbase.FieldChunkIndex)
  1973. }
  1974. return fields
  1975. }
  1976. // AddedField returns the numeric value that was incremented/decremented on a field
  1977. // with the given name. The second boolean return value indicates that this field
  1978. // was not set, or was not defined in the schema.
  1979. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1980. switch name {
  1981. case agentbase.FieldChunkIndex:
  1982. return m.AddedChunkIndex()
  1983. }
  1984. return nil, false
  1985. }
  1986. // AddField adds the value to the field with the given name. It returns an error if
  1987. // the field is not defined in the schema, or if the type mismatched the field
  1988. // type.
  1989. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1990. switch name {
  1991. case agentbase.FieldChunkIndex:
  1992. v, ok := value.(int64)
  1993. if !ok {
  1994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1995. }
  1996. m.AddChunkIndex(v)
  1997. return nil
  1998. }
  1999. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2000. }
  2001. // ClearedFields returns all nullable fields that were cleared during this
  2002. // mutation.
  2003. func (m *AgentBaseMutation) ClearedFields() []string {
  2004. var fields []string
  2005. if m.FieldCleared(agentbase.FieldQ) {
  2006. fields = append(fields, agentbase.FieldQ)
  2007. }
  2008. if m.FieldCleared(agentbase.FieldA) {
  2009. fields = append(fields, agentbase.FieldA)
  2010. }
  2011. if m.FieldCleared(agentbase.FieldIndexes) {
  2012. fields = append(fields, agentbase.FieldIndexes)
  2013. }
  2014. if m.FieldCleared(agentbase.FieldDatasetID) {
  2015. fields = append(fields, agentbase.FieldDatasetID)
  2016. }
  2017. if m.FieldCleared(agentbase.FieldCollectionID) {
  2018. fields = append(fields, agentbase.FieldCollectionID)
  2019. }
  2020. if m.FieldCleared(agentbase.FieldSourceName) {
  2021. fields = append(fields, agentbase.FieldSourceName)
  2022. }
  2023. if m.FieldCleared(agentbase.FieldCanWrite) {
  2024. fields = append(fields, agentbase.FieldCanWrite)
  2025. }
  2026. if m.FieldCleared(agentbase.FieldIsOwner) {
  2027. fields = append(fields, agentbase.FieldIsOwner)
  2028. }
  2029. return fields
  2030. }
  2031. // FieldCleared returns a boolean indicating if a field with the given name was
  2032. // cleared in this mutation.
  2033. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2034. _, ok := m.clearedFields[name]
  2035. return ok
  2036. }
  2037. // ClearField clears the value of the field with the given name. It returns an
  2038. // error if the field is not defined in the schema.
  2039. func (m *AgentBaseMutation) ClearField(name string) error {
  2040. switch name {
  2041. case agentbase.FieldQ:
  2042. m.ClearQ()
  2043. return nil
  2044. case agentbase.FieldA:
  2045. m.ClearA()
  2046. return nil
  2047. case agentbase.FieldIndexes:
  2048. m.ClearIndexes()
  2049. return nil
  2050. case agentbase.FieldDatasetID:
  2051. m.ClearDatasetID()
  2052. return nil
  2053. case agentbase.FieldCollectionID:
  2054. m.ClearCollectionID()
  2055. return nil
  2056. case agentbase.FieldSourceName:
  2057. m.ClearSourceName()
  2058. return nil
  2059. case agentbase.FieldCanWrite:
  2060. m.ClearCanWrite()
  2061. return nil
  2062. case agentbase.FieldIsOwner:
  2063. m.ClearIsOwner()
  2064. return nil
  2065. }
  2066. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2067. }
  2068. // ResetField resets all changes in the mutation for the field with the given name.
  2069. // It returns an error if the field is not defined in the schema.
  2070. func (m *AgentBaseMutation) ResetField(name string) error {
  2071. switch name {
  2072. case agentbase.FieldQ:
  2073. m.ResetQ()
  2074. return nil
  2075. case agentbase.FieldA:
  2076. m.ResetA()
  2077. return nil
  2078. case agentbase.FieldChunkIndex:
  2079. m.ResetChunkIndex()
  2080. return nil
  2081. case agentbase.FieldIndexes:
  2082. m.ResetIndexes()
  2083. return nil
  2084. case agentbase.FieldDatasetID:
  2085. m.ResetDatasetID()
  2086. return nil
  2087. case agentbase.FieldCollectionID:
  2088. m.ResetCollectionID()
  2089. return nil
  2090. case agentbase.FieldSourceName:
  2091. m.ResetSourceName()
  2092. return nil
  2093. case agentbase.FieldCanWrite:
  2094. m.ResetCanWrite()
  2095. return nil
  2096. case agentbase.FieldIsOwner:
  2097. m.ResetIsOwner()
  2098. return nil
  2099. }
  2100. return fmt.Errorf("unknown AgentBase field %s", name)
  2101. }
  2102. // AddedEdges returns all edge names that were set/added in this mutation.
  2103. func (m *AgentBaseMutation) AddedEdges() []string {
  2104. edges := make([]string, 0, 1)
  2105. if m.wx_agent != nil {
  2106. edges = append(edges, agentbase.EdgeWxAgent)
  2107. }
  2108. return edges
  2109. }
  2110. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2111. // name in this mutation.
  2112. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2113. switch name {
  2114. case agentbase.EdgeWxAgent:
  2115. ids := make([]ent.Value, 0, len(m.wx_agent))
  2116. for id := range m.wx_agent {
  2117. ids = append(ids, id)
  2118. }
  2119. return ids
  2120. }
  2121. return nil
  2122. }
  2123. // RemovedEdges returns all edge names that were removed in this mutation.
  2124. func (m *AgentBaseMutation) RemovedEdges() []string {
  2125. edges := make([]string, 0, 1)
  2126. if m.removedwx_agent != nil {
  2127. edges = append(edges, agentbase.EdgeWxAgent)
  2128. }
  2129. return edges
  2130. }
  2131. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2132. // the given name in this mutation.
  2133. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2134. switch name {
  2135. case agentbase.EdgeWxAgent:
  2136. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2137. for id := range m.removedwx_agent {
  2138. ids = append(ids, id)
  2139. }
  2140. return ids
  2141. }
  2142. return nil
  2143. }
  2144. // ClearedEdges returns all edge names that were cleared in this mutation.
  2145. func (m *AgentBaseMutation) ClearedEdges() []string {
  2146. edges := make([]string, 0, 1)
  2147. if m.clearedwx_agent {
  2148. edges = append(edges, agentbase.EdgeWxAgent)
  2149. }
  2150. return edges
  2151. }
  2152. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2153. // was cleared in this mutation.
  2154. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2155. switch name {
  2156. case agentbase.EdgeWxAgent:
  2157. return m.clearedwx_agent
  2158. }
  2159. return false
  2160. }
  2161. // ClearEdge clears the value of the edge with the given name. It returns an error
  2162. // if that edge is not defined in the schema.
  2163. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2164. switch name {
  2165. }
  2166. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2167. }
  2168. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2169. // It returns an error if the edge is not defined in the schema.
  2170. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2171. switch name {
  2172. case agentbase.EdgeWxAgent:
  2173. m.ResetWxAgent()
  2174. return nil
  2175. }
  2176. return fmt.Errorf("unknown AgentBase edge %s", name)
  2177. }
  2178. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2179. type AliyunAvatarMutation struct {
  2180. config
  2181. op Op
  2182. typ string
  2183. id *uint64
  2184. created_at *time.Time
  2185. updated_at *time.Time
  2186. deleted_at *time.Time
  2187. user_id *uint64
  2188. adduser_id *int64
  2189. biz_id *string
  2190. access_key_id *string
  2191. access_key_secret *string
  2192. app_id *string
  2193. tenant_id *uint64
  2194. addtenant_id *int64
  2195. response *string
  2196. token *string
  2197. session_id *string
  2198. clearedFields map[string]struct{}
  2199. done bool
  2200. oldValue func(context.Context) (*AliyunAvatar, error)
  2201. predicates []predicate.AliyunAvatar
  2202. }
  2203. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2204. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2205. type aliyunavatarOption func(*AliyunAvatarMutation)
  2206. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2207. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2208. m := &AliyunAvatarMutation{
  2209. config: c,
  2210. op: op,
  2211. typ: TypeAliyunAvatar,
  2212. clearedFields: make(map[string]struct{}),
  2213. }
  2214. for _, opt := range opts {
  2215. opt(m)
  2216. }
  2217. return m
  2218. }
  2219. // withAliyunAvatarID sets the ID field of the mutation.
  2220. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2221. return func(m *AliyunAvatarMutation) {
  2222. var (
  2223. err error
  2224. once sync.Once
  2225. value *AliyunAvatar
  2226. )
  2227. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2228. once.Do(func() {
  2229. if m.done {
  2230. err = errors.New("querying old values post mutation is not allowed")
  2231. } else {
  2232. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2233. }
  2234. })
  2235. return value, err
  2236. }
  2237. m.id = &id
  2238. }
  2239. }
  2240. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2241. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2242. return func(m *AliyunAvatarMutation) {
  2243. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2244. return node, nil
  2245. }
  2246. m.id = &node.ID
  2247. }
  2248. }
  2249. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2250. // executed in a transaction (ent.Tx), a transactional client is returned.
  2251. func (m AliyunAvatarMutation) Client() *Client {
  2252. client := &Client{config: m.config}
  2253. client.init()
  2254. return client
  2255. }
  2256. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2257. // it returns an error otherwise.
  2258. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2259. if _, ok := m.driver.(*txDriver); !ok {
  2260. return nil, errors.New("ent: mutation is not running in a transaction")
  2261. }
  2262. tx := &Tx{config: m.config}
  2263. tx.init()
  2264. return tx, nil
  2265. }
  2266. // SetID sets the value of the id field. Note that this
  2267. // operation is only accepted on creation of AliyunAvatar entities.
  2268. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2269. m.id = &id
  2270. }
  2271. // ID returns the ID value in the mutation. Note that the ID is only available
  2272. // if it was provided to the builder or after it was returned from the database.
  2273. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2274. if m.id == nil {
  2275. return
  2276. }
  2277. return *m.id, true
  2278. }
  2279. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2280. // That means, if the mutation is applied within a transaction with an isolation level such
  2281. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2282. // or updated by the mutation.
  2283. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2284. switch {
  2285. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2286. id, exists := m.ID()
  2287. if exists {
  2288. return []uint64{id}, nil
  2289. }
  2290. fallthrough
  2291. case m.op.Is(OpUpdate | OpDelete):
  2292. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2293. default:
  2294. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2295. }
  2296. }
  2297. // SetCreatedAt sets the "created_at" field.
  2298. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2299. m.created_at = &t
  2300. }
  2301. // CreatedAt returns the value of the "created_at" field in the mutation.
  2302. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2303. v := m.created_at
  2304. if v == nil {
  2305. return
  2306. }
  2307. return *v, true
  2308. }
  2309. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2310. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2312. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2313. if !m.op.Is(OpUpdateOne) {
  2314. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2315. }
  2316. if m.id == nil || m.oldValue == nil {
  2317. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2318. }
  2319. oldValue, err := m.oldValue(ctx)
  2320. if err != nil {
  2321. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2322. }
  2323. return oldValue.CreatedAt, nil
  2324. }
  2325. // ResetCreatedAt resets all changes to the "created_at" field.
  2326. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2327. m.created_at = nil
  2328. }
  2329. // SetUpdatedAt sets the "updated_at" field.
  2330. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2331. m.updated_at = &t
  2332. }
  2333. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2334. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2335. v := m.updated_at
  2336. if v == nil {
  2337. return
  2338. }
  2339. return *v, true
  2340. }
  2341. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2342. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2344. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2345. if !m.op.Is(OpUpdateOne) {
  2346. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2347. }
  2348. if m.id == nil || m.oldValue == nil {
  2349. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2350. }
  2351. oldValue, err := m.oldValue(ctx)
  2352. if err != nil {
  2353. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2354. }
  2355. return oldValue.UpdatedAt, nil
  2356. }
  2357. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2358. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2359. m.updated_at = nil
  2360. }
  2361. // SetDeletedAt sets the "deleted_at" field.
  2362. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2363. m.deleted_at = &t
  2364. }
  2365. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2366. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2367. v := m.deleted_at
  2368. if v == nil {
  2369. return
  2370. }
  2371. return *v, true
  2372. }
  2373. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2374. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2376. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2377. if !m.op.Is(OpUpdateOne) {
  2378. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2379. }
  2380. if m.id == nil || m.oldValue == nil {
  2381. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2382. }
  2383. oldValue, err := m.oldValue(ctx)
  2384. if err != nil {
  2385. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2386. }
  2387. return oldValue.DeletedAt, nil
  2388. }
  2389. // ClearDeletedAt clears the value of the "deleted_at" field.
  2390. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2391. m.deleted_at = nil
  2392. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2393. }
  2394. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2395. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2396. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2397. return ok
  2398. }
  2399. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2400. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2401. m.deleted_at = nil
  2402. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2403. }
  2404. // SetUserID sets the "user_id" field.
  2405. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2406. m.user_id = &u
  2407. m.adduser_id = nil
  2408. }
  2409. // UserID returns the value of the "user_id" field in the mutation.
  2410. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2411. v := m.user_id
  2412. if v == nil {
  2413. return
  2414. }
  2415. return *v, true
  2416. }
  2417. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2418. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2420. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2421. if !m.op.Is(OpUpdateOne) {
  2422. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2423. }
  2424. if m.id == nil || m.oldValue == nil {
  2425. return v, errors.New("OldUserID requires an ID field in the mutation")
  2426. }
  2427. oldValue, err := m.oldValue(ctx)
  2428. if err != nil {
  2429. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2430. }
  2431. return oldValue.UserID, nil
  2432. }
  2433. // AddUserID adds u to the "user_id" field.
  2434. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2435. if m.adduser_id != nil {
  2436. *m.adduser_id += u
  2437. } else {
  2438. m.adduser_id = &u
  2439. }
  2440. }
  2441. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2442. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2443. v := m.adduser_id
  2444. if v == nil {
  2445. return
  2446. }
  2447. return *v, true
  2448. }
  2449. // ResetUserID resets all changes to the "user_id" field.
  2450. func (m *AliyunAvatarMutation) ResetUserID() {
  2451. m.user_id = nil
  2452. m.adduser_id = nil
  2453. }
  2454. // SetBizID sets the "biz_id" field.
  2455. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2456. m.biz_id = &s
  2457. }
  2458. // BizID returns the value of the "biz_id" field in the mutation.
  2459. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2460. v := m.biz_id
  2461. if v == nil {
  2462. return
  2463. }
  2464. return *v, true
  2465. }
  2466. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2467. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2469. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2470. if !m.op.Is(OpUpdateOne) {
  2471. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2472. }
  2473. if m.id == nil || m.oldValue == nil {
  2474. return v, errors.New("OldBizID requires an ID field in the mutation")
  2475. }
  2476. oldValue, err := m.oldValue(ctx)
  2477. if err != nil {
  2478. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2479. }
  2480. return oldValue.BizID, nil
  2481. }
  2482. // ResetBizID resets all changes to the "biz_id" field.
  2483. func (m *AliyunAvatarMutation) ResetBizID() {
  2484. m.biz_id = nil
  2485. }
  2486. // SetAccessKeyID sets the "access_key_id" field.
  2487. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2488. m.access_key_id = &s
  2489. }
  2490. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2491. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2492. v := m.access_key_id
  2493. if v == nil {
  2494. return
  2495. }
  2496. return *v, true
  2497. }
  2498. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2499. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2501. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2502. if !m.op.Is(OpUpdateOne) {
  2503. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2504. }
  2505. if m.id == nil || m.oldValue == nil {
  2506. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2507. }
  2508. oldValue, err := m.oldValue(ctx)
  2509. if err != nil {
  2510. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2511. }
  2512. return oldValue.AccessKeyID, nil
  2513. }
  2514. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2515. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2516. m.access_key_id = nil
  2517. }
  2518. // SetAccessKeySecret sets the "access_key_secret" field.
  2519. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2520. m.access_key_secret = &s
  2521. }
  2522. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2523. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2524. v := m.access_key_secret
  2525. if v == nil {
  2526. return
  2527. }
  2528. return *v, true
  2529. }
  2530. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2531. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2533. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2534. if !m.op.Is(OpUpdateOne) {
  2535. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2536. }
  2537. if m.id == nil || m.oldValue == nil {
  2538. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2539. }
  2540. oldValue, err := m.oldValue(ctx)
  2541. if err != nil {
  2542. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2543. }
  2544. return oldValue.AccessKeySecret, nil
  2545. }
  2546. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2547. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2548. m.access_key_secret = nil
  2549. }
  2550. // SetAppID sets the "app_id" field.
  2551. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2552. m.app_id = &s
  2553. }
  2554. // AppID returns the value of the "app_id" field in the mutation.
  2555. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2556. v := m.app_id
  2557. if v == nil {
  2558. return
  2559. }
  2560. return *v, true
  2561. }
  2562. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2563. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2565. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2566. if !m.op.Is(OpUpdateOne) {
  2567. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2568. }
  2569. if m.id == nil || m.oldValue == nil {
  2570. return v, errors.New("OldAppID requires an ID field in the mutation")
  2571. }
  2572. oldValue, err := m.oldValue(ctx)
  2573. if err != nil {
  2574. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2575. }
  2576. return oldValue.AppID, nil
  2577. }
  2578. // ClearAppID clears the value of the "app_id" field.
  2579. func (m *AliyunAvatarMutation) ClearAppID() {
  2580. m.app_id = nil
  2581. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2582. }
  2583. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2584. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2585. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2586. return ok
  2587. }
  2588. // ResetAppID resets all changes to the "app_id" field.
  2589. func (m *AliyunAvatarMutation) ResetAppID() {
  2590. m.app_id = nil
  2591. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2592. }
  2593. // SetTenantID sets the "tenant_id" field.
  2594. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2595. m.tenant_id = &u
  2596. m.addtenant_id = nil
  2597. }
  2598. // TenantID returns the value of the "tenant_id" field in the mutation.
  2599. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2600. v := m.tenant_id
  2601. if v == nil {
  2602. return
  2603. }
  2604. return *v, true
  2605. }
  2606. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2607. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2609. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2610. if !m.op.Is(OpUpdateOne) {
  2611. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2612. }
  2613. if m.id == nil || m.oldValue == nil {
  2614. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2615. }
  2616. oldValue, err := m.oldValue(ctx)
  2617. if err != nil {
  2618. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2619. }
  2620. return oldValue.TenantID, nil
  2621. }
  2622. // AddTenantID adds u to the "tenant_id" field.
  2623. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2624. if m.addtenant_id != nil {
  2625. *m.addtenant_id += u
  2626. } else {
  2627. m.addtenant_id = &u
  2628. }
  2629. }
  2630. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2631. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2632. v := m.addtenant_id
  2633. if v == nil {
  2634. return
  2635. }
  2636. return *v, true
  2637. }
  2638. // ResetTenantID resets all changes to the "tenant_id" field.
  2639. func (m *AliyunAvatarMutation) ResetTenantID() {
  2640. m.tenant_id = nil
  2641. m.addtenant_id = nil
  2642. }
  2643. // SetResponse sets the "response" field.
  2644. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2645. m.response = &s
  2646. }
  2647. // Response returns the value of the "response" field in the mutation.
  2648. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2649. v := m.response
  2650. if v == nil {
  2651. return
  2652. }
  2653. return *v, true
  2654. }
  2655. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2656. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2658. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2659. if !m.op.Is(OpUpdateOne) {
  2660. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2661. }
  2662. if m.id == nil || m.oldValue == nil {
  2663. return v, errors.New("OldResponse requires an ID field in the mutation")
  2664. }
  2665. oldValue, err := m.oldValue(ctx)
  2666. if err != nil {
  2667. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2668. }
  2669. return oldValue.Response, nil
  2670. }
  2671. // ResetResponse resets all changes to the "response" field.
  2672. func (m *AliyunAvatarMutation) ResetResponse() {
  2673. m.response = nil
  2674. }
  2675. // SetToken sets the "token" field.
  2676. func (m *AliyunAvatarMutation) SetToken(s string) {
  2677. m.token = &s
  2678. }
  2679. // Token returns the value of the "token" field in the mutation.
  2680. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2681. v := m.token
  2682. if v == nil {
  2683. return
  2684. }
  2685. return *v, true
  2686. }
  2687. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2688. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2690. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2691. if !m.op.Is(OpUpdateOne) {
  2692. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2693. }
  2694. if m.id == nil || m.oldValue == nil {
  2695. return v, errors.New("OldToken requires an ID field in the mutation")
  2696. }
  2697. oldValue, err := m.oldValue(ctx)
  2698. if err != nil {
  2699. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2700. }
  2701. return oldValue.Token, nil
  2702. }
  2703. // ResetToken resets all changes to the "token" field.
  2704. func (m *AliyunAvatarMutation) ResetToken() {
  2705. m.token = nil
  2706. }
  2707. // SetSessionID sets the "session_id" field.
  2708. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2709. m.session_id = &s
  2710. }
  2711. // SessionID returns the value of the "session_id" field in the mutation.
  2712. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2713. v := m.session_id
  2714. if v == nil {
  2715. return
  2716. }
  2717. return *v, true
  2718. }
  2719. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2720. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2722. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2723. if !m.op.Is(OpUpdateOne) {
  2724. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2725. }
  2726. if m.id == nil || m.oldValue == nil {
  2727. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2728. }
  2729. oldValue, err := m.oldValue(ctx)
  2730. if err != nil {
  2731. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2732. }
  2733. return oldValue.SessionID, nil
  2734. }
  2735. // ResetSessionID resets all changes to the "session_id" field.
  2736. func (m *AliyunAvatarMutation) ResetSessionID() {
  2737. m.session_id = nil
  2738. }
  2739. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2740. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2741. m.predicates = append(m.predicates, ps...)
  2742. }
  2743. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2744. // users can use type-assertion to append predicates that do not depend on any generated package.
  2745. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2746. p := make([]predicate.AliyunAvatar, len(ps))
  2747. for i := range ps {
  2748. p[i] = ps[i]
  2749. }
  2750. m.Where(p...)
  2751. }
  2752. // Op returns the operation name.
  2753. func (m *AliyunAvatarMutation) Op() Op {
  2754. return m.op
  2755. }
  2756. // SetOp allows setting the mutation operation.
  2757. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2758. m.op = op
  2759. }
  2760. // Type returns the node type of this mutation (AliyunAvatar).
  2761. func (m *AliyunAvatarMutation) Type() string {
  2762. return m.typ
  2763. }
  2764. // Fields returns all fields that were changed during this mutation. Note that in
  2765. // order to get all numeric fields that were incremented/decremented, call
  2766. // AddedFields().
  2767. func (m *AliyunAvatarMutation) Fields() []string {
  2768. fields := make([]string, 0, 12)
  2769. if m.created_at != nil {
  2770. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2771. }
  2772. if m.updated_at != nil {
  2773. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2774. }
  2775. if m.deleted_at != nil {
  2776. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2777. }
  2778. if m.user_id != nil {
  2779. fields = append(fields, aliyunavatar.FieldUserID)
  2780. }
  2781. if m.biz_id != nil {
  2782. fields = append(fields, aliyunavatar.FieldBizID)
  2783. }
  2784. if m.access_key_id != nil {
  2785. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2786. }
  2787. if m.access_key_secret != nil {
  2788. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2789. }
  2790. if m.app_id != nil {
  2791. fields = append(fields, aliyunavatar.FieldAppID)
  2792. }
  2793. if m.tenant_id != nil {
  2794. fields = append(fields, aliyunavatar.FieldTenantID)
  2795. }
  2796. if m.response != nil {
  2797. fields = append(fields, aliyunavatar.FieldResponse)
  2798. }
  2799. if m.token != nil {
  2800. fields = append(fields, aliyunavatar.FieldToken)
  2801. }
  2802. if m.session_id != nil {
  2803. fields = append(fields, aliyunavatar.FieldSessionID)
  2804. }
  2805. return fields
  2806. }
  2807. // Field returns the value of a field with the given name. The second boolean
  2808. // return value indicates that this field was not set, or was not defined in the
  2809. // schema.
  2810. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2811. switch name {
  2812. case aliyunavatar.FieldCreatedAt:
  2813. return m.CreatedAt()
  2814. case aliyunavatar.FieldUpdatedAt:
  2815. return m.UpdatedAt()
  2816. case aliyunavatar.FieldDeletedAt:
  2817. return m.DeletedAt()
  2818. case aliyunavatar.FieldUserID:
  2819. return m.UserID()
  2820. case aliyunavatar.FieldBizID:
  2821. return m.BizID()
  2822. case aliyunavatar.FieldAccessKeyID:
  2823. return m.AccessKeyID()
  2824. case aliyunavatar.FieldAccessKeySecret:
  2825. return m.AccessKeySecret()
  2826. case aliyunavatar.FieldAppID:
  2827. return m.AppID()
  2828. case aliyunavatar.FieldTenantID:
  2829. return m.TenantID()
  2830. case aliyunavatar.FieldResponse:
  2831. return m.Response()
  2832. case aliyunavatar.FieldToken:
  2833. return m.Token()
  2834. case aliyunavatar.FieldSessionID:
  2835. return m.SessionID()
  2836. }
  2837. return nil, false
  2838. }
  2839. // OldField returns the old value of the field from the database. An error is
  2840. // returned if the mutation operation is not UpdateOne, or the query to the
  2841. // database failed.
  2842. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2843. switch name {
  2844. case aliyunavatar.FieldCreatedAt:
  2845. return m.OldCreatedAt(ctx)
  2846. case aliyunavatar.FieldUpdatedAt:
  2847. return m.OldUpdatedAt(ctx)
  2848. case aliyunavatar.FieldDeletedAt:
  2849. return m.OldDeletedAt(ctx)
  2850. case aliyunavatar.FieldUserID:
  2851. return m.OldUserID(ctx)
  2852. case aliyunavatar.FieldBizID:
  2853. return m.OldBizID(ctx)
  2854. case aliyunavatar.FieldAccessKeyID:
  2855. return m.OldAccessKeyID(ctx)
  2856. case aliyunavatar.FieldAccessKeySecret:
  2857. return m.OldAccessKeySecret(ctx)
  2858. case aliyunavatar.FieldAppID:
  2859. return m.OldAppID(ctx)
  2860. case aliyunavatar.FieldTenantID:
  2861. return m.OldTenantID(ctx)
  2862. case aliyunavatar.FieldResponse:
  2863. return m.OldResponse(ctx)
  2864. case aliyunavatar.FieldToken:
  2865. return m.OldToken(ctx)
  2866. case aliyunavatar.FieldSessionID:
  2867. return m.OldSessionID(ctx)
  2868. }
  2869. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2870. }
  2871. // SetField sets the value of a field with the given name. It returns an error if
  2872. // the field is not defined in the schema, or if the type mismatched the field
  2873. // type.
  2874. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2875. switch name {
  2876. case aliyunavatar.FieldCreatedAt:
  2877. v, ok := value.(time.Time)
  2878. if !ok {
  2879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2880. }
  2881. m.SetCreatedAt(v)
  2882. return nil
  2883. case aliyunavatar.FieldUpdatedAt:
  2884. v, ok := value.(time.Time)
  2885. if !ok {
  2886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2887. }
  2888. m.SetUpdatedAt(v)
  2889. return nil
  2890. case aliyunavatar.FieldDeletedAt:
  2891. v, ok := value.(time.Time)
  2892. if !ok {
  2893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2894. }
  2895. m.SetDeletedAt(v)
  2896. return nil
  2897. case aliyunavatar.FieldUserID:
  2898. v, ok := value.(uint64)
  2899. if !ok {
  2900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2901. }
  2902. m.SetUserID(v)
  2903. return nil
  2904. case aliyunavatar.FieldBizID:
  2905. v, ok := value.(string)
  2906. if !ok {
  2907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2908. }
  2909. m.SetBizID(v)
  2910. return nil
  2911. case aliyunavatar.FieldAccessKeyID:
  2912. v, ok := value.(string)
  2913. if !ok {
  2914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2915. }
  2916. m.SetAccessKeyID(v)
  2917. return nil
  2918. case aliyunavatar.FieldAccessKeySecret:
  2919. v, ok := value.(string)
  2920. if !ok {
  2921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2922. }
  2923. m.SetAccessKeySecret(v)
  2924. return nil
  2925. case aliyunavatar.FieldAppID:
  2926. v, ok := value.(string)
  2927. if !ok {
  2928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2929. }
  2930. m.SetAppID(v)
  2931. return nil
  2932. case aliyunavatar.FieldTenantID:
  2933. v, ok := value.(uint64)
  2934. if !ok {
  2935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2936. }
  2937. m.SetTenantID(v)
  2938. return nil
  2939. case aliyunavatar.FieldResponse:
  2940. v, ok := value.(string)
  2941. if !ok {
  2942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2943. }
  2944. m.SetResponse(v)
  2945. return nil
  2946. case aliyunavatar.FieldToken:
  2947. v, ok := value.(string)
  2948. if !ok {
  2949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2950. }
  2951. m.SetToken(v)
  2952. return nil
  2953. case aliyunavatar.FieldSessionID:
  2954. v, ok := value.(string)
  2955. if !ok {
  2956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2957. }
  2958. m.SetSessionID(v)
  2959. return nil
  2960. }
  2961. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2962. }
  2963. // AddedFields returns all numeric fields that were incremented/decremented during
  2964. // this mutation.
  2965. func (m *AliyunAvatarMutation) AddedFields() []string {
  2966. var fields []string
  2967. if m.adduser_id != nil {
  2968. fields = append(fields, aliyunavatar.FieldUserID)
  2969. }
  2970. if m.addtenant_id != nil {
  2971. fields = append(fields, aliyunavatar.FieldTenantID)
  2972. }
  2973. return fields
  2974. }
  2975. // AddedField returns the numeric value that was incremented/decremented on a field
  2976. // with the given name. The second boolean return value indicates that this field
  2977. // was not set, or was not defined in the schema.
  2978. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2979. switch name {
  2980. case aliyunavatar.FieldUserID:
  2981. return m.AddedUserID()
  2982. case aliyunavatar.FieldTenantID:
  2983. return m.AddedTenantID()
  2984. }
  2985. return nil, false
  2986. }
  2987. // AddField adds the value to the field with the given name. It returns an error if
  2988. // the field is not defined in the schema, or if the type mismatched the field
  2989. // type.
  2990. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2991. switch name {
  2992. case aliyunavatar.FieldUserID:
  2993. v, ok := value.(int64)
  2994. if !ok {
  2995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2996. }
  2997. m.AddUserID(v)
  2998. return nil
  2999. case aliyunavatar.FieldTenantID:
  3000. v, ok := value.(int64)
  3001. if !ok {
  3002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3003. }
  3004. m.AddTenantID(v)
  3005. return nil
  3006. }
  3007. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3008. }
  3009. // ClearedFields returns all nullable fields that were cleared during this
  3010. // mutation.
  3011. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3012. var fields []string
  3013. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3014. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3015. }
  3016. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3017. fields = append(fields, aliyunavatar.FieldAppID)
  3018. }
  3019. return fields
  3020. }
  3021. // FieldCleared returns a boolean indicating if a field with the given name was
  3022. // cleared in this mutation.
  3023. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3024. _, ok := m.clearedFields[name]
  3025. return ok
  3026. }
  3027. // ClearField clears the value of the field with the given name. It returns an
  3028. // error if the field is not defined in the schema.
  3029. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3030. switch name {
  3031. case aliyunavatar.FieldDeletedAt:
  3032. m.ClearDeletedAt()
  3033. return nil
  3034. case aliyunavatar.FieldAppID:
  3035. m.ClearAppID()
  3036. return nil
  3037. }
  3038. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3039. }
  3040. // ResetField resets all changes in the mutation for the field with the given name.
  3041. // It returns an error if the field is not defined in the schema.
  3042. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3043. switch name {
  3044. case aliyunavatar.FieldCreatedAt:
  3045. m.ResetCreatedAt()
  3046. return nil
  3047. case aliyunavatar.FieldUpdatedAt:
  3048. m.ResetUpdatedAt()
  3049. return nil
  3050. case aliyunavatar.FieldDeletedAt:
  3051. m.ResetDeletedAt()
  3052. return nil
  3053. case aliyunavatar.FieldUserID:
  3054. m.ResetUserID()
  3055. return nil
  3056. case aliyunavatar.FieldBizID:
  3057. m.ResetBizID()
  3058. return nil
  3059. case aliyunavatar.FieldAccessKeyID:
  3060. m.ResetAccessKeyID()
  3061. return nil
  3062. case aliyunavatar.FieldAccessKeySecret:
  3063. m.ResetAccessKeySecret()
  3064. return nil
  3065. case aliyunavatar.FieldAppID:
  3066. m.ResetAppID()
  3067. return nil
  3068. case aliyunavatar.FieldTenantID:
  3069. m.ResetTenantID()
  3070. return nil
  3071. case aliyunavatar.FieldResponse:
  3072. m.ResetResponse()
  3073. return nil
  3074. case aliyunavatar.FieldToken:
  3075. m.ResetToken()
  3076. return nil
  3077. case aliyunavatar.FieldSessionID:
  3078. m.ResetSessionID()
  3079. return nil
  3080. }
  3081. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3082. }
  3083. // AddedEdges returns all edge names that were set/added in this mutation.
  3084. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3085. edges := make([]string, 0, 0)
  3086. return edges
  3087. }
  3088. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3089. // name in this mutation.
  3090. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3091. return nil
  3092. }
  3093. // RemovedEdges returns all edge names that were removed in this mutation.
  3094. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3095. edges := make([]string, 0, 0)
  3096. return edges
  3097. }
  3098. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3099. // the given name in this mutation.
  3100. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3101. return nil
  3102. }
  3103. // ClearedEdges returns all edge names that were cleared in this mutation.
  3104. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3105. edges := make([]string, 0, 0)
  3106. return edges
  3107. }
  3108. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3109. // was cleared in this mutation.
  3110. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3111. return false
  3112. }
  3113. // ClearEdge clears the value of the edge with the given name. It returns an error
  3114. // if that edge is not defined in the schema.
  3115. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3116. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3117. }
  3118. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3119. // It returns an error if the edge is not defined in the schema.
  3120. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3121. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3122. }
  3123. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3124. type BatchMsgMutation struct {
  3125. config
  3126. op Op
  3127. typ string
  3128. id *uint64
  3129. created_at *time.Time
  3130. updated_at *time.Time
  3131. deleted_at *time.Time
  3132. status *uint8
  3133. addstatus *int8
  3134. batch_no *string
  3135. task_name *string
  3136. fromwxid *string
  3137. msg *string
  3138. tag *string
  3139. tagids *string
  3140. total *int32
  3141. addtotal *int32
  3142. success *int32
  3143. addsuccess *int32
  3144. fail *int32
  3145. addfail *int32
  3146. start_time *time.Time
  3147. stop_time *time.Time
  3148. send_time *time.Time
  3149. _type *int32
  3150. add_type *int32
  3151. organization_id *uint64
  3152. addorganization_id *int64
  3153. clearedFields map[string]struct{}
  3154. done bool
  3155. oldValue func(context.Context) (*BatchMsg, error)
  3156. predicates []predicate.BatchMsg
  3157. }
  3158. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3159. // batchmsgOption allows management of the mutation configuration using functional options.
  3160. type batchmsgOption func(*BatchMsgMutation)
  3161. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3162. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3163. m := &BatchMsgMutation{
  3164. config: c,
  3165. op: op,
  3166. typ: TypeBatchMsg,
  3167. clearedFields: make(map[string]struct{}),
  3168. }
  3169. for _, opt := range opts {
  3170. opt(m)
  3171. }
  3172. return m
  3173. }
  3174. // withBatchMsgID sets the ID field of the mutation.
  3175. func withBatchMsgID(id uint64) batchmsgOption {
  3176. return func(m *BatchMsgMutation) {
  3177. var (
  3178. err error
  3179. once sync.Once
  3180. value *BatchMsg
  3181. )
  3182. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3183. once.Do(func() {
  3184. if m.done {
  3185. err = errors.New("querying old values post mutation is not allowed")
  3186. } else {
  3187. value, err = m.Client().BatchMsg.Get(ctx, id)
  3188. }
  3189. })
  3190. return value, err
  3191. }
  3192. m.id = &id
  3193. }
  3194. }
  3195. // withBatchMsg sets the old BatchMsg of the mutation.
  3196. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3197. return func(m *BatchMsgMutation) {
  3198. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3199. return node, nil
  3200. }
  3201. m.id = &node.ID
  3202. }
  3203. }
  3204. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3205. // executed in a transaction (ent.Tx), a transactional client is returned.
  3206. func (m BatchMsgMutation) Client() *Client {
  3207. client := &Client{config: m.config}
  3208. client.init()
  3209. return client
  3210. }
  3211. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3212. // it returns an error otherwise.
  3213. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3214. if _, ok := m.driver.(*txDriver); !ok {
  3215. return nil, errors.New("ent: mutation is not running in a transaction")
  3216. }
  3217. tx := &Tx{config: m.config}
  3218. tx.init()
  3219. return tx, nil
  3220. }
  3221. // SetID sets the value of the id field. Note that this
  3222. // operation is only accepted on creation of BatchMsg entities.
  3223. func (m *BatchMsgMutation) SetID(id uint64) {
  3224. m.id = &id
  3225. }
  3226. // ID returns the ID value in the mutation. Note that the ID is only available
  3227. // if it was provided to the builder or after it was returned from the database.
  3228. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3229. if m.id == nil {
  3230. return
  3231. }
  3232. return *m.id, true
  3233. }
  3234. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3235. // That means, if the mutation is applied within a transaction with an isolation level such
  3236. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3237. // or updated by the mutation.
  3238. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3239. switch {
  3240. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3241. id, exists := m.ID()
  3242. if exists {
  3243. return []uint64{id}, nil
  3244. }
  3245. fallthrough
  3246. case m.op.Is(OpUpdate | OpDelete):
  3247. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3248. default:
  3249. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3250. }
  3251. }
  3252. // SetCreatedAt sets the "created_at" field.
  3253. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  3254. m.created_at = &t
  3255. }
  3256. // CreatedAt returns the value of the "created_at" field in the mutation.
  3257. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  3258. v := m.created_at
  3259. if v == nil {
  3260. return
  3261. }
  3262. return *v, true
  3263. }
  3264. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  3265. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3267. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3268. if !m.op.Is(OpUpdateOne) {
  3269. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3270. }
  3271. if m.id == nil || m.oldValue == nil {
  3272. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3273. }
  3274. oldValue, err := m.oldValue(ctx)
  3275. if err != nil {
  3276. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3277. }
  3278. return oldValue.CreatedAt, nil
  3279. }
  3280. // ResetCreatedAt resets all changes to the "created_at" field.
  3281. func (m *BatchMsgMutation) ResetCreatedAt() {
  3282. m.created_at = nil
  3283. }
  3284. // SetUpdatedAt sets the "updated_at" field.
  3285. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  3286. m.updated_at = &t
  3287. }
  3288. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3289. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  3290. v := m.updated_at
  3291. if v == nil {
  3292. return
  3293. }
  3294. return *v, true
  3295. }
  3296. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  3297. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3299. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3300. if !m.op.Is(OpUpdateOne) {
  3301. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3302. }
  3303. if m.id == nil || m.oldValue == nil {
  3304. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3305. }
  3306. oldValue, err := m.oldValue(ctx)
  3307. if err != nil {
  3308. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3309. }
  3310. return oldValue.UpdatedAt, nil
  3311. }
  3312. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3313. func (m *BatchMsgMutation) ResetUpdatedAt() {
  3314. m.updated_at = nil
  3315. }
  3316. // SetDeletedAt sets the "deleted_at" field.
  3317. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  3318. m.deleted_at = &t
  3319. }
  3320. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3321. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  3322. v := m.deleted_at
  3323. if v == nil {
  3324. return
  3325. }
  3326. return *v, true
  3327. }
  3328. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  3329. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3331. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3332. if !m.op.Is(OpUpdateOne) {
  3333. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3334. }
  3335. if m.id == nil || m.oldValue == nil {
  3336. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3337. }
  3338. oldValue, err := m.oldValue(ctx)
  3339. if err != nil {
  3340. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3341. }
  3342. return oldValue.DeletedAt, nil
  3343. }
  3344. // ClearDeletedAt clears the value of the "deleted_at" field.
  3345. func (m *BatchMsgMutation) ClearDeletedAt() {
  3346. m.deleted_at = nil
  3347. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  3348. }
  3349. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3350. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  3351. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  3352. return ok
  3353. }
  3354. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3355. func (m *BatchMsgMutation) ResetDeletedAt() {
  3356. m.deleted_at = nil
  3357. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  3358. }
  3359. // SetStatus sets the "status" field.
  3360. func (m *BatchMsgMutation) SetStatus(u uint8) {
  3361. m.status = &u
  3362. m.addstatus = nil
  3363. }
  3364. // Status returns the value of the "status" field in the mutation.
  3365. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  3366. v := m.status
  3367. if v == nil {
  3368. return
  3369. }
  3370. return *v, true
  3371. }
  3372. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  3373. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3375. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3376. if !m.op.Is(OpUpdateOne) {
  3377. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3378. }
  3379. if m.id == nil || m.oldValue == nil {
  3380. return v, errors.New("OldStatus requires an ID field in the mutation")
  3381. }
  3382. oldValue, err := m.oldValue(ctx)
  3383. if err != nil {
  3384. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3385. }
  3386. return oldValue.Status, nil
  3387. }
  3388. // AddStatus adds u to the "status" field.
  3389. func (m *BatchMsgMutation) AddStatus(u int8) {
  3390. if m.addstatus != nil {
  3391. *m.addstatus += u
  3392. } else {
  3393. m.addstatus = &u
  3394. }
  3395. }
  3396. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3397. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  3398. v := m.addstatus
  3399. if v == nil {
  3400. return
  3401. }
  3402. return *v, true
  3403. }
  3404. // ClearStatus clears the value of the "status" field.
  3405. func (m *BatchMsgMutation) ClearStatus() {
  3406. m.status = nil
  3407. m.addstatus = nil
  3408. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  3409. }
  3410. // StatusCleared returns if the "status" field was cleared in this mutation.
  3411. func (m *BatchMsgMutation) StatusCleared() bool {
  3412. _, ok := m.clearedFields[batchmsg.FieldStatus]
  3413. return ok
  3414. }
  3415. // ResetStatus resets all changes to the "status" field.
  3416. func (m *BatchMsgMutation) ResetStatus() {
  3417. m.status = nil
  3418. m.addstatus = nil
  3419. delete(m.clearedFields, batchmsg.FieldStatus)
  3420. }
  3421. // SetBatchNo sets the "batch_no" field.
  3422. func (m *BatchMsgMutation) SetBatchNo(s string) {
  3423. m.batch_no = &s
  3424. }
  3425. // BatchNo returns the value of the "batch_no" field in the mutation.
  3426. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  3427. v := m.batch_no
  3428. if v == nil {
  3429. return
  3430. }
  3431. return *v, true
  3432. }
  3433. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  3434. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3436. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  3437. if !m.op.Is(OpUpdateOne) {
  3438. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  3439. }
  3440. if m.id == nil || m.oldValue == nil {
  3441. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  3442. }
  3443. oldValue, err := m.oldValue(ctx)
  3444. if err != nil {
  3445. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  3446. }
  3447. return oldValue.BatchNo, nil
  3448. }
  3449. // ClearBatchNo clears the value of the "batch_no" field.
  3450. func (m *BatchMsgMutation) ClearBatchNo() {
  3451. m.batch_no = nil
  3452. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  3453. }
  3454. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  3455. func (m *BatchMsgMutation) BatchNoCleared() bool {
  3456. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  3457. return ok
  3458. }
  3459. // ResetBatchNo resets all changes to the "batch_no" field.
  3460. func (m *BatchMsgMutation) ResetBatchNo() {
  3461. m.batch_no = nil
  3462. delete(m.clearedFields, batchmsg.FieldBatchNo)
  3463. }
  3464. // SetTaskName sets the "task_name" field.
  3465. func (m *BatchMsgMutation) SetTaskName(s string) {
  3466. m.task_name = &s
  3467. }
  3468. // TaskName returns the value of the "task_name" field in the mutation.
  3469. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  3470. v := m.task_name
  3471. if v == nil {
  3472. return
  3473. }
  3474. return *v, true
  3475. }
  3476. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  3477. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3479. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  3480. if !m.op.Is(OpUpdateOne) {
  3481. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  3482. }
  3483. if m.id == nil || m.oldValue == nil {
  3484. return v, errors.New("OldTaskName requires an ID field in the mutation")
  3485. }
  3486. oldValue, err := m.oldValue(ctx)
  3487. if err != nil {
  3488. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  3489. }
  3490. return oldValue.TaskName, nil
  3491. }
  3492. // ClearTaskName clears the value of the "task_name" field.
  3493. func (m *BatchMsgMutation) ClearTaskName() {
  3494. m.task_name = nil
  3495. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  3496. }
  3497. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  3498. func (m *BatchMsgMutation) TaskNameCleared() bool {
  3499. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  3500. return ok
  3501. }
  3502. // ResetTaskName resets all changes to the "task_name" field.
  3503. func (m *BatchMsgMutation) ResetTaskName() {
  3504. m.task_name = nil
  3505. delete(m.clearedFields, batchmsg.FieldTaskName)
  3506. }
  3507. // SetFromwxid sets the "fromwxid" field.
  3508. func (m *BatchMsgMutation) SetFromwxid(s string) {
  3509. m.fromwxid = &s
  3510. }
  3511. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  3512. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  3513. v := m.fromwxid
  3514. if v == nil {
  3515. return
  3516. }
  3517. return *v, true
  3518. }
  3519. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  3520. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3522. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  3523. if !m.op.Is(OpUpdateOne) {
  3524. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  3525. }
  3526. if m.id == nil || m.oldValue == nil {
  3527. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  3528. }
  3529. oldValue, err := m.oldValue(ctx)
  3530. if err != nil {
  3531. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  3532. }
  3533. return oldValue.Fromwxid, nil
  3534. }
  3535. // ClearFromwxid clears the value of the "fromwxid" field.
  3536. func (m *BatchMsgMutation) ClearFromwxid() {
  3537. m.fromwxid = nil
  3538. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  3539. }
  3540. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  3541. func (m *BatchMsgMutation) FromwxidCleared() bool {
  3542. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  3543. return ok
  3544. }
  3545. // ResetFromwxid resets all changes to the "fromwxid" field.
  3546. func (m *BatchMsgMutation) ResetFromwxid() {
  3547. m.fromwxid = nil
  3548. delete(m.clearedFields, batchmsg.FieldFromwxid)
  3549. }
  3550. // SetMsg sets the "msg" field.
  3551. func (m *BatchMsgMutation) SetMsg(s string) {
  3552. m.msg = &s
  3553. }
  3554. // Msg returns the value of the "msg" field in the mutation.
  3555. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  3556. v := m.msg
  3557. if v == nil {
  3558. return
  3559. }
  3560. return *v, true
  3561. }
  3562. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  3563. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3565. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  3566. if !m.op.Is(OpUpdateOne) {
  3567. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  3568. }
  3569. if m.id == nil || m.oldValue == nil {
  3570. return v, errors.New("OldMsg requires an ID field in the mutation")
  3571. }
  3572. oldValue, err := m.oldValue(ctx)
  3573. if err != nil {
  3574. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  3575. }
  3576. return oldValue.Msg, nil
  3577. }
  3578. // ClearMsg clears the value of the "msg" field.
  3579. func (m *BatchMsgMutation) ClearMsg() {
  3580. m.msg = nil
  3581. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  3582. }
  3583. // MsgCleared returns if the "msg" field was cleared in this mutation.
  3584. func (m *BatchMsgMutation) MsgCleared() bool {
  3585. _, ok := m.clearedFields[batchmsg.FieldMsg]
  3586. return ok
  3587. }
  3588. // ResetMsg resets all changes to the "msg" field.
  3589. func (m *BatchMsgMutation) ResetMsg() {
  3590. m.msg = nil
  3591. delete(m.clearedFields, batchmsg.FieldMsg)
  3592. }
  3593. // SetTag sets the "tag" field.
  3594. func (m *BatchMsgMutation) SetTag(s string) {
  3595. m.tag = &s
  3596. }
  3597. // Tag returns the value of the "tag" field in the mutation.
  3598. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  3599. v := m.tag
  3600. if v == nil {
  3601. return
  3602. }
  3603. return *v, true
  3604. }
  3605. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  3606. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3608. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  3609. if !m.op.Is(OpUpdateOne) {
  3610. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  3611. }
  3612. if m.id == nil || m.oldValue == nil {
  3613. return v, errors.New("OldTag requires an ID field in the mutation")
  3614. }
  3615. oldValue, err := m.oldValue(ctx)
  3616. if err != nil {
  3617. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  3618. }
  3619. return oldValue.Tag, nil
  3620. }
  3621. // ClearTag clears the value of the "tag" field.
  3622. func (m *BatchMsgMutation) ClearTag() {
  3623. m.tag = nil
  3624. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  3625. }
  3626. // TagCleared returns if the "tag" field was cleared in this mutation.
  3627. func (m *BatchMsgMutation) TagCleared() bool {
  3628. _, ok := m.clearedFields[batchmsg.FieldTag]
  3629. return ok
  3630. }
  3631. // ResetTag resets all changes to the "tag" field.
  3632. func (m *BatchMsgMutation) ResetTag() {
  3633. m.tag = nil
  3634. delete(m.clearedFields, batchmsg.FieldTag)
  3635. }
  3636. // SetTagids sets the "tagids" field.
  3637. func (m *BatchMsgMutation) SetTagids(s string) {
  3638. m.tagids = &s
  3639. }
  3640. // Tagids returns the value of the "tagids" field in the mutation.
  3641. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  3642. v := m.tagids
  3643. if v == nil {
  3644. return
  3645. }
  3646. return *v, true
  3647. }
  3648. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  3649. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3651. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  3652. if !m.op.Is(OpUpdateOne) {
  3653. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  3654. }
  3655. if m.id == nil || m.oldValue == nil {
  3656. return v, errors.New("OldTagids requires an ID field in the mutation")
  3657. }
  3658. oldValue, err := m.oldValue(ctx)
  3659. if err != nil {
  3660. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  3661. }
  3662. return oldValue.Tagids, nil
  3663. }
  3664. // ClearTagids clears the value of the "tagids" field.
  3665. func (m *BatchMsgMutation) ClearTagids() {
  3666. m.tagids = nil
  3667. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  3668. }
  3669. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  3670. func (m *BatchMsgMutation) TagidsCleared() bool {
  3671. _, ok := m.clearedFields[batchmsg.FieldTagids]
  3672. return ok
  3673. }
  3674. // ResetTagids resets all changes to the "tagids" field.
  3675. func (m *BatchMsgMutation) ResetTagids() {
  3676. m.tagids = nil
  3677. delete(m.clearedFields, batchmsg.FieldTagids)
  3678. }
  3679. // SetTotal sets the "total" field.
  3680. func (m *BatchMsgMutation) SetTotal(i int32) {
  3681. m.total = &i
  3682. m.addtotal = nil
  3683. }
  3684. // Total returns the value of the "total" field in the mutation.
  3685. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  3686. v := m.total
  3687. if v == nil {
  3688. return
  3689. }
  3690. return *v, true
  3691. }
  3692. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  3693. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3695. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  3696. if !m.op.Is(OpUpdateOne) {
  3697. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  3698. }
  3699. if m.id == nil || m.oldValue == nil {
  3700. return v, errors.New("OldTotal requires an ID field in the mutation")
  3701. }
  3702. oldValue, err := m.oldValue(ctx)
  3703. if err != nil {
  3704. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  3705. }
  3706. return oldValue.Total, nil
  3707. }
  3708. // AddTotal adds i to the "total" field.
  3709. func (m *BatchMsgMutation) AddTotal(i int32) {
  3710. if m.addtotal != nil {
  3711. *m.addtotal += i
  3712. } else {
  3713. m.addtotal = &i
  3714. }
  3715. }
  3716. // AddedTotal returns the value that was added to the "total" field in this mutation.
  3717. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  3718. v := m.addtotal
  3719. if v == nil {
  3720. return
  3721. }
  3722. return *v, true
  3723. }
  3724. // ClearTotal clears the value of the "total" field.
  3725. func (m *BatchMsgMutation) ClearTotal() {
  3726. m.total = nil
  3727. m.addtotal = nil
  3728. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  3729. }
  3730. // TotalCleared returns if the "total" field was cleared in this mutation.
  3731. func (m *BatchMsgMutation) TotalCleared() bool {
  3732. _, ok := m.clearedFields[batchmsg.FieldTotal]
  3733. return ok
  3734. }
  3735. // ResetTotal resets all changes to the "total" field.
  3736. func (m *BatchMsgMutation) ResetTotal() {
  3737. m.total = nil
  3738. m.addtotal = nil
  3739. delete(m.clearedFields, batchmsg.FieldTotal)
  3740. }
  3741. // SetSuccess sets the "success" field.
  3742. func (m *BatchMsgMutation) SetSuccess(i int32) {
  3743. m.success = &i
  3744. m.addsuccess = nil
  3745. }
  3746. // Success returns the value of the "success" field in the mutation.
  3747. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  3748. v := m.success
  3749. if v == nil {
  3750. return
  3751. }
  3752. return *v, true
  3753. }
  3754. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  3755. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3757. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  3758. if !m.op.Is(OpUpdateOne) {
  3759. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  3760. }
  3761. if m.id == nil || m.oldValue == nil {
  3762. return v, errors.New("OldSuccess requires an ID field in the mutation")
  3763. }
  3764. oldValue, err := m.oldValue(ctx)
  3765. if err != nil {
  3766. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  3767. }
  3768. return oldValue.Success, nil
  3769. }
  3770. // AddSuccess adds i to the "success" field.
  3771. func (m *BatchMsgMutation) AddSuccess(i int32) {
  3772. if m.addsuccess != nil {
  3773. *m.addsuccess += i
  3774. } else {
  3775. m.addsuccess = &i
  3776. }
  3777. }
  3778. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  3779. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  3780. v := m.addsuccess
  3781. if v == nil {
  3782. return
  3783. }
  3784. return *v, true
  3785. }
  3786. // ClearSuccess clears the value of the "success" field.
  3787. func (m *BatchMsgMutation) ClearSuccess() {
  3788. m.success = nil
  3789. m.addsuccess = nil
  3790. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  3791. }
  3792. // SuccessCleared returns if the "success" field was cleared in this mutation.
  3793. func (m *BatchMsgMutation) SuccessCleared() bool {
  3794. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  3795. return ok
  3796. }
  3797. // ResetSuccess resets all changes to the "success" field.
  3798. func (m *BatchMsgMutation) ResetSuccess() {
  3799. m.success = nil
  3800. m.addsuccess = nil
  3801. delete(m.clearedFields, batchmsg.FieldSuccess)
  3802. }
  3803. // SetFail sets the "fail" field.
  3804. func (m *BatchMsgMutation) SetFail(i int32) {
  3805. m.fail = &i
  3806. m.addfail = nil
  3807. }
  3808. // Fail returns the value of the "fail" field in the mutation.
  3809. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  3810. v := m.fail
  3811. if v == nil {
  3812. return
  3813. }
  3814. return *v, true
  3815. }
  3816. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  3817. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3819. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  3820. if !m.op.Is(OpUpdateOne) {
  3821. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  3822. }
  3823. if m.id == nil || m.oldValue == nil {
  3824. return v, errors.New("OldFail requires an ID field in the mutation")
  3825. }
  3826. oldValue, err := m.oldValue(ctx)
  3827. if err != nil {
  3828. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  3829. }
  3830. return oldValue.Fail, nil
  3831. }
  3832. // AddFail adds i to the "fail" field.
  3833. func (m *BatchMsgMutation) AddFail(i int32) {
  3834. if m.addfail != nil {
  3835. *m.addfail += i
  3836. } else {
  3837. m.addfail = &i
  3838. }
  3839. }
  3840. // AddedFail returns the value that was added to the "fail" field in this mutation.
  3841. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  3842. v := m.addfail
  3843. if v == nil {
  3844. return
  3845. }
  3846. return *v, true
  3847. }
  3848. // ClearFail clears the value of the "fail" field.
  3849. func (m *BatchMsgMutation) ClearFail() {
  3850. m.fail = nil
  3851. m.addfail = nil
  3852. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  3853. }
  3854. // FailCleared returns if the "fail" field was cleared in this mutation.
  3855. func (m *BatchMsgMutation) FailCleared() bool {
  3856. _, ok := m.clearedFields[batchmsg.FieldFail]
  3857. return ok
  3858. }
  3859. // ResetFail resets all changes to the "fail" field.
  3860. func (m *BatchMsgMutation) ResetFail() {
  3861. m.fail = nil
  3862. m.addfail = nil
  3863. delete(m.clearedFields, batchmsg.FieldFail)
  3864. }
  3865. // SetStartTime sets the "start_time" field.
  3866. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  3867. m.start_time = &t
  3868. }
  3869. // StartTime returns the value of the "start_time" field in the mutation.
  3870. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  3871. v := m.start_time
  3872. if v == nil {
  3873. return
  3874. }
  3875. return *v, true
  3876. }
  3877. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  3878. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3880. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  3881. if !m.op.Is(OpUpdateOne) {
  3882. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  3883. }
  3884. if m.id == nil || m.oldValue == nil {
  3885. return v, errors.New("OldStartTime requires an ID field in the mutation")
  3886. }
  3887. oldValue, err := m.oldValue(ctx)
  3888. if err != nil {
  3889. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  3890. }
  3891. return oldValue.StartTime, nil
  3892. }
  3893. // ClearStartTime clears the value of the "start_time" field.
  3894. func (m *BatchMsgMutation) ClearStartTime() {
  3895. m.start_time = nil
  3896. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  3897. }
  3898. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  3899. func (m *BatchMsgMutation) StartTimeCleared() bool {
  3900. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  3901. return ok
  3902. }
  3903. // ResetStartTime resets all changes to the "start_time" field.
  3904. func (m *BatchMsgMutation) ResetStartTime() {
  3905. m.start_time = nil
  3906. delete(m.clearedFields, batchmsg.FieldStartTime)
  3907. }
  3908. // SetStopTime sets the "stop_time" field.
  3909. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  3910. m.stop_time = &t
  3911. }
  3912. // StopTime returns the value of the "stop_time" field in the mutation.
  3913. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  3914. v := m.stop_time
  3915. if v == nil {
  3916. return
  3917. }
  3918. return *v, true
  3919. }
  3920. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  3921. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3923. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  3924. if !m.op.Is(OpUpdateOne) {
  3925. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  3926. }
  3927. if m.id == nil || m.oldValue == nil {
  3928. return v, errors.New("OldStopTime requires an ID field in the mutation")
  3929. }
  3930. oldValue, err := m.oldValue(ctx)
  3931. if err != nil {
  3932. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  3933. }
  3934. return oldValue.StopTime, nil
  3935. }
  3936. // ClearStopTime clears the value of the "stop_time" field.
  3937. func (m *BatchMsgMutation) ClearStopTime() {
  3938. m.stop_time = nil
  3939. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  3940. }
  3941. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  3942. func (m *BatchMsgMutation) StopTimeCleared() bool {
  3943. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  3944. return ok
  3945. }
  3946. // ResetStopTime resets all changes to the "stop_time" field.
  3947. func (m *BatchMsgMutation) ResetStopTime() {
  3948. m.stop_time = nil
  3949. delete(m.clearedFields, batchmsg.FieldStopTime)
  3950. }
  3951. // SetSendTime sets the "send_time" field.
  3952. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  3953. m.send_time = &t
  3954. }
  3955. // SendTime returns the value of the "send_time" field in the mutation.
  3956. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  3957. v := m.send_time
  3958. if v == nil {
  3959. return
  3960. }
  3961. return *v, true
  3962. }
  3963. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  3964. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3966. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  3967. if !m.op.Is(OpUpdateOne) {
  3968. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  3969. }
  3970. if m.id == nil || m.oldValue == nil {
  3971. return v, errors.New("OldSendTime requires an ID field in the mutation")
  3972. }
  3973. oldValue, err := m.oldValue(ctx)
  3974. if err != nil {
  3975. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  3976. }
  3977. return oldValue.SendTime, nil
  3978. }
  3979. // ClearSendTime clears the value of the "send_time" field.
  3980. func (m *BatchMsgMutation) ClearSendTime() {
  3981. m.send_time = nil
  3982. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  3983. }
  3984. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  3985. func (m *BatchMsgMutation) SendTimeCleared() bool {
  3986. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  3987. return ok
  3988. }
  3989. // ResetSendTime resets all changes to the "send_time" field.
  3990. func (m *BatchMsgMutation) ResetSendTime() {
  3991. m.send_time = nil
  3992. delete(m.clearedFields, batchmsg.FieldSendTime)
  3993. }
  3994. // SetType sets the "type" field.
  3995. func (m *BatchMsgMutation) SetType(i int32) {
  3996. m._type = &i
  3997. m.add_type = nil
  3998. }
  3999. // GetType returns the value of the "type" field in the mutation.
  4000. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4001. v := m._type
  4002. if v == nil {
  4003. return
  4004. }
  4005. return *v, true
  4006. }
  4007. // OldType returns the old "type" field's value of the BatchMsg entity.
  4008. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4010. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4011. if !m.op.Is(OpUpdateOne) {
  4012. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4013. }
  4014. if m.id == nil || m.oldValue == nil {
  4015. return v, errors.New("OldType requires an ID field in the mutation")
  4016. }
  4017. oldValue, err := m.oldValue(ctx)
  4018. if err != nil {
  4019. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4020. }
  4021. return oldValue.Type, nil
  4022. }
  4023. // AddType adds i to the "type" field.
  4024. func (m *BatchMsgMutation) AddType(i int32) {
  4025. if m.add_type != nil {
  4026. *m.add_type += i
  4027. } else {
  4028. m.add_type = &i
  4029. }
  4030. }
  4031. // AddedType returns the value that was added to the "type" field in this mutation.
  4032. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4033. v := m.add_type
  4034. if v == nil {
  4035. return
  4036. }
  4037. return *v, true
  4038. }
  4039. // ClearType clears the value of the "type" field.
  4040. func (m *BatchMsgMutation) ClearType() {
  4041. m._type = nil
  4042. m.add_type = nil
  4043. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4044. }
  4045. // TypeCleared returns if the "type" field was cleared in this mutation.
  4046. func (m *BatchMsgMutation) TypeCleared() bool {
  4047. _, ok := m.clearedFields[batchmsg.FieldType]
  4048. return ok
  4049. }
  4050. // ResetType resets all changes to the "type" field.
  4051. func (m *BatchMsgMutation) ResetType() {
  4052. m._type = nil
  4053. m.add_type = nil
  4054. delete(m.clearedFields, batchmsg.FieldType)
  4055. }
  4056. // SetOrganizationID sets the "organization_id" field.
  4057. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4058. m.organization_id = &u
  4059. m.addorganization_id = nil
  4060. }
  4061. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4062. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4063. v := m.organization_id
  4064. if v == nil {
  4065. return
  4066. }
  4067. return *v, true
  4068. }
  4069. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4070. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4072. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4073. if !m.op.Is(OpUpdateOne) {
  4074. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4075. }
  4076. if m.id == nil || m.oldValue == nil {
  4077. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4078. }
  4079. oldValue, err := m.oldValue(ctx)
  4080. if err != nil {
  4081. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4082. }
  4083. return oldValue.OrganizationID, nil
  4084. }
  4085. // AddOrganizationID adds u to the "organization_id" field.
  4086. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4087. if m.addorganization_id != nil {
  4088. *m.addorganization_id += u
  4089. } else {
  4090. m.addorganization_id = &u
  4091. }
  4092. }
  4093. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4094. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4095. v := m.addorganization_id
  4096. if v == nil {
  4097. return
  4098. }
  4099. return *v, true
  4100. }
  4101. // ResetOrganizationID resets all changes to the "organization_id" field.
  4102. func (m *BatchMsgMutation) ResetOrganizationID() {
  4103. m.organization_id = nil
  4104. m.addorganization_id = nil
  4105. }
  4106. // Where appends a list predicates to the BatchMsgMutation builder.
  4107. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4108. m.predicates = append(m.predicates, ps...)
  4109. }
  4110. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4111. // users can use type-assertion to append predicates that do not depend on any generated package.
  4112. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4113. p := make([]predicate.BatchMsg, len(ps))
  4114. for i := range ps {
  4115. p[i] = ps[i]
  4116. }
  4117. m.Where(p...)
  4118. }
  4119. // Op returns the operation name.
  4120. func (m *BatchMsgMutation) Op() Op {
  4121. return m.op
  4122. }
  4123. // SetOp allows setting the mutation operation.
  4124. func (m *BatchMsgMutation) SetOp(op Op) {
  4125. m.op = op
  4126. }
  4127. // Type returns the node type of this mutation (BatchMsg).
  4128. func (m *BatchMsgMutation) Type() string {
  4129. return m.typ
  4130. }
  4131. // Fields returns all fields that were changed during this mutation. Note that in
  4132. // order to get all numeric fields that were incremented/decremented, call
  4133. // AddedFields().
  4134. func (m *BatchMsgMutation) Fields() []string {
  4135. fields := make([]string, 0, 18)
  4136. if m.created_at != nil {
  4137. fields = append(fields, batchmsg.FieldCreatedAt)
  4138. }
  4139. if m.updated_at != nil {
  4140. fields = append(fields, batchmsg.FieldUpdatedAt)
  4141. }
  4142. if m.deleted_at != nil {
  4143. fields = append(fields, batchmsg.FieldDeletedAt)
  4144. }
  4145. if m.status != nil {
  4146. fields = append(fields, batchmsg.FieldStatus)
  4147. }
  4148. if m.batch_no != nil {
  4149. fields = append(fields, batchmsg.FieldBatchNo)
  4150. }
  4151. if m.task_name != nil {
  4152. fields = append(fields, batchmsg.FieldTaskName)
  4153. }
  4154. if m.fromwxid != nil {
  4155. fields = append(fields, batchmsg.FieldFromwxid)
  4156. }
  4157. if m.msg != nil {
  4158. fields = append(fields, batchmsg.FieldMsg)
  4159. }
  4160. if m.tag != nil {
  4161. fields = append(fields, batchmsg.FieldTag)
  4162. }
  4163. if m.tagids != nil {
  4164. fields = append(fields, batchmsg.FieldTagids)
  4165. }
  4166. if m.total != nil {
  4167. fields = append(fields, batchmsg.FieldTotal)
  4168. }
  4169. if m.success != nil {
  4170. fields = append(fields, batchmsg.FieldSuccess)
  4171. }
  4172. if m.fail != nil {
  4173. fields = append(fields, batchmsg.FieldFail)
  4174. }
  4175. if m.start_time != nil {
  4176. fields = append(fields, batchmsg.FieldStartTime)
  4177. }
  4178. if m.stop_time != nil {
  4179. fields = append(fields, batchmsg.FieldStopTime)
  4180. }
  4181. if m.send_time != nil {
  4182. fields = append(fields, batchmsg.FieldSendTime)
  4183. }
  4184. if m._type != nil {
  4185. fields = append(fields, batchmsg.FieldType)
  4186. }
  4187. if m.organization_id != nil {
  4188. fields = append(fields, batchmsg.FieldOrganizationID)
  4189. }
  4190. return fields
  4191. }
  4192. // Field returns the value of a field with the given name. The second boolean
  4193. // return value indicates that this field was not set, or was not defined in the
  4194. // schema.
  4195. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4196. switch name {
  4197. case batchmsg.FieldCreatedAt:
  4198. return m.CreatedAt()
  4199. case batchmsg.FieldUpdatedAt:
  4200. return m.UpdatedAt()
  4201. case batchmsg.FieldDeletedAt:
  4202. return m.DeletedAt()
  4203. case batchmsg.FieldStatus:
  4204. return m.Status()
  4205. case batchmsg.FieldBatchNo:
  4206. return m.BatchNo()
  4207. case batchmsg.FieldTaskName:
  4208. return m.TaskName()
  4209. case batchmsg.FieldFromwxid:
  4210. return m.Fromwxid()
  4211. case batchmsg.FieldMsg:
  4212. return m.Msg()
  4213. case batchmsg.FieldTag:
  4214. return m.Tag()
  4215. case batchmsg.FieldTagids:
  4216. return m.Tagids()
  4217. case batchmsg.FieldTotal:
  4218. return m.Total()
  4219. case batchmsg.FieldSuccess:
  4220. return m.Success()
  4221. case batchmsg.FieldFail:
  4222. return m.Fail()
  4223. case batchmsg.FieldStartTime:
  4224. return m.StartTime()
  4225. case batchmsg.FieldStopTime:
  4226. return m.StopTime()
  4227. case batchmsg.FieldSendTime:
  4228. return m.SendTime()
  4229. case batchmsg.FieldType:
  4230. return m.GetType()
  4231. case batchmsg.FieldOrganizationID:
  4232. return m.OrganizationID()
  4233. }
  4234. return nil, false
  4235. }
  4236. // OldField returns the old value of the field from the database. An error is
  4237. // returned if the mutation operation is not UpdateOne, or the query to the
  4238. // database failed.
  4239. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4240. switch name {
  4241. case batchmsg.FieldCreatedAt:
  4242. return m.OldCreatedAt(ctx)
  4243. case batchmsg.FieldUpdatedAt:
  4244. return m.OldUpdatedAt(ctx)
  4245. case batchmsg.FieldDeletedAt:
  4246. return m.OldDeletedAt(ctx)
  4247. case batchmsg.FieldStatus:
  4248. return m.OldStatus(ctx)
  4249. case batchmsg.FieldBatchNo:
  4250. return m.OldBatchNo(ctx)
  4251. case batchmsg.FieldTaskName:
  4252. return m.OldTaskName(ctx)
  4253. case batchmsg.FieldFromwxid:
  4254. return m.OldFromwxid(ctx)
  4255. case batchmsg.FieldMsg:
  4256. return m.OldMsg(ctx)
  4257. case batchmsg.FieldTag:
  4258. return m.OldTag(ctx)
  4259. case batchmsg.FieldTagids:
  4260. return m.OldTagids(ctx)
  4261. case batchmsg.FieldTotal:
  4262. return m.OldTotal(ctx)
  4263. case batchmsg.FieldSuccess:
  4264. return m.OldSuccess(ctx)
  4265. case batchmsg.FieldFail:
  4266. return m.OldFail(ctx)
  4267. case batchmsg.FieldStartTime:
  4268. return m.OldStartTime(ctx)
  4269. case batchmsg.FieldStopTime:
  4270. return m.OldStopTime(ctx)
  4271. case batchmsg.FieldSendTime:
  4272. return m.OldSendTime(ctx)
  4273. case batchmsg.FieldType:
  4274. return m.OldType(ctx)
  4275. case batchmsg.FieldOrganizationID:
  4276. return m.OldOrganizationID(ctx)
  4277. }
  4278. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  4279. }
  4280. // SetField sets the value of a field with the given name. It returns an error if
  4281. // the field is not defined in the schema, or if the type mismatched the field
  4282. // type.
  4283. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  4284. switch name {
  4285. case batchmsg.FieldCreatedAt:
  4286. v, ok := value.(time.Time)
  4287. if !ok {
  4288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4289. }
  4290. m.SetCreatedAt(v)
  4291. return nil
  4292. case batchmsg.FieldUpdatedAt:
  4293. v, ok := value.(time.Time)
  4294. if !ok {
  4295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4296. }
  4297. m.SetUpdatedAt(v)
  4298. return nil
  4299. case batchmsg.FieldDeletedAt:
  4300. v, ok := value.(time.Time)
  4301. if !ok {
  4302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4303. }
  4304. m.SetDeletedAt(v)
  4305. return nil
  4306. case batchmsg.FieldStatus:
  4307. v, ok := value.(uint8)
  4308. if !ok {
  4309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4310. }
  4311. m.SetStatus(v)
  4312. return nil
  4313. case batchmsg.FieldBatchNo:
  4314. v, ok := value.(string)
  4315. if !ok {
  4316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4317. }
  4318. m.SetBatchNo(v)
  4319. return nil
  4320. case batchmsg.FieldTaskName:
  4321. v, ok := value.(string)
  4322. if !ok {
  4323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4324. }
  4325. m.SetTaskName(v)
  4326. return nil
  4327. case batchmsg.FieldFromwxid:
  4328. v, ok := value.(string)
  4329. if !ok {
  4330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4331. }
  4332. m.SetFromwxid(v)
  4333. return nil
  4334. case batchmsg.FieldMsg:
  4335. v, ok := value.(string)
  4336. if !ok {
  4337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4338. }
  4339. m.SetMsg(v)
  4340. return nil
  4341. case batchmsg.FieldTag:
  4342. v, ok := value.(string)
  4343. if !ok {
  4344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4345. }
  4346. m.SetTag(v)
  4347. return nil
  4348. case batchmsg.FieldTagids:
  4349. v, ok := value.(string)
  4350. if !ok {
  4351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4352. }
  4353. m.SetTagids(v)
  4354. return nil
  4355. case batchmsg.FieldTotal:
  4356. v, ok := value.(int32)
  4357. if !ok {
  4358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4359. }
  4360. m.SetTotal(v)
  4361. return nil
  4362. case batchmsg.FieldSuccess:
  4363. v, ok := value.(int32)
  4364. if !ok {
  4365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4366. }
  4367. m.SetSuccess(v)
  4368. return nil
  4369. case batchmsg.FieldFail:
  4370. v, ok := value.(int32)
  4371. if !ok {
  4372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4373. }
  4374. m.SetFail(v)
  4375. return nil
  4376. case batchmsg.FieldStartTime:
  4377. v, ok := value.(time.Time)
  4378. if !ok {
  4379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4380. }
  4381. m.SetStartTime(v)
  4382. return nil
  4383. case batchmsg.FieldStopTime:
  4384. v, ok := value.(time.Time)
  4385. if !ok {
  4386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4387. }
  4388. m.SetStopTime(v)
  4389. return nil
  4390. case batchmsg.FieldSendTime:
  4391. v, ok := value.(time.Time)
  4392. if !ok {
  4393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4394. }
  4395. m.SetSendTime(v)
  4396. return nil
  4397. case batchmsg.FieldType:
  4398. v, ok := value.(int32)
  4399. if !ok {
  4400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4401. }
  4402. m.SetType(v)
  4403. return nil
  4404. case batchmsg.FieldOrganizationID:
  4405. v, ok := value.(uint64)
  4406. if !ok {
  4407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4408. }
  4409. m.SetOrganizationID(v)
  4410. return nil
  4411. }
  4412. return fmt.Errorf("unknown BatchMsg field %s", name)
  4413. }
  4414. // AddedFields returns all numeric fields that were incremented/decremented during
  4415. // this mutation.
  4416. func (m *BatchMsgMutation) AddedFields() []string {
  4417. var fields []string
  4418. if m.addstatus != nil {
  4419. fields = append(fields, batchmsg.FieldStatus)
  4420. }
  4421. if m.addtotal != nil {
  4422. fields = append(fields, batchmsg.FieldTotal)
  4423. }
  4424. if m.addsuccess != nil {
  4425. fields = append(fields, batchmsg.FieldSuccess)
  4426. }
  4427. if m.addfail != nil {
  4428. fields = append(fields, batchmsg.FieldFail)
  4429. }
  4430. if m.add_type != nil {
  4431. fields = append(fields, batchmsg.FieldType)
  4432. }
  4433. if m.addorganization_id != nil {
  4434. fields = append(fields, batchmsg.FieldOrganizationID)
  4435. }
  4436. return fields
  4437. }
  4438. // AddedField returns the numeric value that was incremented/decremented on a field
  4439. // with the given name. The second boolean return value indicates that this field
  4440. // was not set, or was not defined in the schema.
  4441. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  4442. switch name {
  4443. case batchmsg.FieldStatus:
  4444. return m.AddedStatus()
  4445. case batchmsg.FieldTotal:
  4446. return m.AddedTotal()
  4447. case batchmsg.FieldSuccess:
  4448. return m.AddedSuccess()
  4449. case batchmsg.FieldFail:
  4450. return m.AddedFail()
  4451. case batchmsg.FieldType:
  4452. return m.AddedType()
  4453. case batchmsg.FieldOrganizationID:
  4454. return m.AddedOrganizationID()
  4455. }
  4456. return nil, false
  4457. }
  4458. // AddField adds the value to the field with the given name. It returns an error if
  4459. // the field is not defined in the schema, or if the type mismatched the field
  4460. // type.
  4461. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  4462. switch name {
  4463. case batchmsg.FieldStatus:
  4464. v, ok := value.(int8)
  4465. if !ok {
  4466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4467. }
  4468. m.AddStatus(v)
  4469. return nil
  4470. case batchmsg.FieldTotal:
  4471. v, ok := value.(int32)
  4472. if !ok {
  4473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4474. }
  4475. m.AddTotal(v)
  4476. return nil
  4477. case batchmsg.FieldSuccess:
  4478. v, ok := value.(int32)
  4479. if !ok {
  4480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4481. }
  4482. m.AddSuccess(v)
  4483. return nil
  4484. case batchmsg.FieldFail:
  4485. v, ok := value.(int32)
  4486. if !ok {
  4487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4488. }
  4489. m.AddFail(v)
  4490. return nil
  4491. case batchmsg.FieldType:
  4492. v, ok := value.(int32)
  4493. if !ok {
  4494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4495. }
  4496. m.AddType(v)
  4497. return nil
  4498. case batchmsg.FieldOrganizationID:
  4499. v, ok := value.(int64)
  4500. if !ok {
  4501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4502. }
  4503. m.AddOrganizationID(v)
  4504. return nil
  4505. }
  4506. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  4507. }
  4508. // ClearedFields returns all nullable fields that were cleared during this
  4509. // mutation.
  4510. func (m *BatchMsgMutation) ClearedFields() []string {
  4511. var fields []string
  4512. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  4513. fields = append(fields, batchmsg.FieldDeletedAt)
  4514. }
  4515. if m.FieldCleared(batchmsg.FieldStatus) {
  4516. fields = append(fields, batchmsg.FieldStatus)
  4517. }
  4518. if m.FieldCleared(batchmsg.FieldBatchNo) {
  4519. fields = append(fields, batchmsg.FieldBatchNo)
  4520. }
  4521. if m.FieldCleared(batchmsg.FieldTaskName) {
  4522. fields = append(fields, batchmsg.FieldTaskName)
  4523. }
  4524. if m.FieldCleared(batchmsg.FieldFromwxid) {
  4525. fields = append(fields, batchmsg.FieldFromwxid)
  4526. }
  4527. if m.FieldCleared(batchmsg.FieldMsg) {
  4528. fields = append(fields, batchmsg.FieldMsg)
  4529. }
  4530. if m.FieldCleared(batchmsg.FieldTag) {
  4531. fields = append(fields, batchmsg.FieldTag)
  4532. }
  4533. if m.FieldCleared(batchmsg.FieldTagids) {
  4534. fields = append(fields, batchmsg.FieldTagids)
  4535. }
  4536. if m.FieldCleared(batchmsg.FieldTotal) {
  4537. fields = append(fields, batchmsg.FieldTotal)
  4538. }
  4539. if m.FieldCleared(batchmsg.FieldSuccess) {
  4540. fields = append(fields, batchmsg.FieldSuccess)
  4541. }
  4542. if m.FieldCleared(batchmsg.FieldFail) {
  4543. fields = append(fields, batchmsg.FieldFail)
  4544. }
  4545. if m.FieldCleared(batchmsg.FieldStartTime) {
  4546. fields = append(fields, batchmsg.FieldStartTime)
  4547. }
  4548. if m.FieldCleared(batchmsg.FieldStopTime) {
  4549. fields = append(fields, batchmsg.FieldStopTime)
  4550. }
  4551. if m.FieldCleared(batchmsg.FieldSendTime) {
  4552. fields = append(fields, batchmsg.FieldSendTime)
  4553. }
  4554. if m.FieldCleared(batchmsg.FieldType) {
  4555. fields = append(fields, batchmsg.FieldType)
  4556. }
  4557. return fields
  4558. }
  4559. // FieldCleared returns a boolean indicating if a field with the given name was
  4560. // cleared in this mutation.
  4561. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  4562. _, ok := m.clearedFields[name]
  4563. return ok
  4564. }
  4565. // ClearField clears the value of the field with the given name. It returns an
  4566. // error if the field is not defined in the schema.
  4567. func (m *BatchMsgMutation) ClearField(name string) error {
  4568. switch name {
  4569. case batchmsg.FieldDeletedAt:
  4570. m.ClearDeletedAt()
  4571. return nil
  4572. case batchmsg.FieldStatus:
  4573. m.ClearStatus()
  4574. return nil
  4575. case batchmsg.FieldBatchNo:
  4576. m.ClearBatchNo()
  4577. return nil
  4578. case batchmsg.FieldTaskName:
  4579. m.ClearTaskName()
  4580. return nil
  4581. case batchmsg.FieldFromwxid:
  4582. m.ClearFromwxid()
  4583. return nil
  4584. case batchmsg.FieldMsg:
  4585. m.ClearMsg()
  4586. return nil
  4587. case batchmsg.FieldTag:
  4588. m.ClearTag()
  4589. return nil
  4590. case batchmsg.FieldTagids:
  4591. m.ClearTagids()
  4592. return nil
  4593. case batchmsg.FieldTotal:
  4594. m.ClearTotal()
  4595. return nil
  4596. case batchmsg.FieldSuccess:
  4597. m.ClearSuccess()
  4598. return nil
  4599. case batchmsg.FieldFail:
  4600. m.ClearFail()
  4601. return nil
  4602. case batchmsg.FieldStartTime:
  4603. m.ClearStartTime()
  4604. return nil
  4605. case batchmsg.FieldStopTime:
  4606. m.ClearStopTime()
  4607. return nil
  4608. case batchmsg.FieldSendTime:
  4609. m.ClearSendTime()
  4610. return nil
  4611. case batchmsg.FieldType:
  4612. m.ClearType()
  4613. return nil
  4614. }
  4615. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  4616. }
  4617. // ResetField resets all changes in the mutation for the field with the given name.
  4618. // It returns an error if the field is not defined in the schema.
  4619. func (m *BatchMsgMutation) ResetField(name string) error {
  4620. switch name {
  4621. case batchmsg.FieldCreatedAt:
  4622. m.ResetCreatedAt()
  4623. return nil
  4624. case batchmsg.FieldUpdatedAt:
  4625. m.ResetUpdatedAt()
  4626. return nil
  4627. case batchmsg.FieldDeletedAt:
  4628. m.ResetDeletedAt()
  4629. return nil
  4630. case batchmsg.FieldStatus:
  4631. m.ResetStatus()
  4632. return nil
  4633. case batchmsg.FieldBatchNo:
  4634. m.ResetBatchNo()
  4635. return nil
  4636. case batchmsg.FieldTaskName:
  4637. m.ResetTaskName()
  4638. return nil
  4639. case batchmsg.FieldFromwxid:
  4640. m.ResetFromwxid()
  4641. return nil
  4642. case batchmsg.FieldMsg:
  4643. m.ResetMsg()
  4644. return nil
  4645. case batchmsg.FieldTag:
  4646. m.ResetTag()
  4647. return nil
  4648. case batchmsg.FieldTagids:
  4649. m.ResetTagids()
  4650. return nil
  4651. case batchmsg.FieldTotal:
  4652. m.ResetTotal()
  4653. return nil
  4654. case batchmsg.FieldSuccess:
  4655. m.ResetSuccess()
  4656. return nil
  4657. case batchmsg.FieldFail:
  4658. m.ResetFail()
  4659. return nil
  4660. case batchmsg.FieldStartTime:
  4661. m.ResetStartTime()
  4662. return nil
  4663. case batchmsg.FieldStopTime:
  4664. m.ResetStopTime()
  4665. return nil
  4666. case batchmsg.FieldSendTime:
  4667. m.ResetSendTime()
  4668. return nil
  4669. case batchmsg.FieldType:
  4670. m.ResetType()
  4671. return nil
  4672. case batchmsg.FieldOrganizationID:
  4673. m.ResetOrganizationID()
  4674. return nil
  4675. }
  4676. return fmt.Errorf("unknown BatchMsg field %s", name)
  4677. }
  4678. // AddedEdges returns all edge names that were set/added in this mutation.
  4679. func (m *BatchMsgMutation) AddedEdges() []string {
  4680. edges := make([]string, 0, 0)
  4681. return edges
  4682. }
  4683. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4684. // name in this mutation.
  4685. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  4686. return nil
  4687. }
  4688. // RemovedEdges returns all edge names that were removed in this mutation.
  4689. func (m *BatchMsgMutation) RemovedEdges() []string {
  4690. edges := make([]string, 0, 0)
  4691. return edges
  4692. }
  4693. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4694. // the given name in this mutation.
  4695. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  4696. return nil
  4697. }
  4698. // ClearedEdges returns all edge names that were cleared in this mutation.
  4699. func (m *BatchMsgMutation) ClearedEdges() []string {
  4700. edges := make([]string, 0, 0)
  4701. return edges
  4702. }
  4703. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4704. // was cleared in this mutation.
  4705. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  4706. return false
  4707. }
  4708. // ClearEdge clears the value of the edge with the given name. It returns an error
  4709. // if that edge is not defined in the schema.
  4710. func (m *BatchMsgMutation) ClearEdge(name string) error {
  4711. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  4712. }
  4713. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4714. // It returns an error if the edge is not defined in the schema.
  4715. func (m *BatchMsgMutation) ResetEdge(name string) error {
  4716. return fmt.Errorf("unknown BatchMsg edge %s", name)
  4717. }
  4718. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  4719. type CategoryMutation struct {
  4720. config
  4721. op Op
  4722. typ string
  4723. id *uint64
  4724. created_at *time.Time
  4725. updated_at *time.Time
  4726. deleted_at *time.Time
  4727. name *string
  4728. organization_id *uint64
  4729. addorganization_id *int64
  4730. clearedFields map[string]struct{}
  4731. done bool
  4732. oldValue func(context.Context) (*Category, error)
  4733. predicates []predicate.Category
  4734. }
  4735. var _ ent.Mutation = (*CategoryMutation)(nil)
  4736. // categoryOption allows management of the mutation configuration using functional options.
  4737. type categoryOption func(*CategoryMutation)
  4738. // newCategoryMutation creates new mutation for the Category entity.
  4739. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  4740. m := &CategoryMutation{
  4741. config: c,
  4742. op: op,
  4743. typ: TypeCategory,
  4744. clearedFields: make(map[string]struct{}),
  4745. }
  4746. for _, opt := range opts {
  4747. opt(m)
  4748. }
  4749. return m
  4750. }
  4751. // withCategoryID sets the ID field of the mutation.
  4752. func withCategoryID(id uint64) categoryOption {
  4753. return func(m *CategoryMutation) {
  4754. var (
  4755. err error
  4756. once sync.Once
  4757. value *Category
  4758. )
  4759. m.oldValue = func(ctx context.Context) (*Category, error) {
  4760. once.Do(func() {
  4761. if m.done {
  4762. err = errors.New("querying old values post mutation is not allowed")
  4763. } else {
  4764. value, err = m.Client().Category.Get(ctx, id)
  4765. }
  4766. })
  4767. return value, err
  4768. }
  4769. m.id = &id
  4770. }
  4771. }
  4772. // withCategory sets the old Category of the mutation.
  4773. func withCategory(node *Category) categoryOption {
  4774. return func(m *CategoryMutation) {
  4775. m.oldValue = func(context.Context) (*Category, error) {
  4776. return node, nil
  4777. }
  4778. m.id = &node.ID
  4779. }
  4780. }
  4781. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4782. // executed in a transaction (ent.Tx), a transactional client is returned.
  4783. func (m CategoryMutation) Client() *Client {
  4784. client := &Client{config: m.config}
  4785. client.init()
  4786. return client
  4787. }
  4788. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4789. // it returns an error otherwise.
  4790. func (m CategoryMutation) Tx() (*Tx, error) {
  4791. if _, ok := m.driver.(*txDriver); !ok {
  4792. return nil, errors.New("ent: mutation is not running in a transaction")
  4793. }
  4794. tx := &Tx{config: m.config}
  4795. tx.init()
  4796. return tx, nil
  4797. }
  4798. // SetID sets the value of the id field. Note that this
  4799. // operation is only accepted on creation of Category entities.
  4800. func (m *CategoryMutation) SetID(id uint64) {
  4801. m.id = &id
  4802. }
  4803. // ID returns the ID value in the mutation. Note that the ID is only available
  4804. // if it was provided to the builder or after it was returned from the database.
  4805. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  4806. if m.id == nil {
  4807. return
  4808. }
  4809. return *m.id, true
  4810. }
  4811. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4812. // That means, if the mutation is applied within a transaction with an isolation level such
  4813. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4814. // or updated by the mutation.
  4815. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  4816. switch {
  4817. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4818. id, exists := m.ID()
  4819. if exists {
  4820. return []uint64{id}, nil
  4821. }
  4822. fallthrough
  4823. case m.op.Is(OpUpdate | OpDelete):
  4824. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  4825. default:
  4826. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4827. }
  4828. }
  4829. // SetCreatedAt sets the "created_at" field.
  4830. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  4831. m.created_at = &t
  4832. }
  4833. // CreatedAt returns the value of the "created_at" field in the mutation.
  4834. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  4835. v := m.created_at
  4836. if v == nil {
  4837. return
  4838. }
  4839. return *v, true
  4840. }
  4841. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  4842. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4844. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4845. if !m.op.Is(OpUpdateOne) {
  4846. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4847. }
  4848. if m.id == nil || m.oldValue == nil {
  4849. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4850. }
  4851. oldValue, err := m.oldValue(ctx)
  4852. if err != nil {
  4853. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4854. }
  4855. return oldValue.CreatedAt, nil
  4856. }
  4857. // ResetCreatedAt resets all changes to the "created_at" field.
  4858. func (m *CategoryMutation) ResetCreatedAt() {
  4859. m.created_at = nil
  4860. }
  4861. // SetUpdatedAt sets the "updated_at" field.
  4862. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  4863. m.updated_at = &t
  4864. }
  4865. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4866. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  4867. v := m.updated_at
  4868. if v == nil {
  4869. return
  4870. }
  4871. return *v, true
  4872. }
  4873. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  4874. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4876. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4877. if !m.op.Is(OpUpdateOne) {
  4878. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4879. }
  4880. if m.id == nil || m.oldValue == nil {
  4881. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4882. }
  4883. oldValue, err := m.oldValue(ctx)
  4884. if err != nil {
  4885. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4886. }
  4887. return oldValue.UpdatedAt, nil
  4888. }
  4889. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4890. func (m *CategoryMutation) ResetUpdatedAt() {
  4891. m.updated_at = nil
  4892. }
  4893. // SetDeletedAt sets the "deleted_at" field.
  4894. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  4895. m.deleted_at = &t
  4896. }
  4897. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4898. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  4899. v := m.deleted_at
  4900. if v == nil {
  4901. return
  4902. }
  4903. return *v, true
  4904. }
  4905. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  4906. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4908. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4909. if !m.op.Is(OpUpdateOne) {
  4910. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4911. }
  4912. if m.id == nil || m.oldValue == nil {
  4913. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4914. }
  4915. oldValue, err := m.oldValue(ctx)
  4916. if err != nil {
  4917. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4918. }
  4919. return oldValue.DeletedAt, nil
  4920. }
  4921. // ClearDeletedAt clears the value of the "deleted_at" field.
  4922. func (m *CategoryMutation) ClearDeletedAt() {
  4923. m.deleted_at = nil
  4924. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  4925. }
  4926. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4927. func (m *CategoryMutation) DeletedAtCleared() bool {
  4928. _, ok := m.clearedFields[category.FieldDeletedAt]
  4929. return ok
  4930. }
  4931. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4932. func (m *CategoryMutation) ResetDeletedAt() {
  4933. m.deleted_at = nil
  4934. delete(m.clearedFields, category.FieldDeletedAt)
  4935. }
  4936. // SetName sets the "name" field.
  4937. func (m *CategoryMutation) SetName(s string) {
  4938. m.name = &s
  4939. }
  4940. // Name returns the value of the "name" field in the mutation.
  4941. func (m *CategoryMutation) Name() (r string, exists bool) {
  4942. v := m.name
  4943. if v == nil {
  4944. return
  4945. }
  4946. return *v, true
  4947. }
  4948. // OldName returns the old "name" field's value of the Category entity.
  4949. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4951. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  4952. if !m.op.Is(OpUpdateOne) {
  4953. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4954. }
  4955. if m.id == nil || m.oldValue == nil {
  4956. return v, errors.New("OldName requires an ID field in the mutation")
  4957. }
  4958. oldValue, err := m.oldValue(ctx)
  4959. if err != nil {
  4960. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4961. }
  4962. return oldValue.Name, nil
  4963. }
  4964. // ResetName resets all changes to the "name" field.
  4965. func (m *CategoryMutation) ResetName() {
  4966. m.name = nil
  4967. }
  4968. // SetOrganizationID sets the "organization_id" field.
  4969. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  4970. m.organization_id = &u
  4971. m.addorganization_id = nil
  4972. }
  4973. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4974. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  4975. v := m.organization_id
  4976. if v == nil {
  4977. return
  4978. }
  4979. return *v, true
  4980. }
  4981. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  4982. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4984. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4985. if !m.op.Is(OpUpdateOne) {
  4986. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4987. }
  4988. if m.id == nil || m.oldValue == nil {
  4989. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4990. }
  4991. oldValue, err := m.oldValue(ctx)
  4992. if err != nil {
  4993. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4994. }
  4995. return oldValue.OrganizationID, nil
  4996. }
  4997. // AddOrganizationID adds u to the "organization_id" field.
  4998. func (m *CategoryMutation) AddOrganizationID(u int64) {
  4999. if m.addorganization_id != nil {
  5000. *m.addorganization_id += u
  5001. } else {
  5002. m.addorganization_id = &u
  5003. }
  5004. }
  5005. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5006. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5007. v := m.addorganization_id
  5008. if v == nil {
  5009. return
  5010. }
  5011. return *v, true
  5012. }
  5013. // ResetOrganizationID resets all changes to the "organization_id" field.
  5014. func (m *CategoryMutation) ResetOrganizationID() {
  5015. m.organization_id = nil
  5016. m.addorganization_id = nil
  5017. }
  5018. // Where appends a list predicates to the CategoryMutation builder.
  5019. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5020. m.predicates = append(m.predicates, ps...)
  5021. }
  5022. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5023. // users can use type-assertion to append predicates that do not depend on any generated package.
  5024. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5025. p := make([]predicate.Category, len(ps))
  5026. for i := range ps {
  5027. p[i] = ps[i]
  5028. }
  5029. m.Where(p...)
  5030. }
  5031. // Op returns the operation name.
  5032. func (m *CategoryMutation) Op() Op {
  5033. return m.op
  5034. }
  5035. // SetOp allows setting the mutation operation.
  5036. func (m *CategoryMutation) SetOp(op Op) {
  5037. m.op = op
  5038. }
  5039. // Type returns the node type of this mutation (Category).
  5040. func (m *CategoryMutation) Type() string {
  5041. return m.typ
  5042. }
  5043. // Fields returns all fields that were changed during this mutation. Note that in
  5044. // order to get all numeric fields that were incremented/decremented, call
  5045. // AddedFields().
  5046. func (m *CategoryMutation) Fields() []string {
  5047. fields := make([]string, 0, 5)
  5048. if m.created_at != nil {
  5049. fields = append(fields, category.FieldCreatedAt)
  5050. }
  5051. if m.updated_at != nil {
  5052. fields = append(fields, category.FieldUpdatedAt)
  5053. }
  5054. if m.deleted_at != nil {
  5055. fields = append(fields, category.FieldDeletedAt)
  5056. }
  5057. if m.name != nil {
  5058. fields = append(fields, category.FieldName)
  5059. }
  5060. if m.organization_id != nil {
  5061. fields = append(fields, category.FieldOrganizationID)
  5062. }
  5063. return fields
  5064. }
  5065. // Field returns the value of a field with the given name. The second boolean
  5066. // return value indicates that this field was not set, or was not defined in the
  5067. // schema.
  5068. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5069. switch name {
  5070. case category.FieldCreatedAt:
  5071. return m.CreatedAt()
  5072. case category.FieldUpdatedAt:
  5073. return m.UpdatedAt()
  5074. case category.FieldDeletedAt:
  5075. return m.DeletedAt()
  5076. case category.FieldName:
  5077. return m.Name()
  5078. case category.FieldOrganizationID:
  5079. return m.OrganizationID()
  5080. }
  5081. return nil, false
  5082. }
  5083. // OldField returns the old value of the field from the database. An error is
  5084. // returned if the mutation operation is not UpdateOne, or the query to the
  5085. // database failed.
  5086. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5087. switch name {
  5088. case category.FieldCreatedAt:
  5089. return m.OldCreatedAt(ctx)
  5090. case category.FieldUpdatedAt:
  5091. return m.OldUpdatedAt(ctx)
  5092. case category.FieldDeletedAt:
  5093. return m.OldDeletedAt(ctx)
  5094. case category.FieldName:
  5095. return m.OldName(ctx)
  5096. case category.FieldOrganizationID:
  5097. return m.OldOrganizationID(ctx)
  5098. }
  5099. return nil, fmt.Errorf("unknown Category field %s", name)
  5100. }
  5101. // SetField sets the value of a field with the given name. It returns an error if
  5102. // the field is not defined in the schema, or if the type mismatched the field
  5103. // type.
  5104. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5105. switch name {
  5106. case category.FieldCreatedAt:
  5107. v, ok := value.(time.Time)
  5108. if !ok {
  5109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5110. }
  5111. m.SetCreatedAt(v)
  5112. return nil
  5113. case category.FieldUpdatedAt:
  5114. v, ok := value.(time.Time)
  5115. if !ok {
  5116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5117. }
  5118. m.SetUpdatedAt(v)
  5119. return nil
  5120. case category.FieldDeletedAt:
  5121. v, ok := value.(time.Time)
  5122. if !ok {
  5123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5124. }
  5125. m.SetDeletedAt(v)
  5126. return nil
  5127. case category.FieldName:
  5128. v, ok := value.(string)
  5129. if !ok {
  5130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5131. }
  5132. m.SetName(v)
  5133. return nil
  5134. case category.FieldOrganizationID:
  5135. v, ok := value.(uint64)
  5136. if !ok {
  5137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5138. }
  5139. m.SetOrganizationID(v)
  5140. return nil
  5141. }
  5142. return fmt.Errorf("unknown Category field %s", name)
  5143. }
  5144. // AddedFields returns all numeric fields that were incremented/decremented during
  5145. // this mutation.
  5146. func (m *CategoryMutation) AddedFields() []string {
  5147. var fields []string
  5148. if m.addorganization_id != nil {
  5149. fields = append(fields, category.FieldOrganizationID)
  5150. }
  5151. return fields
  5152. }
  5153. // AddedField returns the numeric value that was incremented/decremented on a field
  5154. // with the given name. The second boolean return value indicates that this field
  5155. // was not set, or was not defined in the schema.
  5156. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5157. switch name {
  5158. case category.FieldOrganizationID:
  5159. return m.AddedOrganizationID()
  5160. }
  5161. return nil, false
  5162. }
  5163. // AddField adds the value to the field with the given name. It returns an error if
  5164. // the field is not defined in the schema, or if the type mismatched the field
  5165. // type.
  5166. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5167. switch name {
  5168. case category.FieldOrganizationID:
  5169. v, ok := value.(int64)
  5170. if !ok {
  5171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5172. }
  5173. m.AddOrganizationID(v)
  5174. return nil
  5175. }
  5176. return fmt.Errorf("unknown Category numeric field %s", name)
  5177. }
  5178. // ClearedFields returns all nullable fields that were cleared during this
  5179. // mutation.
  5180. func (m *CategoryMutation) ClearedFields() []string {
  5181. var fields []string
  5182. if m.FieldCleared(category.FieldDeletedAt) {
  5183. fields = append(fields, category.FieldDeletedAt)
  5184. }
  5185. return fields
  5186. }
  5187. // FieldCleared returns a boolean indicating if a field with the given name was
  5188. // cleared in this mutation.
  5189. func (m *CategoryMutation) FieldCleared(name string) bool {
  5190. _, ok := m.clearedFields[name]
  5191. return ok
  5192. }
  5193. // ClearField clears the value of the field with the given name. It returns an
  5194. // error if the field is not defined in the schema.
  5195. func (m *CategoryMutation) ClearField(name string) error {
  5196. switch name {
  5197. case category.FieldDeletedAt:
  5198. m.ClearDeletedAt()
  5199. return nil
  5200. }
  5201. return fmt.Errorf("unknown Category nullable field %s", name)
  5202. }
  5203. // ResetField resets all changes in the mutation for the field with the given name.
  5204. // It returns an error if the field is not defined in the schema.
  5205. func (m *CategoryMutation) ResetField(name string) error {
  5206. switch name {
  5207. case category.FieldCreatedAt:
  5208. m.ResetCreatedAt()
  5209. return nil
  5210. case category.FieldUpdatedAt:
  5211. m.ResetUpdatedAt()
  5212. return nil
  5213. case category.FieldDeletedAt:
  5214. m.ResetDeletedAt()
  5215. return nil
  5216. case category.FieldName:
  5217. m.ResetName()
  5218. return nil
  5219. case category.FieldOrganizationID:
  5220. m.ResetOrganizationID()
  5221. return nil
  5222. }
  5223. return fmt.Errorf("unknown Category field %s", name)
  5224. }
  5225. // AddedEdges returns all edge names that were set/added in this mutation.
  5226. func (m *CategoryMutation) AddedEdges() []string {
  5227. edges := make([]string, 0, 0)
  5228. return edges
  5229. }
  5230. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5231. // name in this mutation.
  5232. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5233. return nil
  5234. }
  5235. // RemovedEdges returns all edge names that were removed in this mutation.
  5236. func (m *CategoryMutation) RemovedEdges() []string {
  5237. edges := make([]string, 0, 0)
  5238. return edges
  5239. }
  5240. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5241. // the given name in this mutation.
  5242. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5243. return nil
  5244. }
  5245. // ClearedEdges returns all edge names that were cleared in this mutation.
  5246. func (m *CategoryMutation) ClearedEdges() []string {
  5247. edges := make([]string, 0, 0)
  5248. return edges
  5249. }
  5250. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5251. // was cleared in this mutation.
  5252. func (m *CategoryMutation) EdgeCleared(name string) bool {
  5253. return false
  5254. }
  5255. // ClearEdge clears the value of the edge with the given name. It returns an error
  5256. // if that edge is not defined in the schema.
  5257. func (m *CategoryMutation) ClearEdge(name string) error {
  5258. return fmt.Errorf("unknown Category unique edge %s", name)
  5259. }
  5260. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5261. // It returns an error if the edge is not defined in the schema.
  5262. func (m *CategoryMutation) ResetEdge(name string) error {
  5263. return fmt.Errorf("unknown Category edge %s", name)
  5264. }
  5265. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  5266. type ChatRecordsMutation struct {
  5267. config
  5268. op Op
  5269. typ string
  5270. id *uint64
  5271. created_at *time.Time
  5272. updated_at *time.Time
  5273. deleted_at *time.Time
  5274. content *string
  5275. content_type *uint8
  5276. addcontent_type *int8
  5277. session_id *uint64
  5278. addsession_id *int64
  5279. user_id *uint64
  5280. adduser_id *int64
  5281. bot_id *uint64
  5282. addbot_id *int64
  5283. bot_type *uint8
  5284. addbot_type *int8
  5285. clearedFields map[string]struct{}
  5286. done bool
  5287. oldValue func(context.Context) (*ChatRecords, error)
  5288. predicates []predicate.ChatRecords
  5289. }
  5290. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  5291. // chatrecordsOption allows management of the mutation configuration using functional options.
  5292. type chatrecordsOption func(*ChatRecordsMutation)
  5293. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  5294. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  5295. m := &ChatRecordsMutation{
  5296. config: c,
  5297. op: op,
  5298. typ: TypeChatRecords,
  5299. clearedFields: make(map[string]struct{}),
  5300. }
  5301. for _, opt := range opts {
  5302. opt(m)
  5303. }
  5304. return m
  5305. }
  5306. // withChatRecordsID sets the ID field of the mutation.
  5307. func withChatRecordsID(id uint64) chatrecordsOption {
  5308. return func(m *ChatRecordsMutation) {
  5309. var (
  5310. err error
  5311. once sync.Once
  5312. value *ChatRecords
  5313. )
  5314. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  5315. once.Do(func() {
  5316. if m.done {
  5317. err = errors.New("querying old values post mutation is not allowed")
  5318. } else {
  5319. value, err = m.Client().ChatRecords.Get(ctx, id)
  5320. }
  5321. })
  5322. return value, err
  5323. }
  5324. m.id = &id
  5325. }
  5326. }
  5327. // withChatRecords sets the old ChatRecords of the mutation.
  5328. func withChatRecords(node *ChatRecords) chatrecordsOption {
  5329. return func(m *ChatRecordsMutation) {
  5330. m.oldValue = func(context.Context) (*ChatRecords, error) {
  5331. return node, nil
  5332. }
  5333. m.id = &node.ID
  5334. }
  5335. }
  5336. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5337. // executed in a transaction (ent.Tx), a transactional client is returned.
  5338. func (m ChatRecordsMutation) Client() *Client {
  5339. client := &Client{config: m.config}
  5340. client.init()
  5341. return client
  5342. }
  5343. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5344. // it returns an error otherwise.
  5345. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  5346. if _, ok := m.driver.(*txDriver); !ok {
  5347. return nil, errors.New("ent: mutation is not running in a transaction")
  5348. }
  5349. tx := &Tx{config: m.config}
  5350. tx.init()
  5351. return tx, nil
  5352. }
  5353. // SetID sets the value of the id field. Note that this
  5354. // operation is only accepted on creation of ChatRecords entities.
  5355. func (m *ChatRecordsMutation) SetID(id uint64) {
  5356. m.id = &id
  5357. }
  5358. // ID returns the ID value in the mutation. Note that the ID is only available
  5359. // if it was provided to the builder or after it was returned from the database.
  5360. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  5361. if m.id == nil {
  5362. return
  5363. }
  5364. return *m.id, true
  5365. }
  5366. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5367. // That means, if the mutation is applied within a transaction with an isolation level such
  5368. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5369. // or updated by the mutation.
  5370. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5371. switch {
  5372. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5373. id, exists := m.ID()
  5374. if exists {
  5375. return []uint64{id}, nil
  5376. }
  5377. fallthrough
  5378. case m.op.Is(OpUpdate | OpDelete):
  5379. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  5380. default:
  5381. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5382. }
  5383. }
  5384. // SetCreatedAt sets the "created_at" field.
  5385. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  5386. m.created_at = &t
  5387. }
  5388. // CreatedAt returns the value of the "created_at" field in the mutation.
  5389. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5390. v := m.created_at
  5391. if v == nil {
  5392. return
  5393. }
  5394. return *v, true
  5395. }
  5396. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  5397. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5399. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5400. if !m.op.Is(OpUpdateOne) {
  5401. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5402. }
  5403. if m.id == nil || m.oldValue == nil {
  5404. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5405. }
  5406. oldValue, err := m.oldValue(ctx)
  5407. if err != nil {
  5408. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5409. }
  5410. return oldValue.CreatedAt, nil
  5411. }
  5412. // ResetCreatedAt resets all changes to the "created_at" field.
  5413. func (m *ChatRecordsMutation) ResetCreatedAt() {
  5414. m.created_at = nil
  5415. }
  5416. // SetUpdatedAt sets the "updated_at" field.
  5417. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  5418. m.updated_at = &t
  5419. }
  5420. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5421. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5422. v := m.updated_at
  5423. if v == nil {
  5424. return
  5425. }
  5426. return *v, true
  5427. }
  5428. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  5429. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5431. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5432. if !m.op.Is(OpUpdateOne) {
  5433. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5434. }
  5435. if m.id == nil || m.oldValue == nil {
  5436. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5437. }
  5438. oldValue, err := m.oldValue(ctx)
  5439. if err != nil {
  5440. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5441. }
  5442. return oldValue.UpdatedAt, nil
  5443. }
  5444. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5445. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  5446. m.updated_at = nil
  5447. }
  5448. // SetDeletedAt sets the "deleted_at" field.
  5449. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  5450. m.deleted_at = &t
  5451. }
  5452. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5453. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5454. v := m.deleted_at
  5455. if v == nil {
  5456. return
  5457. }
  5458. return *v, true
  5459. }
  5460. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  5461. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5463. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5464. if !m.op.Is(OpUpdateOne) {
  5465. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5466. }
  5467. if m.id == nil || m.oldValue == nil {
  5468. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5469. }
  5470. oldValue, err := m.oldValue(ctx)
  5471. if err != nil {
  5472. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5473. }
  5474. return oldValue.DeletedAt, nil
  5475. }
  5476. // ClearDeletedAt clears the value of the "deleted_at" field.
  5477. func (m *ChatRecordsMutation) ClearDeletedAt() {
  5478. m.deleted_at = nil
  5479. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  5480. }
  5481. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5482. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  5483. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  5484. return ok
  5485. }
  5486. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5487. func (m *ChatRecordsMutation) ResetDeletedAt() {
  5488. m.deleted_at = nil
  5489. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  5490. }
  5491. // SetContent sets the "content" field.
  5492. func (m *ChatRecordsMutation) SetContent(s string) {
  5493. m.content = &s
  5494. }
  5495. // Content returns the value of the "content" field in the mutation.
  5496. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  5497. v := m.content
  5498. if v == nil {
  5499. return
  5500. }
  5501. return *v, true
  5502. }
  5503. // OldContent returns the old "content" field's value of the ChatRecords entity.
  5504. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5506. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5507. if !m.op.Is(OpUpdateOne) {
  5508. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5509. }
  5510. if m.id == nil || m.oldValue == nil {
  5511. return v, errors.New("OldContent requires an ID field in the mutation")
  5512. }
  5513. oldValue, err := m.oldValue(ctx)
  5514. if err != nil {
  5515. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5516. }
  5517. return oldValue.Content, nil
  5518. }
  5519. // ResetContent resets all changes to the "content" field.
  5520. func (m *ChatRecordsMutation) ResetContent() {
  5521. m.content = nil
  5522. }
  5523. // SetContentType sets the "content_type" field.
  5524. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  5525. m.content_type = &u
  5526. m.addcontent_type = nil
  5527. }
  5528. // ContentType returns the value of the "content_type" field in the mutation.
  5529. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  5530. v := m.content_type
  5531. if v == nil {
  5532. return
  5533. }
  5534. return *v, true
  5535. }
  5536. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  5537. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5539. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  5540. if !m.op.Is(OpUpdateOne) {
  5541. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5542. }
  5543. if m.id == nil || m.oldValue == nil {
  5544. return v, errors.New("OldContentType requires an ID field in the mutation")
  5545. }
  5546. oldValue, err := m.oldValue(ctx)
  5547. if err != nil {
  5548. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5549. }
  5550. return oldValue.ContentType, nil
  5551. }
  5552. // AddContentType adds u to the "content_type" field.
  5553. func (m *ChatRecordsMutation) AddContentType(u int8) {
  5554. if m.addcontent_type != nil {
  5555. *m.addcontent_type += u
  5556. } else {
  5557. m.addcontent_type = &u
  5558. }
  5559. }
  5560. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5561. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  5562. v := m.addcontent_type
  5563. if v == nil {
  5564. return
  5565. }
  5566. return *v, true
  5567. }
  5568. // ResetContentType resets all changes to the "content_type" field.
  5569. func (m *ChatRecordsMutation) ResetContentType() {
  5570. m.content_type = nil
  5571. m.addcontent_type = nil
  5572. }
  5573. // SetSessionID sets the "session_id" field.
  5574. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  5575. m.session_id = &u
  5576. m.addsession_id = nil
  5577. }
  5578. // SessionID returns the value of the "session_id" field in the mutation.
  5579. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  5580. v := m.session_id
  5581. if v == nil {
  5582. return
  5583. }
  5584. return *v, true
  5585. }
  5586. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  5587. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5589. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  5590. if !m.op.Is(OpUpdateOne) {
  5591. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  5592. }
  5593. if m.id == nil || m.oldValue == nil {
  5594. return v, errors.New("OldSessionID requires an ID field in the mutation")
  5595. }
  5596. oldValue, err := m.oldValue(ctx)
  5597. if err != nil {
  5598. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  5599. }
  5600. return oldValue.SessionID, nil
  5601. }
  5602. // AddSessionID adds u to the "session_id" field.
  5603. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  5604. if m.addsession_id != nil {
  5605. *m.addsession_id += u
  5606. } else {
  5607. m.addsession_id = &u
  5608. }
  5609. }
  5610. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  5611. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  5612. v := m.addsession_id
  5613. if v == nil {
  5614. return
  5615. }
  5616. return *v, true
  5617. }
  5618. // ResetSessionID resets all changes to the "session_id" field.
  5619. func (m *ChatRecordsMutation) ResetSessionID() {
  5620. m.session_id = nil
  5621. m.addsession_id = nil
  5622. }
  5623. // SetUserID sets the "user_id" field.
  5624. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  5625. m.user_id = &u
  5626. m.adduser_id = nil
  5627. }
  5628. // UserID returns the value of the "user_id" field in the mutation.
  5629. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  5630. v := m.user_id
  5631. if v == nil {
  5632. return
  5633. }
  5634. return *v, true
  5635. }
  5636. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  5637. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5639. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5640. if !m.op.Is(OpUpdateOne) {
  5641. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5642. }
  5643. if m.id == nil || m.oldValue == nil {
  5644. return v, errors.New("OldUserID requires an ID field in the mutation")
  5645. }
  5646. oldValue, err := m.oldValue(ctx)
  5647. if err != nil {
  5648. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5649. }
  5650. return oldValue.UserID, nil
  5651. }
  5652. // AddUserID adds u to the "user_id" field.
  5653. func (m *ChatRecordsMutation) AddUserID(u int64) {
  5654. if m.adduser_id != nil {
  5655. *m.adduser_id += u
  5656. } else {
  5657. m.adduser_id = &u
  5658. }
  5659. }
  5660. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5661. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  5662. v := m.adduser_id
  5663. if v == nil {
  5664. return
  5665. }
  5666. return *v, true
  5667. }
  5668. // ResetUserID resets all changes to the "user_id" field.
  5669. func (m *ChatRecordsMutation) ResetUserID() {
  5670. m.user_id = nil
  5671. m.adduser_id = nil
  5672. }
  5673. // SetBotID sets the "bot_id" field.
  5674. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  5675. m.bot_id = &u
  5676. m.addbot_id = nil
  5677. }
  5678. // BotID returns the value of the "bot_id" field in the mutation.
  5679. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  5680. v := m.bot_id
  5681. if v == nil {
  5682. return
  5683. }
  5684. return *v, true
  5685. }
  5686. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  5687. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5689. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5690. if !m.op.Is(OpUpdateOne) {
  5691. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5692. }
  5693. if m.id == nil || m.oldValue == nil {
  5694. return v, errors.New("OldBotID requires an ID field in the mutation")
  5695. }
  5696. oldValue, err := m.oldValue(ctx)
  5697. if err != nil {
  5698. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5699. }
  5700. return oldValue.BotID, nil
  5701. }
  5702. // AddBotID adds u to the "bot_id" field.
  5703. func (m *ChatRecordsMutation) AddBotID(u int64) {
  5704. if m.addbot_id != nil {
  5705. *m.addbot_id += u
  5706. } else {
  5707. m.addbot_id = &u
  5708. }
  5709. }
  5710. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5711. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  5712. v := m.addbot_id
  5713. if v == nil {
  5714. return
  5715. }
  5716. return *v, true
  5717. }
  5718. // ResetBotID resets all changes to the "bot_id" field.
  5719. func (m *ChatRecordsMutation) ResetBotID() {
  5720. m.bot_id = nil
  5721. m.addbot_id = nil
  5722. }
  5723. // SetBotType sets the "bot_type" field.
  5724. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  5725. m.bot_type = &u
  5726. m.addbot_type = nil
  5727. }
  5728. // BotType returns the value of the "bot_type" field in the mutation.
  5729. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  5730. v := m.bot_type
  5731. if v == nil {
  5732. return
  5733. }
  5734. return *v, true
  5735. }
  5736. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  5737. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5739. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5740. if !m.op.Is(OpUpdateOne) {
  5741. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5742. }
  5743. if m.id == nil || m.oldValue == nil {
  5744. return v, errors.New("OldBotType requires an ID field in the mutation")
  5745. }
  5746. oldValue, err := m.oldValue(ctx)
  5747. if err != nil {
  5748. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  5749. }
  5750. return oldValue.BotType, nil
  5751. }
  5752. // AddBotType adds u to the "bot_type" field.
  5753. func (m *ChatRecordsMutation) AddBotType(u int8) {
  5754. if m.addbot_type != nil {
  5755. *m.addbot_type += u
  5756. } else {
  5757. m.addbot_type = &u
  5758. }
  5759. }
  5760. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5761. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  5762. v := m.addbot_type
  5763. if v == nil {
  5764. return
  5765. }
  5766. return *v, true
  5767. }
  5768. // ResetBotType resets all changes to the "bot_type" field.
  5769. func (m *ChatRecordsMutation) ResetBotType() {
  5770. m.bot_type = nil
  5771. m.addbot_type = nil
  5772. }
  5773. // Where appends a list predicates to the ChatRecordsMutation builder.
  5774. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  5775. m.predicates = append(m.predicates, ps...)
  5776. }
  5777. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  5778. // users can use type-assertion to append predicates that do not depend on any generated package.
  5779. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5780. p := make([]predicate.ChatRecords, len(ps))
  5781. for i := range ps {
  5782. p[i] = ps[i]
  5783. }
  5784. m.Where(p...)
  5785. }
  5786. // Op returns the operation name.
  5787. func (m *ChatRecordsMutation) Op() Op {
  5788. return m.op
  5789. }
  5790. // SetOp allows setting the mutation operation.
  5791. func (m *ChatRecordsMutation) SetOp(op Op) {
  5792. m.op = op
  5793. }
  5794. // Type returns the node type of this mutation (ChatRecords).
  5795. func (m *ChatRecordsMutation) Type() string {
  5796. return m.typ
  5797. }
  5798. // Fields returns all fields that were changed during this mutation. Note that in
  5799. // order to get all numeric fields that were incremented/decremented, call
  5800. // AddedFields().
  5801. func (m *ChatRecordsMutation) Fields() []string {
  5802. fields := make([]string, 0, 9)
  5803. if m.created_at != nil {
  5804. fields = append(fields, chatrecords.FieldCreatedAt)
  5805. }
  5806. if m.updated_at != nil {
  5807. fields = append(fields, chatrecords.FieldUpdatedAt)
  5808. }
  5809. if m.deleted_at != nil {
  5810. fields = append(fields, chatrecords.FieldDeletedAt)
  5811. }
  5812. if m.content != nil {
  5813. fields = append(fields, chatrecords.FieldContent)
  5814. }
  5815. if m.content_type != nil {
  5816. fields = append(fields, chatrecords.FieldContentType)
  5817. }
  5818. if m.session_id != nil {
  5819. fields = append(fields, chatrecords.FieldSessionID)
  5820. }
  5821. if m.user_id != nil {
  5822. fields = append(fields, chatrecords.FieldUserID)
  5823. }
  5824. if m.bot_id != nil {
  5825. fields = append(fields, chatrecords.FieldBotID)
  5826. }
  5827. if m.bot_type != nil {
  5828. fields = append(fields, chatrecords.FieldBotType)
  5829. }
  5830. return fields
  5831. }
  5832. // Field returns the value of a field with the given name. The second boolean
  5833. // return value indicates that this field was not set, or was not defined in the
  5834. // schema.
  5835. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  5836. switch name {
  5837. case chatrecords.FieldCreatedAt:
  5838. return m.CreatedAt()
  5839. case chatrecords.FieldUpdatedAt:
  5840. return m.UpdatedAt()
  5841. case chatrecords.FieldDeletedAt:
  5842. return m.DeletedAt()
  5843. case chatrecords.FieldContent:
  5844. return m.Content()
  5845. case chatrecords.FieldContentType:
  5846. return m.ContentType()
  5847. case chatrecords.FieldSessionID:
  5848. return m.SessionID()
  5849. case chatrecords.FieldUserID:
  5850. return m.UserID()
  5851. case chatrecords.FieldBotID:
  5852. return m.BotID()
  5853. case chatrecords.FieldBotType:
  5854. return m.BotType()
  5855. }
  5856. return nil, false
  5857. }
  5858. // OldField returns the old value of the field from the database. An error is
  5859. // returned if the mutation operation is not UpdateOne, or the query to the
  5860. // database failed.
  5861. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5862. switch name {
  5863. case chatrecords.FieldCreatedAt:
  5864. return m.OldCreatedAt(ctx)
  5865. case chatrecords.FieldUpdatedAt:
  5866. return m.OldUpdatedAt(ctx)
  5867. case chatrecords.FieldDeletedAt:
  5868. return m.OldDeletedAt(ctx)
  5869. case chatrecords.FieldContent:
  5870. return m.OldContent(ctx)
  5871. case chatrecords.FieldContentType:
  5872. return m.OldContentType(ctx)
  5873. case chatrecords.FieldSessionID:
  5874. return m.OldSessionID(ctx)
  5875. case chatrecords.FieldUserID:
  5876. return m.OldUserID(ctx)
  5877. case chatrecords.FieldBotID:
  5878. return m.OldBotID(ctx)
  5879. case chatrecords.FieldBotType:
  5880. return m.OldBotType(ctx)
  5881. }
  5882. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  5883. }
  5884. // SetField sets the value of a field with the given name. It returns an error if
  5885. // the field is not defined in the schema, or if the type mismatched the field
  5886. // type.
  5887. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  5888. switch name {
  5889. case chatrecords.FieldCreatedAt:
  5890. v, ok := value.(time.Time)
  5891. if !ok {
  5892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5893. }
  5894. m.SetCreatedAt(v)
  5895. return nil
  5896. case chatrecords.FieldUpdatedAt:
  5897. v, ok := value.(time.Time)
  5898. if !ok {
  5899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5900. }
  5901. m.SetUpdatedAt(v)
  5902. return nil
  5903. case chatrecords.FieldDeletedAt:
  5904. v, ok := value.(time.Time)
  5905. if !ok {
  5906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5907. }
  5908. m.SetDeletedAt(v)
  5909. return nil
  5910. case chatrecords.FieldContent:
  5911. v, ok := value.(string)
  5912. if !ok {
  5913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5914. }
  5915. m.SetContent(v)
  5916. return nil
  5917. case chatrecords.FieldContentType:
  5918. v, ok := value.(uint8)
  5919. if !ok {
  5920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5921. }
  5922. m.SetContentType(v)
  5923. return nil
  5924. case chatrecords.FieldSessionID:
  5925. v, ok := value.(uint64)
  5926. if !ok {
  5927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5928. }
  5929. m.SetSessionID(v)
  5930. return nil
  5931. case chatrecords.FieldUserID:
  5932. v, ok := value.(uint64)
  5933. if !ok {
  5934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5935. }
  5936. m.SetUserID(v)
  5937. return nil
  5938. case chatrecords.FieldBotID:
  5939. v, ok := value.(uint64)
  5940. if !ok {
  5941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5942. }
  5943. m.SetBotID(v)
  5944. return nil
  5945. case chatrecords.FieldBotType:
  5946. v, ok := value.(uint8)
  5947. if !ok {
  5948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5949. }
  5950. m.SetBotType(v)
  5951. return nil
  5952. }
  5953. return fmt.Errorf("unknown ChatRecords field %s", name)
  5954. }
  5955. // AddedFields returns all numeric fields that were incremented/decremented during
  5956. // this mutation.
  5957. func (m *ChatRecordsMutation) AddedFields() []string {
  5958. var fields []string
  5959. if m.addcontent_type != nil {
  5960. fields = append(fields, chatrecords.FieldContentType)
  5961. }
  5962. if m.addsession_id != nil {
  5963. fields = append(fields, chatrecords.FieldSessionID)
  5964. }
  5965. if m.adduser_id != nil {
  5966. fields = append(fields, chatrecords.FieldUserID)
  5967. }
  5968. if m.addbot_id != nil {
  5969. fields = append(fields, chatrecords.FieldBotID)
  5970. }
  5971. if m.addbot_type != nil {
  5972. fields = append(fields, chatrecords.FieldBotType)
  5973. }
  5974. return fields
  5975. }
  5976. // AddedField returns the numeric value that was incremented/decremented on a field
  5977. // with the given name. The second boolean return value indicates that this field
  5978. // was not set, or was not defined in the schema.
  5979. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  5980. switch name {
  5981. case chatrecords.FieldContentType:
  5982. return m.AddedContentType()
  5983. case chatrecords.FieldSessionID:
  5984. return m.AddedSessionID()
  5985. case chatrecords.FieldUserID:
  5986. return m.AddedUserID()
  5987. case chatrecords.FieldBotID:
  5988. return m.AddedBotID()
  5989. case chatrecords.FieldBotType:
  5990. return m.AddedBotType()
  5991. }
  5992. return nil, false
  5993. }
  5994. // AddField adds the value to the field with the given name. It returns an error if
  5995. // the field is not defined in the schema, or if the type mismatched the field
  5996. // type.
  5997. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  5998. switch name {
  5999. case chatrecords.FieldContentType:
  6000. v, ok := value.(int8)
  6001. if !ok {
  6002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6003. }
  6004. m.AddContentType(v)
  6005. return nil
  6006. case chatrecords.FieldSessionID:
  6007. v, ok := value.(int64)
  6008. if !ok {
  6009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6010. }
  6011. m.AddSessionID(v)
  6012. return nil
  6013. case chatrecords.FieldUserID:
  6014. v, ok := value.(int64)
  6015. if !ok {
  6016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6017. }
  6018. m.AddUserID(v)
  6019. return nil
  6020. case chatrecords.FieldBotID:
  6021. v, ok := value.(int64)
  6022. if !ok {
  6023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6024. }
  6025. m.AddBotID(v)
  6026. return nil
  6027. case chatrecords.FieldBotType:
  6028. v, ok := value.(int8)
  6029. if !ok {
  6030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6031. }
  6032. m.AddBotType(v)
  6033. return nil
  6034. }
  6035. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6036. }
  6037. // ClearedFields returns all nullable fields that were cleared during this
  6038. // mutation.
  6039. func (m *ChatRecordsMutation) ClearedFields() []string {
  6040. var fields []string
  6041. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6042. fields = append(fields, chatrecords.FieldDeletedAt)
  6043. }
  6044. return fields
  6045. }
  6046. // FieldCleared returns a boolean indicating if a field with the given name was
  6047. // cleared in this mutation.
  6048. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6049. _, ok := m.clearedFields[name]
  6050. return ok
  6051. }
  6052. // ClearField clears the value of the field with the given name. It returns an
  6053. // error if the field is not defined in the schema.
  6054. func (m *ChatRecordsMutation) ClearField(name string) error {
  6055. switch name {
  6056. case chatrecords.FieldDeletedAt:
  6057. m.ClearDeletedAt()
  6058. return nil
  6059. }
  6060. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6061. }
  6062. // ResetField resets all changes in the mutation for the field with the given name.
  6063. // It returns an error if the field is not defined in the schema.
  6064. func (m *ChatRecordsMutation) ResetField(name string) error {
  6065. switch name {
  6066. case chatrecords.FieldCreatedAt:
  6067. m.ResetCreatedAt()
  6068. return nil
  6069. case chatrecords.FieldUpdatedAt:
  6070. m.ResetUpdatedAt()
  6071. return nil
  6072. case chatrecords.FieldDeletedAt:
  6073. m.ResetDeletedAt()
  6074. return nil
  6075. case chatrecords.FieldContent:
  6076. m.ResetContent()
  6077. return nil
  6078. case chatrecords.FieldContentType:
  6079. m.ResetContentType()
  6080. return nil
  6081. case chatrecords.FieldSessionID:
  6082. m.ResetSessionID()
  6083. return nil
  6084. case chatrecords.FieldUserID:
  6085. m.ResetUserID()
  6086. return nil
  6087. case chatrecords.FieldBotID:
  6088. m.ResetBotID()
  6089. return nil
  6090. case chatrecords.FieldBotType:
  6091. m.ResetBotType()
  6092. return nil
  6093. }
  6094. return fmt.Errorf("unknown ChatRecords field %s", name)
  6095. }
  6096. // AddedEdges returns all edge names that were set/added in this mutation.
  6097. func (m *ChatRecordsMutation) AddedEdges() []string {
  6098. edges := make([]string, 0, 0)
  6099. return edges
  6100. }
  6101. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6102. // name in this mutation.
  6103. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6104. return nil
  6105. }
  6106. // RemovedEdges returns all edge names that were removed in this mutation.
  6107. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6108. edges := make([]string, 0, 0)
  6109. return edges
  6110. }
  6111. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6112. // the given name in this mutation.
  6113. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6114. return nil
  6115. }
  6116. // ClearedEdges returns all edge names that were cleared in this mutation.
  6117. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6118. edges := make([]string, 0, 0)
  6119. return edges
  6120. }
  6121. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6122. // was cleared in this mutation.
  6123. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6124. return false
  6125. }
  6126. // ClearEdge clears the value of the edge with the given name. It returns an error
  6127. // if that edge is not defined in the schema.
  6128. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6129. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6130. }
  6131. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6132. // It returns an error if the edge is not defined in the schema.
  6133. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6134. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6135. }
  6136. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6137. type ChatSessionMutation struct {
  6138. config
  6139. op Op
  6140. typ string
  6141. id *uint64
  6142. created_at *time.Time
  6143. updated_at *time.Time
  6144. deleted_at *time.Time
  6145. name *string
  6146. user_id *uint64
  6147. adduser_id *int64
  6148. bot_id *uint64
  6149. addbot_id *int64
  6150. bot_type *uint8
  6151. addbot_type *int8
  6152. clearedFields map[string]struct{}
  6153. done bool
  6154. oldValue func(context.Context) (*ChatSession, error)
  6155. predicates []predicate.ChatSession
  6156. }
  6157. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6158. // chatsessionOption allows management of the mutation configuration using functional options.
  6159. type chatsessionOption func(*ChatSessionMutation)
  6160. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6161. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6162. m := &ChatSessionMutation{
  6163. config: c,
  6164. op: op,
  6165. typ: TypeChatSession,
  6166. clearedFields: make(map[string]struct{}),
  6167. }
  6168. for _, opt := range opts {
  6169. opt(m)
  6170. }
  6171. return m
  6172. }
  6173. // withChatSessionID sets the ID field of the mutation.
  6174. func withChatSessionID(id uint64) chatsessionOption {
  6175. return func(m *ChatSessionMutation) {
  6176. var (
  6177. err error
  6178. once sync.Once
  6179. value *ChatSession
  6180. )
  6181. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6182. once.Do(func() {
  6183. if m.done {
  6184. err = errors.New("querying old values post mutation is not allowed")
  6185. } else {
  6186. value, err = m.Client().ChatSession.Get(ctx, id)
  6187. }
  6188. })
  6189. return value, err
  6190. }
  6191. m.id = &id
  6192. }
  6193. }
  6194. // withChatSession sets the old ChatSession of the mutation.
  6195. func withChatSession(node *ChatSession) chatsessionOption {
  6196. return func(m *ChatSessionMutation) {
  6197. m.oldValue = func(context.Context) (*ChatSession, error) {
  6198. return node, nil
  6199. }
  6200. m.id = &node.ID
  6201. }
  6202. }
  6203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6204. // executed in a transaction (ent.Tx), a transactional client is returned.
  6205. func (m ChatSessionMutation) Client() *Client {
  6206. client := &Client{config: m.config}
  6207. client.init()
  6208. return client
  6209. }
  6210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6211. // it returns an error otherwise.
  6212. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6213. if _, ok := m.driver.(*txDriver); !ok {
  6214. return nil, errors.New("ent: mutation is not running in a transaction")
  6215. }
  6216. tx := &Tx{config: m.config}
  6217. tx.init()
  6218. return tx, nil
  6219. }
  6220. // SetID sets the value of the id field. Note that this
  6221. // operation is only accepted on creation of ChatSession entities.
  6222. func (m *ChatSessionMutation) SetID(id uint64) {
  6223. m.id = &id
  6224. }
  6225. // ID returns the ID value in the mutation. Note that the ID is only available
  6226. // if it was provided to the builder or after it was returned from the database.
  6227. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6228. if m.id == nil {
  6229. return
  6230. }
  6231. return *m.id, true
  6232. }
  6233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6234. // That means, if the mutation is applied within a transaction with an isolation level such
  6235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6236. // or updated by the mutation.
  6237. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6238. switch {
  6239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6240. id, exists := m.ID()
  6241. if exists {
  6242. return []uint64{id}, nil
  6243. }
  6244. fallthrough
  6245. case m.op.Is(OpUpdate | OpDelete):
  6246. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6247. default:
  6248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6249. }
  6250. }
  6251. // SetCreatedAt sets the "created_at" field.
  6252. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  6253. m.created_at = &t
  6254. }
  6255. // CreatedAt returns the value of the "created_at" field in the mutation.
  6256. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  6257. v := m.created_at
  6258. if v == nil {
  6259. return
  6260. }
  6261. return *v, true
  6262. }
  6263. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  6264. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6266. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6267. if !m.op.Is(OpUpdateOne) {
  6268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6269. }
  6270. if m.id == nil || m.oldValue == nil {
  6271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6272. }
  6273. oldValue, err := m.oldValue(ctx)
  6274. if err != nil {
  6275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6276. }
  6277. return oldValue.CreatedAt, nil
  6278. }
  6279. // ResetCreatedAt resets all changes to the "created_at" field.
  6280. func (m *ChatSessionMutation) ResetCreatedAt() {
  6281. m.created_at = nil
  6282. }
  6283. // SetUpdatedAt sets the "updated_at" field.
  6284. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  6285. m.updated_at = &t
  6286. }
  6287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6288. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  6289. v := m.updated_at
  6290. if v == nil {
  6291. return
  6292. }
  6293. return *v, true
  6294. }
  6295. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  6296. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6298. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6299. if !m.op.Is(OpUpdateOne) {
  6300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6301. }
  6302. if m.id == nil || m.oldValue == nil {
  6303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6304. }
  6305. oldValue, err := m.oldValue(ctx)
  6306. if err != nil {
  6307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6308. }
  6309. return oldValue.UpdatedAt, nil
  6310. }
  6311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6312. func (m *ChatSessionMutation) ResetUpdatedAt() {
  6313. m.updated_at = nil
  6314. }
  6315. // SetDeletedAt sets the "deleted_at" field.
  6316. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  6317. m.deleted_at = &t
  6318. }
  6319. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6320. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  6321. v := m.deleted_at
  6322. if v == nil {
  6323. return
  6324. }
  6325. return *v, true
  6326. }
  6327. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  6328. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6330. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6331. if !m.op.Is(OpUpdateOne) {
  6332. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6333. }
  6334. if m.id == nil || m.oldValue == nil {
  6335. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6336. }
  6337. oldValue, err := m.oldValue(ctx)
  6338. if err != nil {
  6339. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6340. }
  6341. return oldValue.DeletedAt, nil
  6342. }
  6343. // ClearDeletedAt clears the value of the "deleted_at" field.
  6344. func (m *ChatSessionMutation) ClearDeletedAt() {
  6345. m.deleted_at = nil
  6346. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  6347. }
  6348. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6349. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  6350. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  6351. return ok
  6352. }
  6353. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6354. func (m *ChatSessionMutation) ResetDeletedAt() {
  6355. m.deleted_at = nil
  6356. delete(m.clearedFields, chatsession.FieldDeletedAt)
  6357. }
  6358. // SetName sets the "name" field.
  6359. func (m *ChatSessionMutation) SetName(s string) {
  6360. m.name = &s
  6361. }
  6362. // Name returns the value of the "name" field in the mutation.
  6363. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  6364. v := m.name
  6365. if v == nil {
  6366. return
  6367. }
  6368. return *v, true
  6369. }
  6370. // OldName returns the old "name" field's value of the ChatSession entity.
  6371. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6373. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  6374. if !m.op.Is(OpUpdateOne) {
  6375. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6376. }
  6377. if m.id == nil || m.oldValue == nil {
  6378. return v, errors.New("OldName requires an ID field in the mutation")
  6379. }
  6380. oldValue, err := m.oldValue(ctx)
  6381. if err != nil {
  6382. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6383. }
  6384. return oldValue.Name, nil
  6385. }
  6386. // ResetName resets all changes to the "name" field.
  6387. func (m *ChatSessionMutation) ResetName() {
  6388. m.name = nil
  6389. }
  6390. // SetUserID sets the "user_id" field.
  6391. func (m *ChatSessionMutation) SetUserID(u uint64) {
  6392. m.user_id = &u
  6393. m.adduser_id = nil
  6394. }
  6395. // UserID returns the value of the "user_id" field in the mutation.
  6396. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  6397. v := m.user_id
  6398. if v == nil {
  6399. return
  6400. }
  6401. return *v, true
  6402. }
  6403. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  6404. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6406. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6407. if !m.op.Is(OpUpdateOne) {
  6408. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6409. }
  6410. if m.id == nil || m.oldValue == nil {
  6411. return v, errors.New("OldUserID requires an ID field in the mutation")
  6412. }
  6413. oldValue, err := m.oldValue(ctx)
  6414. if err != nil {
  6415. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6416. }
  6417. return oldValue.UserID, nil
  6418. }
  6419. // AddUserID adds u to the "user_id" field.
  6420. func (m *ChatSessionMutation) AddUserID(u int64) {
  6421. if m.adduser_id != nil {
  6422. *m.adduser_id += u
  6423. } else {
  6424. m.adduser_id = &u
  6425. }
  6426. }
  6427. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6428. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  6429. v := m.adduser_id
  6430. if v == nil {
  6431. return
  6432. }
  6433. return *v, true
  6434. }
  6435. // ResetUserID resets all changes to the "user_id" field.
  6436. func (m *ChatSessionMutation) ResetUserID() {
  6437. m.user_id = nil
  6438. m.adduser_id = nil
  6439. }
  6440. // SetBotID sets the "bot_id" field.
  6441. func (m *ChatSessionMutation) SetBotID(u uint64) {
  6442. m.bot_id = &u
  6443. m.addbot_id = nil
  6444. }
  6445. // BotID returns the value of the "bot_id" field in the mutation.
  6446. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  6447. v := m.bot_id
  6448. if v == nil {
  6449. return
  6450. }
  6451. return *v, true
  6452. }
  6453. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  6454. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6456. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6457. if !m.op.Is(OpUpdateOne) {
  6458. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6459. }
  6460. if m.id == nil || m.oldValue == nil {
  6461. return v, errors.New("OldBotID requires an ID field in the mutation")
  6462. }
  6463. oldValue, err := m.oldValue(ctx)
  6464. if err != nil {
  6465. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6466. }
  6467. return oldValue.BotID, nil
  6468. }
  6469. // AddBotID adds u to the "bot_id" field.
  6470. func (m *ChatSessionMutation) AddBotID(u int64) {
  6471. if m.addbot_id != nil {
  6472. *m.addbot_id += u
  6473. } else {
  6474. m.addbot_id = &u
  6475. }
  6476. }
  6477. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6478. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  6479. v := m.addbot_id
  6480. if v == nil {
  6481. return
  6482. }
  6483. return *v, true
  6484. }
  6485. // ResetBotID resets all changes to the "bot_id" field.
  6486. func (m *ChatSessionMutation) ResetBotID() {
  6487. m.bot_id = nil
  6488. m.addbot_id = nil
  6489. }
  6490. // SetBotType sets the "bot_type" field.
  6491. func (m *ChatSessionMutation) SetBotType(u uint8) {
  6492. m.bot_type = &u
  6493. m.addbot_type = nil
  6494. }
  6495. // BotType returns the value of the "bot_type" field in the mutation.
  6496. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  6497. v := m.bot_type
  6498. if v == nil {
  6499. return
  6500. }
  6501. return *v, true
  6502. }
  6503. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  6504. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6506. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6507. if !m.op.Is(OpUpdateOne) {
  6508. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6509. }
  6510. if m.id == nil || m.oldValue == nil {
  6511. return v, errors.New("OldBotType requires an ID field in the mutation")
  6512. }
  6513. oldValue, err := m.oldValue(ctx)
  6514. if err != nil {
  6515. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6516. }
  6517. return oldValue.BotType, nil
  6518. }
  6519. // AddBotType adds u to the "bot_type" field.
  6520. func (m *ChatSessionMutation) AddBotType(u int8) {
  6521. if m.addbot_type != nil {
  6522. *m.addbot_type += u
  6523. } else {
  6524. m.addbot_type = &u
  6525. }
  6526. }
  6527. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6528. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  6529. v := m.addbot_type
  6530. if v == nil {
  6531. return
  6532. }
  6533. return *v, true
  6534. }
  6535. // ResetBotType resets all changes to the "bot_type" field.
  6536. func (m *ChatSessionMutation) ResetBotType() {
  6537. m.bot_type = nil
  6538. m.addbot_type = nil
  6539. }
  6540. // Where appends a list predicates to the ChatSessionMutation builder.
  6541. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  6542. m.predicates = append(m.predicates, ps...)
  6543. }
  6544. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  6545. // users can use type-assertion to append predicates that do not depend on any generated package.
  6546. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  6547. p := make([]predicate.ChatSession, len(ps))
  6548. for i := range ps {
  6549. p[i] = ps[i]
  6550. }
  6551. m.Where(p...)
  6552. }
  6553. // Op returns the operation name.
  6554. func (m *ChatSessionMutation) Op() Op {
  6555. return m.op
  6556. }
  6557. // SetOp allows setting the mutation operation.
  6558. func (m *ChatSessionMutation) SetOp(op Op) {
  6559. m.op = op
  6560. }
  6561. // Type returns the node type of this mutation (ChatSession).
  6562. func (m *ChatSessionMutation) Type() string {
  6563. return m.typ
  6564. }
  6565. // Fields returns all fields that were changed during this mutation. Note that in
  6566. // order to get all numeric fields that were incremented/decremented, call
  6567. // AddedFields().
  6568. func (m *ChatSessionMutation) Fields() []string {
  6569. fields := make([]string, 0, 7)
  6570. if m.created_at != nil {
  6571. fields = append(fields, chatsession.FieldCreatedAt)
  6572. }
  6573. if m.updated_at != nil {
  6574. fields = append(fields, chatsession.FieldUpdatedAt)
  6575. }
  6576. if m.deleted_at != nil {
  6577. fields = append(fields, chatsession.FieldDeletedAt)
  6578. }
  6579. if m.name != nil {
  6580. fields = append(fields, chatsession.FieldName)
  6581. }
  6582. if m.user_id != nil {
  6583. fields = append(fields, chatsession.FieldUserID)
  6584. }
  6585. if m.bot_id != nil {
  6586. fields = append(fields, chatsession.FieldBotID)
  6587. }
  6588. if m.bot_type != nil {
  6589. fields = append(fields, chatsession.FieldBotType)
  6590. }
  6591. return fields
  6592. }
  6593. // Field returns the value of a field with the given name. The second boolean
  6594. // return value indicates that this field was not set, or was not defined in the
  6595. // schema.
  6596. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  6597. switch name {
  6598. case chatsession.FieldCreatedAt:
  6599. return m.CreatedAt()
  6600. case chatsession.FieldUpdatedAt:
  6601. return m.UpdatedAt()
  6602. case chatsession.FieldDeletedAt:
  6603. return m.DeletedAt()
  6604. case chatsession.FieldName:
  6605. return m.Name()
  6606. case chatsession.FieldUserID:
  6607. return m.UserID()
  6608. case chatsession.FieldBotID:
  6609. return m.BotID()
  6610. case chatsession.FieldBotType:
  6611. return m.BotType()
  6612. }
  6613. return nil, false
  6614. }
  6615. // OldField returns the old value of the field from the database. An error is
  6616. // returned if the mutation operation is not UpdateOne, or the query to the
  6617. // database failed.
  6618. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6619. switch name {
  6620. case chatsession.FieldCreatedAt:
  6621. return m.OldCreatedAt(ctx)
  6622. case chatsession.FieldUpdatedAt:
  6623. return m.OldUpdatedAt(ctx)
  6624. case chatsession.FieldDeletedAt:
  6625. return m.OldDeletedAt(ctx)
  6626. case chatsession.FieldName:
  6627. return m.OldName(ctx)
  6628. case chatsession.FieldUserID:
  6629. return m.OldUserID(ctx)
  6630. case chatsession.FieldBotID:
  6631. return m.OldBotID(ctx)
  6632. case chatsession.FieldBotType:
  6633. return m.OldBotType(ctx)
  6634. }
  6635. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  6636. }
  6637. // SetField sets the value of a field with the given name. It returns an error if
  6638. // the field is not defined in the schema, or if the type mismatched the field
  6639. // type.
  6640. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  6641. switch name {
  6642. case chatsession.FieldCreatedAt:
  6643. v, ok := value.(time.Time)
  6644. if !ok {
  6645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6646. }
  6647. m.SetCreatedAt(v)
  6648. return nil
  6649. case chatsession.FieldUpdatedAt:
  6650. v, ok := value.(time.Time)
  6651. if !ok {
  6652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6653. }
  6654. m.SetUpdatedAt(v)
  6655. return nil
  6656. case chatsession.FieldDeletedAt:
  6657. v, ok := value.(time.Time)
  6658. if !ok {
  6659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6660. }
  6661. m.SetDeletedAt(v)
  6662. return nil
  6663. case chatsession.FieldName:
  6664. v, ok := value.(string)
  6665. if !ok {
  6666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6667. }
  6668. m.SetName(v)
  6669. return nil
  6670. case chatsession.FieldUserID:
  6671. v, ok := value.(uint64)
  6672. if !ok {
  6673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6674. }
  6675. m.SetUserID(v)
  6676. return nil
  6677. case chatsession.FieldBotID:
  6678. v, ok := value.(uint64)
  6679. if !ok {
  6680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6681. }
  6682. m.SetBotID(v)
  6683. return nil
  6684. case chatsession.FieldBotType:
  6685. v, ok := value.(uint8)
  6686. if !ok {
  6687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6688. }
  6689. m.SetBotType(v)
  6690. return nil
  6691. }
  6692. return fmt.Errorf("unknown ChatSession field %s", name)
  6693. }
  6694. // AddedFields returns all numeric fields that were incremented/decremented during
  6695. // this mutation.
  6696. func (m *ChatSessionMutation) AddedFields() []string {
  6697. var fields []string
  6698. if m.adduser_id != nil {
  6699. fields = append(fields, chatsession.FieldUserID)
  6700. }
  6701. if m.addbot_id != nil {
  6702. fields = append(fields, chatsession.FieldBotID)
  6703. }
  6704. if m.addbot_type != nil {
  6705. fields = append(fields, chatsession.FieldBotType)
  6706. }
  6707. return fields
  6708. }
  6709. // AddedField returns the numeric value that was incremented/decremented on a field
  6710. // with the given name. The second boolean return value indicates that this field
  6711. // was not set, or was not defined in the schema.
  6712. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  6713. switch name {
  6714. case chatsession.FieldUserID:
  6715. return m.AddedUserID()
  6716. case chatsession.FieldBotID:
  6717. return m.AddedBotID()
  6718. case chatsession.FieldBotType:
  6719. return m.AddedBotType()
  6720. }
  6721. return nil, false
  6722. }
  6723. // AddField adds the value to the field with the given name. It returns an error if
  6724. // the field is not defined in the schema, or if the type mismatched the field
  6725. // type.
  6726. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  6727. switch name {
  6728. case chatsession.FieldUserID:
  6729. v, ok := value.(int64)
  6730. if !ok {
  6731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6732. }
  6733. m.AddUserID(v)
  6734. return nil
  6735. case chatsession.FieldBotID:
  6736. v, ok := value.(int64)
  6737. if !ok {
  6738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6739. }
  6740. m.AddBotID(v)
  6741. return nil
  6742. case chatsession.FieldBotType:
  6743. v, ok := value.(int8)
  6744. if !ok {
  6745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6746. }
  6747. m.AddBotType(v)
  6748. return nil
  6749. }
  6750. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  6751. }
  6752. // ClearedFields returns all nullable fields that were cleared during this
  6753. // mutation.
  6754. func (m *ChatSessionMutation) ClearedFields() []string {
  6755. var fields []string
  6756. if m.FieldCleared(chatsession.FieldDeletedAt) {
  6757. fields = append(fields, chatsession.FieldDeletedAt)
  6758. }
  6759. return fields
  6760. }
  6761. // FieldCleared returns a boolean indicating if a field with the given name was
  6762. // cleared in this mutation.
  6763. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  6764. _, ok := m.clearedFields[name]
  6765. return ok
  6766. }
  6767. // ClearField clears the value of the field with the given name. It returns an
  6768. // error if the field is not defined in the schema.
  6769. func (m *ChatSessionMutation) ClearField(name string) error {
  6770. switch name {
  6771. case chatsession.FieldDeletedAt:
  6772. m.ClearDeletedAt()
  6773. return nil
  6774. }
  6775. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  6776. }
  6777. // ResetField resets all changes in the mutation for the field with the given name.
  6778. // It returns an error if the field is not defined in the schema.
  6779. func (m *ChatSessionMutation) ResetField(name string) error {
  6780. switch name {
  6781. case chatsession.FieldCreatedAt:
  6782. m.ResetCreatedAt()
  6783. return nil
  6784. case chatsession.FieldUpdatedAt:
  6785. m.ResetUpdatedAt()
  6786. return nil
  6787. case chatsession.FieldDeletedAt:
  6788. m.ResetDeletedAt()
  6789. return nil
  6790. case chatsession.FieldName:
  6791. m.ResetName()
  6792. return nil
  6793. case chatsession.FieldUserID:
  6794. m.ResetUserID()
  6795. return nil
  6796. case chatsession.FieldBotID:
  6797. m.ResetBotID()
  6798. return nil
  6799. case chatsession.FieldBotType:
  6800. m.ResetBotType()
  6801. return nil
  6802. }
  6803. return fmt.Errorf("unknown ChatSession field %s", name)
  6804. }
  6805. // AddedEdges returns all edge names that were set/added in this mutation.
  6806. func (m *ChatSessionMutation) AddedEdges() []string {
  6807. edges := make([]string, 0, 0)
  6808. return edges
  6809. }
  6810. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6811. // name in this mutation.
  6812. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  6813. return nil
  6814. }
  6815. // RemovedEdges returns all edge names that were removed in this mutation.
  6816. func (m *ChatSessionMutation) RemovedEdges() []string {
  6817. edges := make([]string, 0, 0)
  6818. return edges
  6819. }
  6820. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6821. // the given name in this mutation.
  6822. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  6823. return nil
  6824. }
  6825. // ClearedEdges returns all edge names that were cleared in this mutation.
  6826. func (m *ChatSessionMutation) ClearedEdges() []string {
  6827. edges := make([]string, 0, 0)
  6828. return edges
  6829. }
  6830. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6831. // was cleared in this mutation.
  6832. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  6833. return false
  6834. }
  6835. // ClearEdge clears the value of the edge with the given name. It returns an error
  6836. // if that edge is not defined in the schema.
  6837. func (m *ChatSessionMutation) ClearEdge(name string) error {
  6838. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  6839. }
  6840. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6841. // It returns an error if the edge is not defined in the schema.
  6842. func (m *ChatSessionMutation) ResetEdge(name string) error {
  6843. return fmt.Errorf("unknown ChatSession edge %s", name)
  6844. }
  6845. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  6846. type ContactMutation struct {
  6847. config
  6848. op Op
  6849. typ string
  6850. id *uint64
  6851. created_at *time.Time
  6852. updated_at *time.Time
  6853. status *uint8
  6854. addstatus *int8
  6855. deleted_at *time.Time
  6856. wx_wxid *string
  6857. _type *int
  6858. add_type *int
  6859. wxid *string
  6860. account *string
  6861. nickname *string
  6862. markname *string
  6863. headimg *string
  6864. sex *int
  6865. addsex *int
  6866. starrole *string
  6867. dontseeit *int
  6868. adddontseeit *int
  6869. dontseeme *int
  6870. adddontseeme *int
  6871. lag *string
  6872. gid *string
  6873. gname *string
  6874. v3 *string
  6875. organization_id *uint64
  6876. addorganization_id *int64
  6877. clearedFields map[string]struct{}
  6878. contact_relationships map[uint64]struct{}
  6879. removedcontact_relationships map[uint64]struct{}
  6880. clearedcontact_relationships bool
  6881. contact_messages map[uint64]struct{}
  6882. removedcontact_messages map[uint64]struct{}
  6883. clearedcontact_messages bool
  6884. done bool
  6885. oldValue func(context.Context) (*Contact, error)
  6886. predicates []predicate.Contact
  6887. }
  6888. var _ ent.Mutation = (*ContactMutation)(nil)
  6889. // contactOption allows management of the mutation configuration using functional options.
  6890. type contactOption func(*ContactMutation)
  6891. // newContactMutation creates new mutation for the Contact entity.
  6892. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  6893. m := &ContactMutation{
  6894. config: c,
  6895. op: op,
  6896. typ: TypeContact,
  6897. clearedFields: make(map[string]struct{}),
  6898. }
  6899. for _, opt := range opts {
  6900. opt(m)
  6901. }
  6902. return m
  6903. }
  6904. // withContactID sets the ID field of the mutation.
  6905. func withContactID(id uint64) contactOption {
  6906. return func(m *ContactMutation) {
  6907. var (
  6908. err error
  6909. once sync.Once
  6910. value *Contact
  6911. )
  6912. m.oldValue = func(ctx context.Context) (*Contact, error) {
  6913. once.Do(func() {
  6914. if m.done {
  6915. err = errors.New("querying old values post mutation is not allowed")
  6916. } else {
  6917. value, err = m.Client().Contact.Get(ctx, id)
  6918. }
  6919. })
  6920. return value, err
  6921. }
  6922. m.id = &id
  6923. }
  6924. }
  6925. // withContact sets the old Contact of the mutation.
  6926. func withContact(node *Contact) contactOption {
  6927. return func(m *ContactMutation) {
  6928. m.oldValue = func(context.Context) (*Contact, error) {
  6929. return node, nil
  6930. }
  6931. m.id = &node.ID
  6932. }
  6933. }
  6934. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6935. // executed in a transaction (ent.Tx), a transactional client is returned.
  6936. func (m ContactMutation) Client() *Client {
  6937. client := &Client{config: m.config}
  6938. client.init()
  6939. return client
  6940. }
  6941. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6942. // it returns an error otherwise.
  6943. func (m ContactMutation) Tx() (*Tx, error) {
  6944. if _, ok := m.driver.(*txDriver); !ok {
  6945. return nil, errors.New("ent: mutation is not running in a transaction")
  6946. }
  6947. tx := &Tx{config: m.config}
  6948. tx.init()
  6949. return tx, nil
  6950. }
  6951. // SetID sets the value of the id field. Note that this
  6952. // operation is only accepted on creation of Contact entities.
  6953. func (m *ContactMutation) SetID(id uint64) {
  6954. m.id = &id
  6955. }
  6956. // ID returns the ID value in the mutation. Note that the ID is only available
  6957. // if it was provided to the builder or after it was returned from the database.
  6958. func (m *ContactMutation) ID() (id uint64, exists bool) {
  6959. if m.id == nil {
  6960. return
  6961. }
  6962. return *m.id, true
  6963. }
  6964. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6965. // That means, if the mutation is applied within a transaction with an isolation level such
  6966. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6967. // or updated by the mutation.
  6968. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  6969. switch {
  6970. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6971. id, exists := m.ID()
  6972. if exists {
  6973. return []uint64{id}, nil
  6974. }
  6975. fallthrough
  6976. case m.op.Is(OpUpdate | OpDelete):
  6977. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  6978. default:
  6979. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6980. }
  6981. }
  6982. // SetCreatedAt sets the "created_at" field.
  6983. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  6984. m.created_at = &t
  6985. }
  6986. // CreatedAt returns the value of the "created_at" field in the mutation.
  6987. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  6988. v := m.created_at
  6989. if v == nil {
  6990. return
  6991. }
  6992. return *v, true
  6993. }
  6994. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  6995. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6997. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6998. if !m.op.Is(OpUpdateOne) {
  6999. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7000. }
  7001. if m.id == nil || m.oldValue == nil {
  7002. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7003. }
  7004. oldValue, err := m.oldValue(ctx)
  7005. if err != nil {
  7006. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7007. }
  7008. return oldValue.CreatedAt, nil
  7009. }
  7010. // ResetCreatedAt resets all changes to the "created_at" field.
  7011. func (m *ContactMutation) ResetCreatedAt() {
  7012. m.created_at = nil
  7013. }
  7014. // SetUpdatedAt sets the "updated_at" field.
  7015. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7016. m.updated_at = &t
  7017. }
  7018. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7019. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7020. v := m.updated_at
  7021. if v == nil {
  7022. return
  7023. }
  7024. return *v, true
  7025. }
  7026. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7027. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7029. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7030. if !m.op.Is(OpUpdateOne) {
  7031. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7032. }
  7033. if m.id == nil || m.oldValue == nil {
  7034. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7035. }
  7036. oldValue, err := m.oldValue(ctx)
  7037. if err != nil {
  7038. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7039. }
  7040. return oldValue.UpdatedAt, nil
  7041. }
  7042. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7043. func (m *ContactMutation) ResetUpdatedAt() {
  7044. m.updated_at = nil
  7045. }
  7046. // SetStatus sets the "status" field.
  7047. func (m *ContactMutation) SetStatus(u uint8) {
  7048. m.status = &u
  7049. m.addstatus = nil
  7050. }
  7051. // Status returns the value of the "status" field in the mutation.
  7052. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7053. v := m.status
  7054. if v == nil {
  7055. return
  7056. }
  7057. return *v, true
  7058. }
  7059. // OldStatus returns the old "status" field's value of the Contact entity.
  7060. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7062. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7063. if !m.op.Is(OpUpdateOne) {
  7064. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7065. }
  7066. if m.id == nil || m.oldValue == nil {
  7067. return v, errors.New("OldStatus requires an ID field in the mutation")
  7068. }
  7069. oldValue, err := m.oldValue(ctx)
  7070. if err != nil {
  7071. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7072. }
  7073. return oldValue.Status, nil
  7074. }
  7075. // AddStatus adds u to the "status" field.
  7076. func (m *ContactMutation) AddStatus(u int8) {
  7077. if m.addstatus != nil {
  7078. *m.addstatus += u
  7079. } else {
  7080. m.addstatus = &u
  7081. }
  7082. }
  7083. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7084. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7085. v := m.addstatus
  7086. if v == nil {
  7087. return
  7088. }
  7089. return *v, true
  7090. }
  7091. // ClearStatus clears the value of the "status" field.
  7092. func (m *ContactMutation) ClearStatus() {
  7093. m.status = nil
  7094. m.addstatus = nil
  7095. m.clearedFields[contact.FieldStatus] = struct{}{}
  7096. }
  7097. // StatusCleared returns if the "status" field was cleared in this mutation.
  7098. func (m *ContactMutation) StatusCleared() bool {
  7099. _, ok := m.clearedFields[contact.FieldStatus]
  7100. return ok
  7101. }
  7102. // ResetStatus resets all changes to the "status" field.
  7103. func (m *ContactMutation) ResetStatus() {
  7104. m.status = nil
  7105. m.addstatus = nil
  7106. delete(m.clearedFields, contact.FieldStatus)
  7107. }
  7108. // SetDeletedAt sets the "deleted_at" field.
  7109. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7110. m.deleted_at = &t
  7111. }
  7112. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7113. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7114. v := m.deleted_at
  7115. if v == nil {
  7116. return
  7117. }
  7118. return *v, true
  7119. }
  7120. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7121. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7123. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7124. if !m.op.Is(OpUpdateOne) {
  7125. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7126. }
  7127. if m.id == nil || m.oldValue == nil {
  7128. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7129. }
  7130. oldValue, err := m.oldValue(ctx)
  7131. if err != nil {
  7132. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7133. }
  7134. return oldValue.DeletedAt, nil
  7135. }
  7136. // ClearDeletedAt clears the value of the "deleted_at" field.
  7137. func (m *ContactMutation) ClearDeletedAt() {
  7138. m.deleted_at = nil
  7139. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7140. }
  7141. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7142. func (m *ContactMutation) DeletedAtCleared() bool {
  7143. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7144. return ok
  7145. }
  7146. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7147. func (m *ContactMutation) ResetDeletedAt() {
  7148. m.deleted_at = nil
  7149. delete(m.clearedFields, contact.FieldDeletedAt)
  7150. }
  7151. // SetWxWxid sets the "wx_wxid" field.
  7152. func (m *ContactMutation) SetWxWxid(s string) {
  7153. m.wx_wxid = &s
  7154. }
  7155. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7156. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7157. v := m.wx_wxid
  7158. if v == nil {
  7159. return
  7160. }
  7161. return *v, true
  7162. }
  7163. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7164. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7166. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7167. if !m.op.Is(OpUpdateOne) {
  7168. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7169. }
  7170. if m.id == nil || m.oldValue == nil {
  7171. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7172. }
  7173. oldValue, err := m.oldValue(ctx)
  7174. if err != nil {
  7175. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7176. }
  7177. return oldValue.WxWxid, nil
  7178. }
  7179. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7180. func (m *ContactMutation) ResetWxWxid() {
  7181. m.wx_wxid = nil
  7182. }
  7183. // SetType sets the "type" field.
  7184. func (m *ContactMutation) SetType(i int) {
  7185. m._type = &i
  7186. m.add_type = nil
  7187. }
  7188. // GetType returns the value of the "type" field in the mutation.
  7189. func (m *ContactMutation) GetType() (r int, exists bool) {
  7190. v := m._type
  7191. if v == nil {
  7192. return
  7193. }
  7194. return *v, true
  7195. }
  7196. // OldType returns the old "type" field's value of the Contact entity.
  7197. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7199. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7200. if !m.op.Is(OpUpdateOne) {
  7201. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7202. }
  7203. if m.id == nil || m.oldValue == nil {
  7204. return v, errors.New("OldType requires an ID field in the mutation")
  7205. }
  7206. oldValue, err := m.oldValue(ctx)
  7207. if err != nil {
  7208. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7209. }
  7210. return oldValue.Type, nil
  7211. }
  7212. // AddType adds i to the "type" field.
  7213. func (m *ContactMutation) AddType(i int) {
  7214. if m.add_type != nil {
  7215. *m.add_type += i
  7216. } else {
  7217. m.add_type = &i
  7218. }
  7219. }
  7220. // AddedType returns the value that was added to the "type" field in this mutation.
  7221. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7222. v := m.add_type
  7223. if v == nil {
  7224. return
  7225. }
  7226. return *v, true
  7227. }
  7228. // ClearType clears the value of the "type" field.
  7229. func (m *ContactMutation) ClearType() {
  7230. m._type = nil
  7231. m.add_type = nil
  7232. m.clearedFields[contact.FieldType] = struct{}{}
  7233. }
  7234. // TypeCleared returns if the "type" field was cleared in this mutation.
  7235. func (m *ContactMutation) TypeCleared() bool {
  7236. _, ok := m.clearedFields[contact.FieldType]
  7237. return ok
  7238. }
  7239. // ResetType resets all changes to the "type" field.
  7240. func (m *ContactMutation) ResetType() {
  7241. m._type = nil
  7242. m.add_type = nil
  7243. delete(m.clearedFields, contact.FieldType)
  7244. }
  7245. // SetWxid sets the "wxid" field.
  7246. func (m *ContactMutation) SetWxid(s string) {
  7247. m.wxid = &s
  7248. }
  7249. // Wxid returns the value of the "wxid" field in the mutation.
  7250. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7251. v := m.wxid
  7252. if v == nil {
  7253. return
  7254. }
  7255. return *v, true
  7256. }
  7257. // OldWxid returns the old "wxid" field's value of the Contact entity.
  7258. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7260. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  7261. if !m.op.Is(OpUpdateOne) {
  7262. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7263. }
  7264. if m.id == nil || m.oldValue == nil {
  7265. return v, errors.New("OldWxid requires an ID field in the mutation")
  7266. }
  7267. oldValue, err := m.oldValue(ctx)
  7268. if err != nil {
  7269. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7270. }
  7271. return oldValue.Wxid, nil
  7272. }
  7273. // ResetWxid resets all changes to the "wxid" field.
  7274. func (m *ContactMutation) ResetWxid() {
  7275. m.wxid = nil
  7276. }
  7277. // SetAccount sets the "account" field.
  7278. func (m *ContactMutation) SetAccount(s string) {
  7279. m.account = &s
  7280. }
  7281. // Account returns the value of the "account" field in the mutation.
  7282. func (m *ContactMutation) Account() (r string, exists bool) {
  7283. v := m.account
  7284. if v == nil {
  7285. return
  7286. }
  7287. return *v, true
  7288. }
  7289. // OldAccount returns the old "account" field's value of the Contact entity.
  7290. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7292. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  7293. if !m.op.Is(OpUpdateOne) {
  7294. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  7295. }
  7296. if m.id == nil || m.oldValue == nil {
  7297. return v, errors.New("OldAccount requires an ID field in the mutation")
  7298. }
  7299. oldValue, err := m.oldValue(ctx)
  7300. if err != nil {
  7301. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  7302. }
  7303. return oldValue.Account, nil
  7304. }
  7305. // ResetAccount resets all changes to the "account" field.
  7306. func (m *ContactMutation) ResetAccount() {
  7307. m.account = nil
  7308. }
  7309. // SetNickname sets the "nickname" field.
  7310. func (m *ContactMutation) SetNickname(s string) {
  7311. m.nickname = &s
  7312. }
  7313. // Nickname returns the value of the "nickname" field in the mutation.
  7314. func (m *ContactMutation) Nickname() (r string, exists bool) {
  7315. v := m.nickname
  7316. if v == nil {
  7317. return
  7318. }
  7319. return *v, true
  7320. }
  7321. // OldNickname returns the old "nickname" field's value of the Contact entity.
  7322. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7324. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  7325. if !m.op.Is(OpUpdateOne) {
  7326. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  7327. }
  7328. if m.id == nil || m.oldValue == nil {
  7329. return v, errors.New("OldNickname requires an ID field in the mutation")
  7330. }
  7331. oldValue, err := m.oldValue(ctx)
  7332. if err != nil {
  7333. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  7334. }
  7335. return oldValue.Nickname, nil
  7336. }
  7337. // ResetNickname resets all changes to the "nickname" field.
  7338. func (m *ContactMutation) ResetNickname() {
  7339. m.nickname = nil
  7340. }
  7341. // SetMarkname sets the "markname" field.
  7342. func (m *ContactMutation) SetMarkname(s string) {
  7343. m.markname = &s
  7344. }
  7345. // Markname returns the value of the "markname" field in the mutation.
  7346. func (m *ContactMutation) Markname() (r string, exists bool) {
  7347. v := m.markname
  7348. if v == nil {
  7349. return
  7350. }
  7351. return *v, true
  7352. }
  7353. // OldMarkname returns the old "markname" field's value of the Contact entity.
  7354. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7356. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  7357. if !m.op.Is(OpUpdateOne) {
  7358. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  7359. }
  7360. if m.id == nil || m.oldValue == nil {
  7361. return v, errors.New("OldMarkname requires an ID field in the mutation")
  7362. }
  7363. oldValue, err := m.oldValue(ctx)
  7364. if err != nil {
  7365. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  7366. }
  7367. return oldValue.Markname, nil
  7368. }
  7369. // ResetMarkname resets all changes to the "markname" field.
  7370. func (m *ContactMutation) ResetMarkname() {
  7371. m.markname = nil
  7372. }
  7373. // SetHeadimg sets the "headimg" field.
  7374. func (m *ContactMutation) SetHeadimg(s string) {
  7375. m.headimg = &s
  7376. }
  7377. // Headimg returns the value of the "headimg" field in the mutation.
  7378. func (m *ContactMutation) Headimg() (r string, exists bool) {
  7379. v := m.headimg
  7380. if v == nil {
  7381. return
  7382. }
  7383. return *v, true
  7384. }
  7385. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  7386. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7388. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  7389. if !m.op.Is(OpUpdateOne) {
  7390. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  7391. }
  7392. if m.id == nil || m.oldValue == nil {
  7393. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  7394. }
  7395. oldValue, err := m.oldValue(ctx)
  7396. if err != nil {
  7397. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  7398. }
  7399. return oldValue.Headimg, nil
  7400. }
  7401. // ResetHeadimg resets all changes to the "headimg" field.
  7402. func (m *ContactMutation) ResetHeadimg() {
  7403. m.headimg = nil
  7404. }
  7405. // SetSex sets the "sex" field.
  7406. func (m *ContactMutation) SetSex(i int) {
  7407. m.sex = &i
  7408. m.addsex = nil
  7409. }
  7410. // Sex returns the value of the "sex" field in the mutation.
  7411. func (m *ContactMutation) Sex() (r int, exists bool) {
  7412. v := m.sex
  7413. if v == nil {
  7414. return
  7415. }
  7416. return *v, true
  7417. }
  7418. // OldSex returns the old "sex" field's value of the Contact entity.
  7419. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7421. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  7422. if !m.op.Is(OpUpdateOne) {
  7423. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  7424. }
  7425. if m.id == nil || m.oldValue == nil {
  7426. return v, errors.New("OldSex requires an ID field in the mutation")
  7427. }
  7428. oldValue, err := m.oldValue(ctx)
  7429. if err != nil {
  7430. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  7431. }
  7432. return oldValue.Sex, nil
  7433. }
  7434. // AddSex adds i to the "sex" field.
  7435. func (m *ContactMutation) AddSex(i int) {
  7436. if m.addsex != nil {
  7437. *m.addsex += i
  7438. } else {
  7439. m.addsex = &i
  7440. }
  7441. }
  7442. // AddedSex returns the value that was added to the "sex" field in this mutation.
  7443. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  7444. v := m.addsex
  7445. if v == nil {
  7446. return
  7447. }
  7448. return *v, true
  7449. }
  7450. // ResetSex resets all changes to the "sex" field.
  7451. func (m *ContactMutation) ResetSex() {
  7452. m.sex = nil
  7453. m.addsex = nil
  7454. }
  7455. // SetStarrole sets the "starrole" field.
  7456. func (m *ContactMutation) SetStarrole(s string) {
  7457. m.starrole = &s
  7458. }
  7459. // Starrole returns the value of the "starrole" field in the mutation.
  7460. func (m *ContactMutation) Starrole() (r string, exists bool) {
  7461. v := m.starrole
  7462. if v == nil {
  7463. return
  7464. }
  7465. return *v, true
  7466. }
  7467. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  7468. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7470. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  7471. if !m.op.Is(OpUpdateOne) {
  7472. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  7473. }
  7474. if m.id == nil || m.oldValue == nil {
  7475. return v, errors.New("OldStarrole requires an ID field in the mutation")
  7476. }
  7477. oldValue, err := m.oldValue(ctx)
  7478. if err != nil {
  7479. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  7480. }
  7481. return oldValue.Starrole, nil
  7482. }
  7483. // ResetStarrole resets all changes to the "starrole" field.
  7484. func (m *ContactMutation) ResetStarrole() {
  7485. m.starrole = nil
  7486. }
  7487. // SetDontseeit sets the "dontseeit" field.
  7488. func (m *ContactMutation) SetDontseeit(i int) {
  7489. m.dontseeit = &i
  7490. m.adddontseeit = nil
  7491. }
  7492. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  7493. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  7494. v := m.dontseeit
  7495. if v == nil {
  7496. return
  7497. }
  7498. return *v, true
  7499. }
  7500. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  7501. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7503. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  7504. if !m.op.Is(OpUpdateOne) {
  7505. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  7506. }
  7507. if m.id == nil || m.oldValue == nil {
  7508. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  7509. }
  7510. oldValue, err := m.oldValue(ctx)
  7511. if err != nil {
  7512. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  7513. }
  7514. return oldValue.Dontseeit, nil
  7515. }
  7516. // AddDontseeit adds i to the "dontseeit" field.
  7517. func (m *ContactMutation) AddDontseeit(i int) {
  7518. if m.adddontseeit != nil {
  7519. *m.adddontseeit += i
  7520. } else {
  7521. m.adddontseeit = &i
  7522. }
  7523. }
  7524. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  7525. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  7526. v := m.adddontseeit
  7527. if v == nil {
  7528. return
  7529. }
  7530. return *v, true
  7531. }
  7532. // ResetDontseeit resets all changes to the "dontseeit" field.
  7533. func (m *ContactMutation) ResetDontseeit() {
  7534. m.dontseeit = nil
  7535. m.adddontseeit = nil
  7536. }
  7537. // SetDontseeme sets the "dontseeme" field.
  7538. func (m *ContactMutation) SetDontseeme(i int) {
  7539. m.dontseeme = &i
  7540. m.adddontseeme = nil
  7541. }
  7542. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  7543. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  7544. v := m.dontseeme
  7545. if v == nil {
  7546. return
  7547. }
  7548. return *v, true
  7549. }
  7550. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  7551. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7553. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  7554. if !m.op.Is(OpUpdateOne) {
  7555. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  7556. }
  7557. if m.id == nil || m.oldValue == nil {
  7558. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  7559. }
  7560. oldValue, err := m.oldValue(ctx)
  7561. if err != nil {
  7562. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  7563. }
  7564. return oldValue.Dontseeme, nil
  7565. }
  7566. // AddDontseeme adds i to the "dontseeme" field.
  7567. func (m *ContactMutation) AddDontseeme(i int) {
  7568. if m.adddontseeme != nil {
  7569. *m.adddontseeme += i
  7570. } else {
  7571. m.adddontseeme = &i
  7572. }
  7573. }
  7574. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  7575. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  7576. v := m.adddontseeme
  7577. if v == nil {
  7578. return
  7579. }
  7580. return *v, true
  7581. }
  7582. // ResetDontseeme resets all changes to the "dontseeme" field.
  7583. func (m *ContactMutation) ResetDontseeme() {
  7584. m.dontseeme = nil
  7585. m.adddontseeme = nil
  7586. }
  7587. // SetLag sets the "lag" field.
  7588. func (m *ContactMutation) SetLag(s string) {
  7589. m.lag = &s
  7590. }
  7591. // Lag returns the value of the "lag" field in the mutation.
  7592. func (m *ContactMutation) Lag() (r string, exists bool) {
  7593. v := m.lag
  7594. if v == nil {
  7595. return
  7596. }
  7597. return *v, true
  7598. }
  7599. // OldLag returns the old "lag" field's value of the Contact entity.
  7600. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7602. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  7603. if !m.op.Is(OpUpdateOne) {
  7604. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  7605. }
  7606. if m.id == nil || m.oldValue == nil {
  7607. return v, errors.New("OldLag requires an ID field in the mutation")
  7608. }
  7609. oldValue, err := m.oldValue(ctx)
  7610. if err != nil {
  7611. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  7612. }
  7613. return oldValue.Lag, nil
  7614. }
  7615. // ResetLag resets all changes to the "lag" field.
  7616. func (m *ContactMutation) ResetLag() {
  7617. m.lag = nil
  7618. }
  7619. // SetGid sets the "gid" field.
  7620. func (m *ContactMutation) SetGid(s string) {
  7621. m.gid = &s
  7622. }
  7623. // Gid returns the value of the "gid" field in the mutation.
  7624. func (m *ContactMutation) Gid() (r string, exists bool) {
  7625. v := m.gid
  7626. if v == nil {
  7627. return
  7628. }
  7629. return *v, true
  7630. }
  7631. // OldGid returns the old "gid" field's value of the Contact entity.
  7632. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7634. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  7635. if !m.op.Is(OpUpdateOne) {
  7636. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  7637. }
  7638. if m.id == nil || m.oldValue == nil {
  7639. return v, errors.New("OldGid requires an ID field in the mutation")
  7640. }
  7641. oldValue, err := m.oldValue(ctx)
  7642. if err != nil {
  7643. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  7644. }
  7645. return oldValue.Gid, nil
  7646. }
  7647. // ResetGid resets all changes to the "gid" field.
  7648. func (m *ContactMutation) ResetGid() {
  7649. m.gid = nil
  7650. }
  7651. // SetGname sets the "gname" field.
  7652. func (m *ContactMutation) SetGname(s string) {
  7653. m.gname = &s
  7654. }
  7655. // Gname returns the value of the "gname" field in the mutation.
  7656. func (m *ContactMutation) Gname() (r string, exists bool) {
  7657. v := m.gname
  7658. if v == nil {
  7659. return
  7660. }
  7661. return *v, true
  7662. }
  7663. // OldGname returns the old "gname" field's value of the Contact entity.
  7664. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7666. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  7667. if !m.op.Is(OpUpdateOne) {
  7668. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  7669. }
  7670. if m.id == nil || m.oldValue == nil {
  7671. return v, errors.New("OldGname requires an ID field in the mutation")
  7672. }
  7673. oldValue, err := m.oldValue(ctx)
  7674. if err != nil {
  7675. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  7676. }
  7677. return oldValue.Gname, nil
  7678. }
  7679. // ResetGname resets all changes to the "gname" field.
  7680. func (m *ContactMutation) ResetGname() {
  7681. m.gname = nil
  7682. }
  7683. // SetV3 sets the "v3" field.
  7684. func (m *ContactMutation) SetV3(s string) {
  7685. m.v3 = &s
  7686. }
  7687. // V3 returns the value of the "v3" field in the mutation.
  7688. func (m *ContactMutation) V3() (r string, exists bool) {
  7689. v := m.v3
  7690. if v == nil {
  7691. return
  7692. }
  7693. return *v, true
  7694. }
  7695. // OldV3 returns the old "v3" field's value of the Contact entity.
  7696. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7698. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  7699. if !m.op.Is(OpUpdateOne) {
  7700. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  7701. }
  7702. if m.id == nil || m.oldValue == nil {
  7703. return v, errors.New("OldV3 requires an ID field in the mutation")
  7704. }
  7705. oldValue, err := m.oldValue(ctx)
  7706. if err != nil {
  7707. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  7708. }
  7709. return oldValue.V3, nil
  7710. }
  7711. // ResetV3 resets all changes to the "v3" field.
  7712. func (m *ContactMutation) ResetV3() {
  7713. m.v3 = nil
  7714. }
  7715. // SetOrganizationID sets the "organization_id" field.
  7716. func (m *ContactMutation) SetOrganizationID(u uint64) {
  7717. m.organization_id = &u
  7718. m.addorganization_id = nil
  7719. }
  7720. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7721. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  7722. v := m.organization_id
  7723. if v == nil {
  7724. return
  7725. }
  7726. return *v, true
  7727. }
  7728. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  7729. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7731. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7732. if !m.op.Is(OpUpdateOne) {
  7733. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7734. }
  7735. if m.id == nil || m.oldValue == nil {
  7736. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7737. }
  7738. oldValue, err := m.oldValue(ctx)
  7739. if err != nil {
  7740. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7741. }
  7742. return oldValue.OrganizationID, nil
  7743. }
  7744. // AddOrganizationID adds u to the "organization_id" field.
  7745. func (m *ContactMutation) AddOrganizationID(u int64) {
  7746. if m.addorganization_id != nil {
  7747. *m.addorganization_id += u
  7748. } else {
  7749. m.addorganization_id = &u
  7750. }
  7751. }
  7752. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7753. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  7754. v := m.addorganization_id
  7755. if v == nil {
  7756. return
  7757. }
  7758. return *v, true
  7759. }
  7760. // ClearOrganizationID clears the value of the "organization_id" field.
  7761. func (m *ContactMutation) ClearOrganizationID() {
  7762. m.organization_id = nil
  7763. m.addorganization_id = nil
  7764. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  7765. }
  7766. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7767. func (m *ContactMutation) OrganizationIDCleared() bool {
  7768. _, ok := m.clearedFields[contact.FieldOrganizationID]
  7769. return ok
  7770. }
  7771. // ResetOrganizationID resets all changes to the "organization_id" field.
  7772. func (m *ContactMutation) ResetOrganizationID() {
  7773. m.organization_id = nil
  7774. m.addorganization_id = nil
  7775. delete(m.clearedFields, contact.FieldOrganizationID)
  7776. }
  7777. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  7778. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  7779. if m.contact_relationships == nil {
  7780. m.contact_relationships = make(map[uint64]struct{})
  7781. }
  7782. for i := range ids {
  7783. m.contact_relationships[ids[i]] = struct{}{}
  7784. }
  7785. }
  7786. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  7787. func (m *ContactMutation) ClearContactRelationships() {
  7788. m.clearedcontact_relationships = true
  7789. }
  7790. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  7791. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  7792. return m.clearedcontact_relationships
  7793. }
  7794. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  7795. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  7796. if m.removedcontact_relationships == nil {
  7797. m.removedcontact_relationships = make(map[uint64]struct{})
  7798. }
  7799. for i := range ids {
  7800. delete(m.contact_relationships, ids[i])
  7801. m.removedcontact_relationships[ids[i]] = struct{}{}
  7802. }
  7803. }
  7804. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  7805. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  7806. for id := range m.removedcontact_relationships {
  7807. ids = append(ids, id)
  7808. }
  7809. return
  7810. }
  7811. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  7812. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  7813. for id := range m.contact_relationships {
  7814. ids = append(ids, id)
  7815. }
  7816. return
  7817. }
  7818. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  7819. func (m *ContactMutation) ResetContactRelationships() {
  7820. m.contact_relationships = nil
  7821. m.clearedcontact_relationships = false
  7822. m.removedcontact_relationships = nil
  7823. }
  7824. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  7825. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  7826. if m.contact_messages == nil {
  7827. m.contact_messages = make(map[uint64]struct{})
  7828. }
  7829. for i := range ids {
  7830. m.contact_messages[ids[i]] = struct{}{}
  7831. }
  7832. }
  7833. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  7834. func (m *ContactMutation) ClearContactMessages() {
  7835. m.clearedcontact_messages = true
  7836. }
  7837. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  7838. func (m *ContactMutation) ContactMessagesCleared() bool {
  7839. return m.clearedcontact_messages
  7840. }
  7841. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  7842. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  7843. if m.removedcontact_messages == nil {
  7844. m.removedcontact_messages = make(map[uint64]struct{})
  7845. }
  7846. for i := range ids {
  7847. delete(m.contact_messages, ids[i])
  7848. m.removedcontact_messages[ids[i]] = struct{}{}
  7849. }
  7850. }
  7851. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  7852. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  7853. for id := range m.removedcontact_messages {
  7854. ids = append(ids, id)
  7855. }
  7856. return
  7857. }
  7858. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  7859. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  7860. for id := range m.contact_messages {
  7861. ids = append(ids, id)
  7862. }
  7863. return
  7864. }
  7865. // ResetContactMessages resets all changes to the "contact_messages" edge.
  7866. func (m *ContactMutation) ResetContactMessages() {
  7867. m.contact_messages = nil
  7868. m.clearedcontact_messages = false
  7869. m.removedcontact_messages = nil
  7870. }
  7871. // Where appends a list predicates to the ContactMutation builder.
  7872. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  7873. m.predicates = append(m.predicates, ps...)
  7874. }
  7875. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  7876. // users can use type-assertion to append predicates that do not depend on any generated package.
  7877. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  7878. p := make([]predicate.Contact, len(ps))
  7879. for i := range ps {
  7880. p[i] = ps[i]
  7881. }
  7882. m.Where(p...)
  7883. }
  7884. // Op returns the operation name.
  7885. func (m *ContactMutation) Op() Op {
  7886. return m.op
  7887. }
  7888. // SetOp allows setting the mutation operation.
  7889. func (m *ContactMutation) SetOp(op Op) {
  7890. m.op = op
  7891. }
  7892. // Type returns the node type of this mutation (Contact).
  7893. func (m *ContactMutation) Type() string {
  7894. return m.typ
  7895. }
  7896. // Fields returns all fields that were changed during this mutation. Note that in
  7897. // order to get all numeric fields that were incremented/decremented, call
  7898. // AddedFields().
  7899. func (m *ContactMutation) Fields() []string {
  7900. fields := make([]string, 0, 20)
  7901. if m.created_at != nil {
  7902. fields = append(fields, contact.FieldCreatedAt)
  7903. }
  7904. if m.updated_at != nil {
  7905. fields = append(fields, contact.FieldUpdatedAt)
  7906. }
  7907. if m.status != nil {
  7908. fields = append(fields, contact.FieldStatus)
  7909. }
  7910. if m.deleted_at != nil {
  7911. fields = append(fields, contact.FieldDeletedAt)
  7912. }
  7913. if m.wx_wxid != nil {
  7914. fields = append(fields, contact.FieldWxWxid)
  7915. }
  7916. if m._type != nil {
  7917. fields = append(fields, contact.FieldType)
  7918. }
  7919. if m.wxid != nil {
  7920. fields = append(fields, contact.FieldWxid)
  7921. }
  7922. if m.account != nil {
  7923. fields = append(fields, contact.FieldAccount)
  7924. }
  7925. if m.nickname != nil {
  7926. fields = append(fields, contact.FieldNickname)
  7927. }
  7928. if m.markname != nil {
  7929. fields = append(fields, contact.FieldMarkname)
  7930. }
  7931. if m.headimg != nil {
  7932. fields = append(fields, contact.FieldHeadimg)
  7933. }
  7934. if m.sex != nil {
  7935. fields = append(fields, contact.FieldSex)
  7936. }
  7937. if m.starrole != nil {
  7938. fields = append(fields, contact.FieldStarrole)
  7939. }
  7940. if m.dontseeit != nil {
  7941. fields = append(fields, contact.FieldDontseeit)
  7942. }
  7943. if m.dontseeme != nil {
  7944. fields = append(fields, contact.FieldDontseeme)
  7945. }
  7946. if m.lag != nil {
  7947. fields = append(fields, contact.FieldLag)
  7948. }
  7949. if m.gid != nil {
  7950. fields = append(fields, contact.FieldGid)
  7951. }
  7952. if m.gname != nil {
  7953. fields = append(fields, contact.FieldGname)
  7954. }
  7955. if m.v3 != nil {
  7956. fields = append(fields, contact.FieldV3)
  7957. }
  7958. if m.organization_id != nil {
  7959. fields = append(fields, contact.FieldOrganizationID)
  7960. }
  7961. return fields
  7962. }
  7963. // Field returns the value of a field with the given name. The second boolean
  7964. // return value indicates that this field was not set, or was not defined in the
  7965. // schema.
  7966. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  7967. switch name {
  7968. case contact.FieldCreatedAt:
  7969. return m.CreatedAt()
  7970. case contact.FieldUpdatedAt:
  7971. return m.UpdatedAt()
  7972. case contact.FieldStatus:
  7973. return m.Status()
  7974. case contact.FieldDeletedAt:
  7975. return m.DeletedAt()
  7976. case contact.FieldWxWxid:
  7977. return m.WxWxid()
  7978. case contact.FieldType:
  7979. return m.GetType()
  7980. case contact.FieldWxid:
  7981. return m.Wxid()
  7982. case contact.FieldAccount:
  7983. return m.Account()
  7984. case contact.FieldNickname:
  7985. return m.Nickname()
  7986. case contact.FieldMarkname:
  7987. return m.Markname()
  7988. case contact.FieldHeadimg:
  7989. return m.Headimg()
  7990. case contact.FieldSex:
  7991. return m.Sex()
  7992. case contact.FieldStarrole:
  7993. return m.Starrole()
  7994. case contact.FieldDontseeit:
  7995. return m.Dontseeit()
  7996. case contact.FieldDontseeme:
  7997. return m.Dontseeme()
  7998. case contact.FieldLag:
  7999. return m.Lag()
  8000. case contact.FieldGid:
  8001. return m.Gid()
  8002. case contact.FieldGname:
  8003. return m.Gname()
  8004. case contact.FieldV3:
  8005. return m.V3()
  8006. case contact.FieldOrganizationID:
  8007. return m.OrganizationID()
  8008. }
  8009. return nil, false
  8010. }
  8011. // OldField returns the old value of the field from the database. An error is
  8012. // returned if the mutation operation is not UpdateOne, or the query to the
  8013. // database failed.
  8014. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8015. switch name {
  8016. case contact.FieldCreatedAt:
  8017. return m.OldCreatedAt(ctx)
  8018. case contact.FieldUpdatedAt:
  8019. return m.OldUpdatedAt(ctx)
  8020. case contact.FieldStatus:
  8021. return m.OldStatus(ctx)
  8022. case contact.FieldDeletedAt:
  8023. return m.OldDeletedAt(ctx)
  8024. case contact.FieldWxWxid:
  8025. return m.OldWxWxid(ctx)
  8026. case contact.FieldType:
  8027. return m.OldType(ctx)
  8028. case contact.FieldWxid:
  8029. return m.OldWxid(ctx)
  8030. case contact.FieldAccount:
  8031. return m.OldAccount(ctx)
  8032. case contact.FieldNickname:
  8033. return m.OldNickname(ctx)
  8034. case contact.FieldMarkname:
  8035. return m.OldMarkname(ctx)
  8036. case contact.FieldHeadimg:
  8037. return m.OldHeadimg(ctx)
  8038. case contact.FieldSex:
  8039. return m.OldSex(ctx)
  8040. case contact.FieldStarrole:
  8041. return m.OldStarrole(ctx)
  8042. case contact.FieldDontseeit:
  8043. return m.OldDontseeit(ctx)
  8044. case contact.FieldDontseeme:
  8045. return m.OldDontseeme(ctx)
  8046. case contact.FieldLag:
  8047. return m.OldLag(ctx)
  8048. case contact.FieldGid:
  8049. return m.OldGid(ctx)
  8050. case contact.FieldGname:
  8051. return m.OldGname(ctx)
  8052. case contact.FieldV3:
  8053. return m.OldV3(ctx)
  8054. case contact.FieldOrganizationID:
  8055. return m.OldOrganizationID(ctx)
  8056. }
  8057. return nil, fmt.Errorf("unknown Contact field %s", name)
  8058. }
  8059. // SetField sets the value of a field with the given name. It returns an error if
  8060. // the field is not defined in the schema, or if the type mismatched the field
  8061. // type.
  8062. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8063. switch name {
  8064. case contact.FieldCreatedAt:
  8065. v, ok := value.(time.Time)
  8066. if !ok {
  8067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8068. }
  8069. m.SetCreatedAt(v)
  8070. return nil
  8071. case contact.FieldUpdatedAt:
  8072. v, ok := value.(time.Time)
  8073. if !ok {
  8074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8075. }
  8076. m.SetUpdatedAt(v)
  8077. return nil
  8078. case contact.FieldStatus:
  8079. v, ok := value.(uint8)
  8080. if !ok {
  8081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8082. }
  8083. m.SetStatus(v)
  8084. return nil
  8085. case contact.FieldDeletedAt:
  8086. v, ok := value.(time.Time)
  8087. if !ok {
  8088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8089. }
  8090. m.SetDeletedAt(v)
  8091. return nil
  8092. case contact.FieldWxWxid:
  8093. v, ok := value.(string)
  8094. if !ok {
  8095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8096. }
  8097. m.SetWxWxid(v)
  8098. return nil
  8099. case contact.FieldType:
  8100. v, ok := value.(int)
  8101. if !ok {
  8102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8103. }
  8104. m.SetType(v)
  8105. return nil
  8106. case contact.FieldWxid:
  8107. v, ok := value.(string)
  8108. if !ok {
  8109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8110. }
  8111. m.SetWxid(v)
  8112. return nil
  8113. case contact.FieldAccount:
  8114. v, ok := value.(string)
  8115. if !ok {
  8116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8117. }
  8118. m.SetAccount(v)
  8119. return nil
  8120. case contact.FieldNickname:
  8121. v, ok := value.(string)
  8122. if !ok {
  8123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8124. }
  8125. m.SetNickname(v)
  8126. return nil
  8127. case contact.FieldMarkname:
  8128. v, ok := value.(string)
  8129. if !ok {
  8130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8131. }
  8132. m.SetMarkname(v)
  8133. return nil
  8134. case contact.FieldHeadimg:
  8135. v, ok := value.(string)
  8136. if !ok {
  8137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8138. }
  8139. m.SetHeadimg(v)
  8140. return nil
  8141. case contact.FieldSex:
  8142. v, ok := value.(int)
  8143. if !ok {
  8144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8145. }
  8146. m.SetSex(v)
  8147. return nil
  8148. case contact.FieldStarrole:
  8149. v, ok := value.(string)
  8150. if !ok {
  8151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8152. }
  8153. m.SetStarrole(v)
  8154. return nil
  8155. case contact.FieldDontseeit:
  8156. v, ok := value.(int)
  8157. if !ok {
  8158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8159. }
  8160. m.SetDontseeit(v)
  8161. return nil
  8162. case contact.FieldDontseeme:
  8163. v, ok := value.(int)
  8164. if !ok {
  8165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8166. }
  8167. m.SetDontseeme(v)
  8168. return nil
  8169. case contact.FieldLag:
  8170. v, ok := value.(string)
  8171. if !ok {
  8172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8173. }
  8174. m.SetLag(v)
  8175. return nil
  8176. case contact.FieldGid:
  8177. v, ok := value.(string)
  8178. if !ok {
  8179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8180. }
  8181. m.SetGid(v)
  8182. return nil
  8183. case contact.FieldGname:
  8184. v, ok := value.(string)
  8185. if !ok {
  8186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8187. }
  8188. m.SetGname(v)
  8189. return nil
  8190. case contact.FieldV3:
  8191. v, ok := value.(string)
  8192. if !ok {
  8193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8194. }
  8195. m.SetV3(v)
  8196. return nil
  8197. case contact.FieldOrganizationID:
  8198. v, ok := value.(uint64)
  8199. if !ok {
  8200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8201. }
  8202. m.SetOrganizationID(v)
  8203. return nil
  8204. }
  8205. return fmt.Errorf("unknown Contact field %s", name)
  8206. }
  8207. // AddedFields returns all numeric fields that were incremented/decremented during
  8208. // this mutation.
  8209. func (m *ContactMutation) AddedFields() []string {
  8210. var fields []string
  8211. if m.addstatus != nil {
  8212. fields = append(fields, contact.FieldStatus)
  8213. }
  8214. if m.add_type != nil {
  8215. fields = append(fields, contact.FieldType)
  8216. }
  8217. if m.addsex != nil {
  8218. fields = append(fields, contact.FieldSex)
  8219. }
  8220. if m.adddontseeit != nil {
  8221. fields = append(fields, contact.FieldDontseeit)
  8222. }
  8223. if m.adddontseeme != nil {
  8224. fields = append(fields, contact.FieldDontseeme)
  8225. }
  8226. if m.addorganization_id != nil {
  8227. fields = append(fields, contact.FieldOrganizationID)
  8228. }
  8229. return fields
  8230. }
  8231. // AddedField returns the numeric value that was incremented/decremented on a field
  8232. // with the given name. The second boolean return value indicates that this field
  8233. // was not set, or was not defined in the schema.
  8234. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8235. switch name {
  8236. case contact.FieldStatus:
  8237. return m.AddedStatus()
  8238. case contact.FieldType:
  8239. return m.AddedType()
  8240. case contact.FieldSex:
  8241. return m.AddedSex()
  8242. case contact.FieldDontseeit:
  8243. return m.AddedDontseeit()
  8244. case contact.FieldDontseeme:
  8245. return m.AddedDontseeme()
  8246. case contact.FieldOrganizationID:
  8247. return m.AddedOrganizationID()
  8248. }
  8249. return nil, false
  8250. }
  8251. // AddField adds the value to the field with the given name. It returns an error if
  8252. // the field is not defined in the schema, or if the type mismatched the field
  8253. // type.
  8254. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  8255. switch name {
  8256. case contact.FieldStatus:
  8257. v, ok := value.(int8)
  8258. if !ok {
  8259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8260. }
  8261. m.AddStatus(v)
  8262. return nil
  8263. case contact.FieldType:
  8264. v, ok := value.(int)
  8265. if !ok {
  8266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8267. }
  8268. m.AddType(v)
  8269. return nil
  8270. case contact.FieldSex:
  8271. v, ok := value.(int)
  8272. if !ok {
  8273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8274. }
  8275. m.AddSex(v)
  8276. return nil
  8277. case contact.FieldDontseeit:
  8278. v, ok := value.(int)
  8279. if !ok {
  8280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8281. }
  8282. m.AddDontseeit(v)
  8283. return nil
  8284. case contact.FieldDontseeme:
  8285. v, ok := value.(int)
  8286. if !ok {
  8287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8288. }
  8289. m.AddDontseeme(v)
  8290. return nil
  8291. case contact.FieldOrganizationID:
  8292. v, ok := value.(int64)
  8293. if !ok {
  8294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8295. }
  8296. m.AddOrganizationID(v)
  8297. return nil
  8298. }
  8299. return fmt.Errorf("unknown Contact numeric field %s", name)
  8300. }
  8301. // ClearedFields returns all nullable fields that were cleared during this
  8302. // mutation.
  8303. func (m *ContactMutation) ClearedFields() []string {
  8304. var fields []string
  8305. if m.FieldCleared(contact.FieldStatus) {
  8306. fields = append(fields, contact.FieldStatus)
  8307. }
  8308. if m.FieldCleared(contact.FieldDeletedAt) {
  8309. fields = append(fields, contact.FieldDeletedAt)
  8310. }
  8311. if m.FieldCleared(contact.FieldType) {
  8312. fields = append(fields, contact.FieldType)
  8313. }
  8314. if m.FieldCleared(contact.FieldOrganizationID) {
  8315. fields = append(fields, contact.FieldOrganizationID)
  8316. }
  8317. return fields
  8318. }
  8319. // FieldCleared returns a boolean indicating if a field with the given name was
  8320. // cleared in this mutation.
  8321. func (m *ContactMutation) FieldCleared(name string) bool {
  8322. _, ok := m.clearedFields[name]
  8323. return ok
  8324. }
  8325. // ClearField clears the value of the field with the given name. It returns an
  8326. // error if the field is not defined in the schema.
  8327. func (m *ContactMutation) ClearField(name string) error {
  8328. switch name {
  8329. case contact.FieldStatus:
  8330. m.ClearStatus()
  8331. return nil
  8332. case contact.FieldDeletedAt:
  8333. m.ClearDeletedAt()
  8334. return nil
  8335. case contact.FieldType:
  8336. m.ClearType()
  8337. return nil
  8338. case contact.FieldOrganizationID:
  8339. m.ClearOrganizationID()
  8340. return nil
  8341. }
  8342. return fmt.Errorf("unknown Contact nullable field %s", name)
  8343. }
  8344. // ResetField resets all changes in the mutation for the field with the given name.
  8345. // It returns an error if the field is not defined in the schema.
  8346. func (m *ContactMutation) ResetField(name string) error {
  8347. switch name {
  8348. case contact.FieldCreatedAt:
  8349. m.ResetCreatedAt()
  8350. return nil
  8351. case contact.FieldUpdatedAt:
  8352. m.ResetUpdatedAt()
  8353. return nil
  8354. case contact.FieldStatus:
  8355. m.ResetStatus()
  8356. return nil
  8357. case contact.FieldDeletedAt:
  8358. m.ResetDeletedAt()
  8359. return nil
  8360. case contact.FieldWxWxid:
  8361. m.ResetWxWxid()
  8362. return nil
  8363. case contact.FieldType:
  8364. m.ResetType()
  8365. return nil
  8366. case contact.FieldWxid:
  8367. m.ResetWxid()
  8368. return nil
  8369. case contact.FieldAccount:
  8370. m.ResetAccount()
  8371. return nil
  8372. case contact.FieldNickname:
  8373. m.ResetNickname()
  8374. return nil
  8375. case contact.FieldMarkname:
  8376. m.ResetMarkname()
  8377. return nil
  8378. case contact.FieldHeadimg:
  8379. m.ResetHeadimg()
  8380. return nil
  8381. case contact.FieldSex:
  8382. m.ResetSex()
  8383. return nil
  8384. case contact.FieldStarrole:
  8385. m.ResetStarrole()
  8386. return nil
  8387. case contact.FieldDontseeit:
  8388. m.ResetDontseeit()
  8389. return nil
  8390. case contact.FieldDontseeme:
  8391. m.ResetDontseeme()
  8392. return nil
  8393. case contact.FieldLag:
  8394. m.ResetLag()
  8395. return nil
  8396. case contact.FieldGid:
  8397. m.ResetGid()
  8398. return nil
  8399. case contact.FieldGname:
  8400. m.ResetGname()
  8401. return nil
  8402. case contact.FieldV3:
  8403. m.ResetV3()
  8404. return nil
  8405. case contact.FieldOrganizationID:
  8406. m.ResetOrganizationID()
  8407. return nil
  8408. }
  8409. return fmt.Errorf("unknown Contact field %s", name)
  8410. }
  8411. // AddedEdges returns all edge names that were set/added in this mutation.
  8412. func (m *ContactMutation) AddedEdges() []string {
  8413. edges := make([]string, 0, 2)
  8414. if m.contact_relationships != nil {
  8415. edges = append(edges, contact.EdgeContactRelationships)
  8416. }
  8417. if m.contact_messages != nil {
  8418. edges = append(edges, contact.EdgeContactMessages)
  8419. }
  8420. return edges
  8421. }
  8422. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8423. // name in this mutation.
  8424. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  8425. switch name {
  8426. case contact.EdgeContactRelationships:
  8427. ids := make([]ent.Value, 0, len(m.contact_relationships))
  8428. for id := range m.contact_relationships {
  8429. ids = append(ids, id)
  8430. }
  8431. return ids
  8432. case contact.EdgeContactMessages:
  8433. ids := make([]ent.Value, 0, len(m.contact_messages))
  8434. for id := range m.contact_messages {
  8435. ids = append(ids, id)
  8436. }
  8437. return ids
  8438. }
  8439. return nil
  8440. }
  8441. // RemovedEdges returns all edge names that were removed in this mutation.
  8442. func (m *ContactMutation) RemovedEdges() []string {
  8443. edges := make([]string, 0, 2)
  8444. if m.removedcontact_relationships != nil {
  8445. edges = append(edges, contact.EdgeContactRelationships)
  8446. }
  8447. if m.removedcontact_messages != nil {
  8448. edges = append(edges, contact.EdgeContactMessages)
  8449. }
  8450. return edges
  8451. }
  8452. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8453. // the given name in this mutation.
  8454. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  8455. switch name {
  8456. case contact.EdgeContactRelationships:
  8457. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  8458. for id := range m.removedcontact_relationships {
  8459. ids = append(ids, id)
  8460. }
  8461. return ids
  8462. case contact.EdgeContactMessages:
  8463. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  8464. for id := range m.removedcontact_messages {
  8465. ids = append(ids, id)
  8466. }
  8467. return ids
  8468. }
  8469. return nil
  8470. }
  8471. // ClearedEdges returns all edge names that were cleared in this mutation.
  8472. func (m *ContactMutation) ClearedEdges() []string {
  8473. edges := make([]string, 0, 2)
  8474. if m.clearedcontact_relationships {
  8475. edges = append(edges, contact.EdgeContactRelationships)
  8476. }
  8477. if m.clearedcontact_messages {
  8478. edges = append(edges, contact.EdgeContactMessages)
  8479. }
  8480. return edges
  8481. }
  8482. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8483. // was cleared in this mutation.
  8484. func (m *ContactMutation) EdgeCleared(name string) bool {
  8485. switch name {
  8486. case contact.EdgeContactRelationships:
  8487. return m.clearedcontact_relationships
  8488. case contact.EdgeContactMessages:
  8489. return m.clearedcontact_messages
  8490. }
  8491. return false
  8492. }
  8493. // ClearEdge clears the value of the edge with the given name. It returns an error
  8494. // if that edge is not defined in the schema.
  8495. func (m *ContactMutation) ClearEdge(name string) error {
  8496. switch name {
  8497. }
  8498. return fmt.Errorf("unknown Contact unique edge %s", name)
  8499. }
  8500. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8501. // It returns an error if the edge is not defined in the schema.
  8502. func (m *ContactMutation) ResetEdge(name string) error {
  8503. switch name {
  8504. case contact.EdgeContactRelationships:
  8505. m.ResetContactRelationships()
  8506. return nil
  8507. case contact.EdgeContactMessages:
  8508. m.ResetContactMessages()
  8509. return nil
  8510. }
  8511. return fmt.Errorf("unknown Contact edge %s", name)
  8512. }
  8513. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  8514. type EmployeeMutation struct {
  8515. config
  8516. op Op
  8517. typ string
  8518. id *uint64
  8519. created_at *time.Time
  8520. updated_at *time.Time
  8521. deleted_at *time.Time
  8522. title *string
  8523. avatar *string
  8524. tags *string
  8525. hire_count *int
  8526. addhire_count *int
  8527. service_count *int
  8528. addservice_count *int
  8529. achievement_count *int
  8530. addachievement_count *int
  8531. intro *string
  8532. estimate *string
  8533. skill *string
  8534. ability_type *string
  8535. scene *string
  8536. switch_in *string
  8537. video_url *string
  8538. organization_id *uint64
  8539. addorganization_id *int64
  8540. category_id *uint64
  8541. addcategory_id *int64
  8542. api_base *string
  8543. api_key *string
  8544. ai_info *string
  8545. is_vip *int
  8546. addis_vip *int
  8547. chat_url *string
  8548. clearedFields map[string]struct{}
  8549. em_work_experiences map[uint64]struct{}
  8550. removedem_work_experiences map[uint64]struct{}
  8551. clearedem_work_experiences bool
  8552. em_tutorial map[uint64]struct{}
  8553. removedem_tutorial map[uint64]struct{}
  8554. clearedem_tutorial bool
  8555. done bool
  8556. oldValue func(context.Context) (*Employee, error)
  8557. predicates []predicate.Employee
  8558. }
  8559. var _ ent.Mutation = (*EmployeeMutation)(nil)
  8560. // employeeOption allows management of the mutation configuration using functional options.
  8561. type employeeOption func(*EmployeeMutation)
  8562. // newEmployeeMutation creates new mutation for the Employee entity.
  8563. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  8564. m := &EmployeeMutation{
  8565. config: c,
  8566. op: op,
  8567. typ: TypeEmployee,
  8568. clearedFields: make(map[string]struct{}),
  8569. }
  8570. for _, opt := range opts {
  8571. opt(m)
  8572. }
  8573. return m
  8574. }
  8575. // withEmployeeID sets the ID field of the mutation.
  8576. func withEmployeeID(id uint64) employeeOption {
  8577. return func(m *EmployeeMutation) {
  8578. var (
  8579. err error
  8580. once sync.Once
  8581. value *Employee
  8582. )
  8583. m.oldValue = func(ctx context.Context) (*Employee, error) {
  8584. once.Do(func() {
  8585. if m.done {
  8586. err = errors.New("querying old values post mutation is not allowed")
  8587. } else {
  8588. value, err = m.Client().Employee.Get(ctx, id)
  8589. }
  8590. })
  8591. return value, err
  8592. }
  8593. m.id = &id
  8594. }
  8595. }
  8596. // withEmployee sets the old Employee of the mutation.
  8597. func withEmployee(node *Employee) employeeOption {
  8598. return func(m *EmployeeMutation) {
  8599. m.oldValue = func(context.Context) (*Employee, error) {
  8600. return node, nil
  8601. }
  8602. m.id = &node.ID
  8603. }
  8604. }
  8605. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8606. // executed in a transaction (ent.Tx), a transactional client is returned.
  8607. func (m EmployeeMutation) Client() *Client {
  8608. client := &Client{config: m.config}
  8609. client.init()
  8610. return client
  8611. }
  8612. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8613. // it returns an error otherwise.
  8614. func (m EmployeeMutation) Tx() (*Tx, error) {
  8615. if _, ok := m.driver.(*txDriver); !ok {
  8616. return nil, errors.New("ent: mutation is not running in a transaction")
  8617. }
  8618. tx := &Tx{config: m.config}
  8619. tx.init()
  8620. return tx, nil
  8621. }
  8622. // SetID sets the value of the id field. Note that this
  8623. // operation is only accepted on creation of Employee entities.
  8624. func (m *EmployeeMutation) SetID(id uint64) {
  8625. m.id = &id
  8626. }
  8627. // ID returns the ID value in the mutation. Note that the ID is only available
  8628. // if it was provided to the builder or after it was returned from the database.
  8629. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  8630. if m.id == nil {
  8631. return
  8632. }
  8633. return *m.id, true
  8634. }
  8635. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8636. // That means, if the mutation is applied within a transaction with an isolation level such
  8637. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8638. // or updated by the mutation.
  8639. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8640. switch {
  8641. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8642. id, exists := m.ID()
  8643. if exists {
  8644. return []uint64{id}, nil
  8645. }
  8646. fallthrough
  8647. case m.op.Is(OpUpdate | OpDelete):
  8648. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  8649. default:
  8650. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8651. }
  8652. }
  8653. // SetCreatedAt sets the "created_at" field.
  8654. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  8655. m.created_at = &t
  8656. }
  8657. // CreatedAt returns the value of the "created_at" field in the mutation.
  8658. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  8659. v := m.created_at
  8660. if v == nil {
  8661. return
  8662. }
  8663. return *v, true
  8664. }
  8665. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  8666. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8668. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8669. if !m.op.Is(OpUpdateOne) {
  8670. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8671. }
  8672. if m.id == nil || m.oldValue == nil {
  8673. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8674. }
  8675. oldValue, err := m.oldValue(ctx)
  8676. if err != nil {
  8677. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8678. }
  8679. return oldValue.CreatedAt, nil
  8680. }
  8681. // ResetCreatedAt resets all changes to the "created_at" field.
  8682. func (m *EmployeeMutation) ResetCreatedAt() {
  8683. m.created_at = nil
  8684. }
  8685. // SetUpdatedAt sets the "updated_at" field.
  8686. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  8687. m.updated_at = &t
  8688. }
  8689. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8690. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  8691. v := m.updated_at
  8692. if v == nil {
  8693. return
  8694. }
  8695. return *v, true
  8696. }
  8697. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  8698. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8700. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8701. if !m.op.Is(OpUpdateOne) {
  8702. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8703. }
  8704. if m.id == nil || m.oldValue == nil {
  8705. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8706. }
  8707. oldValue, err := m.oldValue(ctx)
  8708. if err != nil {
  8709. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8710. }
  8711. return oldValue.UpdatedAt, nil
  8712. }
  8713. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8714. func (m *EmployeeMutation) ResetUpdatedAt() {
  8715. m.updated_at = nil
  8716. }
  8717. // SetDeletedAt sets the "deleted_at" field.
  8718. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  8719. m.deleted_at = &t
  8720. }
  8721. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8722. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  8723. v := m.deleted_at
  8724. if v == nil {
  8725. return
  8726. }
  8727. return *v, true
  8728. }
  8729. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  8730. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8732. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8733. if !m.op.Is(OpUpdateOne) {
  8734. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8735. }
  8736. if m.id == nil || m.oldValue == nil {
  8737. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8738. }
  8739. oldValue, err := m.oldValue(ctx)
  8740. if err != nil {
  8741. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8742. }
  8743. return oldValue.DeletedAt, nil
  8744. }
  8745. // ClearDeletedAt clears the value of the "deleted_at" field.
  8746. func (m *EmployeeMutation) ClearDeletedAt() {
  8747. m.deleted_at = nil
  8748. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  8749. }
  8750. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8751. func (m *EmployeeMutation) DeletedAtCleared() bool {
  8752. _, ok := m.clearedFields[employee.FieldDeletedAt]
  8753. return ok
  8754. }
  8755. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8756. func (m *EmployeeMutation) ResetDeletedAt() {
  8757. m.deleted_at = nil
  8758. delete(m.clearedFields, employee.FieldDeletedAt)
  8759. }
  8760. // SetTitle sets the "title" field.
  8761. func (m *EmployeeMutation) SetTitle(s string) {
  8762. m.title = &s
  8763. }
  8764. // Title returns the value of the "title" field in the mutation.
  8765. func (m *EmployeeMutation) Title() (r string, exists bool) {
  8766. v := m.title
  8767. if v == nil {
  8768. return
  8769. }
  8770. return *v, true
  8771. }
  8772. // OldTitle returns the old "title" field's value of the Employee entity.
  8773. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8775. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  8776. if !m.op.Is(OpUpdateOne) {
  8777. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  8778. }
  8779. if m.id == nil || m.oldValue == nil {
  8780. return v, errors.New("OldTitle requires an ID field in the mutation")
  8781. }
  8782. oldValue, err := m.oldValue(ctx)
  8783. if err != nil {
  8784. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  8785. }
  8786. return oldValue.Title, nil
  8787. }
  8788. // ResetTitle resets all changes to the "title" field.
  8789. func (m *EmployeeMutation) ResetTitle() {
  8790. m.title = nil
  8791. }
  8792. // SetAvatar sets the "avatar" field.
  8793. func (m *EmployeeMutation) SetAvatar(s string) {
  8794. m.avatar = &s
  8795. }
  8796. // Avatar returns the value of the "avatar" field in the mutation.
  8797. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  8798. v := m.avatar
  8799. if v == nil {
  8800. return
  8801. }
  8802. return *v, true
  8803. }
  8804. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  8805. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8807. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  8808. if !m.op.Is(OpUpdateOne) {
  8809. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  8810. }
  8811. if m.id == nil || m.oldValue == nil {
  8812. return v, errors.New("OldAvatar requires an ID field in the mutation")
  8813. }
  8814. oldValue, err := m.oldValue(ctx)
  8815. if err != nil {
  8816. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  8817. }
  8818. return oldValue.Avatar, nil
  8819. }
  8820. // ResetAvatar resets all changes to the "avatar" field.
  8821. func (m *EmployeeMutation) ResetAvatar() {
  8822. m.avatar = nil
  8823. }
  8824. // SetTags sets the "tags" field.
  8825. func (m *EmployeeMutation) SetTags(s string) {
  8826. m.tags = &s
  8827. }
  8828. // Tags returns the value of the "tags" field in the mutation.
  8829. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  8830. v := m.tags
  8831. if v == nil {
  8832. return
  8833. }
  8834. return *v, true
  8835. }
  8836. // OldTags returns the old "tags" field's value of the Employee entity.
  8837. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8839. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  8840. if !m.op.Is(OpUpdateOne) {
  8841. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  8842. }
  8843. if m.id == nil || m.oldValue == nil {
  8844. return v, errors.New("OldTags requires an ID field in the mutation")
  8845. }
  8846. oldValue, err := m.oldValue(ctx)
  8847. if err != nil {
  8848. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  8849. }
  8850. return oldValue.Tags, nil
  8851. }
  8852. // ResetTags resets all changes to the "tags" field.
  8853. func (m *EmployeeMutation) ResetTags() {
  8854. m.tags = nil
  8855. }
  8856. // SetHireCount sets the "hire_count" field.
  8857. func (m *EmployeeMutation) SetHireCount(i int) {
  8858. m.hire_count = &i
  8859. m.addhire_count = nil
  8860. }
  8861. // HireCount returns the value of the "hire_count" field in the mutation.
  8862. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  8863. v := m.hire_count
  8864. if v == nil {
  8865. return
  8866. }
  8867. return *v, true
  8868. }
  8869. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  8870. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8872. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  8873. if !m.op.Is(OpUpdateOne) {
  8874. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  8875. }
  8876. if m.id == nil || m.oldValue == nil {
  8877. return v, errors.New("OldHireCount requires an ID field in the mutation")
  8878. }
  8879. oldValue, err := m.oldValue(ctx)
  8880. if err != nil {
  8881. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  8882. }
  8883. return oldValue.HireCount, nil
  8884. }
  8885. // AddHireCount adds i to the "hire_count" field.
  8886. func (m *EmployeeMutation) AddHireCount(i int) {
  8887. if m.addhire_count != nil {
  8888. *m.addhire_count += i
  8889. } else {
  8890. m.addhire_count = &i
  8891. }
  8892. }
  8893. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  8894. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  8895. v := m.addhire_count
  8896. if v == nil {
  8897. return
  8898. }
  8899. return *v, true
  8900. }
  8901. // ResetHireCount resets all changes to the "hire_count" field.
  8902. func (m *EmployeeMutation) ResetHireCount() {
  8903. m.hire_count = nil
  8904. m.addhire_count = nil
  8905. }
  8906. // SetServiceCount sets the "service_count" field.
  8907. func (m *EmployeeMutation) SetServiceCount(i int) {
  8908. m.service_count = &i
  8909. m.addservice_count = nil
  8910. }
  8911. // ServiceCount returns the value of the "service_count" field in the mutation.
  8912. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  8913. v := m.service_count
  8914. if v == nil {
  8915. return
  8916. }
  8917. return *v, true
  8918. }
  8919. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  8920. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8922. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  8923. if !m.op.Is(OpUpdateOne) {
  8924. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  8925. }
  8926. if m.id == nil || m.oldValue == nil {
  8927. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  8928. }
  8929. oldValue, err := m.oldValue(ctx)
  8930. if err != nil {
  8931. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  8932. }
  8933. return oldValue.ServiceCount, nil
  8934. }
  8935. // AddServiceCount adds i to the "service_count" field.
  8936. func (m *EmployeeMutation) AddServiceCount(i int) {
  8937. if m.addservice_count != nil {
  8938. *m.addservice_count += i
  8939. } else {
  8940. m.addservice_count = &i
  8941. }
  8942. }
  8943. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  8944. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  8945. v := m.addservice_count
  8946. if v == nil {
  8947. return
  8948. }
  8949. return *v, true
  8950. }
  8951. // ResetServiceCount resets all changes to the "service_count" field.
  8952. func (m *EmployeeMutation) ResetServiceCount() {
  8953. m.service_count = nil
  8954. m.addservice_count = nil
  8955. }
  8956. // SetAchievementCount sets the "achievement_count" field.
  8957. func (m *EmployeeMutation) SetAchievementCount(i int) {
  8958. m.achievement_count = &i
  8959. m.addachievement_count = nil
  8960. }
  8961. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  8962. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  8963. v := m.achievement_count
  8964. if v == nil {
  8965. return
  8966. }
  8967. return *v, true
  8968. }
  8969. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  8970. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8972. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  8973. if !m.op.Is(OpUpdateOne) {
  8974. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  8975. }
  8976. if m.id == nil || m.oldValue == nil {
  8977. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  8978. }
  8979. oldValue, err := m.oldValue(ctx)
  8980. if err != nil {
  8981. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  8982. }
  8983. return oldValue.AchievementCount, nil
  8984. }
  8985. // AddAchievementCount adds i to the "achievement_count" field.
  8986. func (m *EmployeeMutation) AddAchievementCount(i int) {
  8987. if m.addachievement_count != nil {
  8988. *m.addachievement_count += i
  8989. } else {
  8990. m.addachievement_count = &i
  8991. }
  8992. }
  8993. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  8994. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  8995. v := m.addachievement_count
  8996. if v == nil {
  8997. return
  8998. }
  8999. return *v, true
  9000. }
  9001. // ResetAchievementCount resets all changes to the "achievement_count" field.
  9002. func (m *EmployeeMutation) ResetAchievementCount() {
  9003. m.achievement_count = nil
  9004. m.addachievement_count = nil
  9005. }
  9006. // SetIntro sets the "intro" field.
  9007. func (m *EmployeeMutation) SetIntro(s string) {
  9008. m.intro = &s
  9009. }
  9010. // Intro returns the value of the "intro" field in the mutation.
  9011. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  9012. v := m.intro
  9013. if v == nil {
  9014. return
  9015. }
  9016. return *v, true
  9017. }
  9018. // OldIntro returns the old "intro" field's value of the Employee entity.
  9019. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9021. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9022. if !m.op.Is(OpUpdateOne) {
  9023. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9024. }
  9025. if m.id == nil || m.oldValue == nil {
  9026. return v, errors.New("OldIntro requires an ID field in the mutation")
  9027. }
  9028. oldValue, err := m.oldValue(ctx)
  9029. if err != nil {
  9030. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9031. }
  9032. return oldValue.Intro, nil
  9033. }
  9034. // ResetIntro resets all changes to the "intro" field.
  9035. func (m *EmployeeMutation) ResetIntro() {
  9036. m.intro = nil
  9037. }
  9038. // SetEstimate sets the "estimate" field.
  9039. func (m *EmployeeMutation) SetEstimate(s string) {
  9040. m.estimate = &s
  9041. }
  9042. // Estimate returns the value of the "estimate" field in the mutation.
  9043. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9044. v := m.estimate
  9045. if v == nil {
  9046. return
  9047. }
  9048. return *v, true
  9049. }
  9050. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9051. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9053. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9054. if !m.op.Is(OpUpdateOne) {
  9055. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9056. }
  9057. if m.id == nil || m.oldValue == nil {
  9058. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9059. }
  9060. oldValue, err := m.oldValue(ctx)
  9061. if err != nil {
  9062. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9063. }
  9064. return oldValue.Estimate, nil
  9065. }
  9066. // ResetEstimate resets all changes to the "estimate" field.
  9067. func (m *EmployeeMutation) ResetEstimate() {
  9068. m.estimate = nil
  9069. }
  9070. // SetSkill sets the "skill" field.
  9071. func (m *EmployeeMutation) SetSkill(s string) {
  9072. m.skill = &s
  9073. }
  9074. // Skill returns the value of the "skill" field in the mutation.
  9075. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9076. v := m.skill
  9077. if v == nil {
  9078. return
  9079. }
  9080. return *v, true
  9081. }
  9082. // OldSkill returns the old "skill" field's value of the Employee entity.
  9083. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9085. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9086. if !m.op.Is(OpUpdateOne) {
  9087. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9088. }
  9089. if m.id == nil || m.oldValue == nil {
  9090. return v, errors.New("OldSkill requires an ID field in the mutation")
  9091. }
  9092. oldValue, err := m.oldValue(ctx)
  9093. if err != nil {
  9094. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9095. }
  9096. return oldValue.Skill, nil
  9097. }
  9098. // ResetSkill resets all changes to the "skill" field.
  9099. func (m *EmployeeMutation) ResetSkill() {
  9100. m.skill = nil
  9101. }
  9102. // SetAbilityType sets the "ability_type" field.
  9103. func (m *EmployeeMutation) SetAbilityType(s string) {
  9104. m.ability_type = &s
  9105. }
  9106. // AbilityType returns the value of the "ability_type" field in the mutation.
  9107. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9108. v := m.ability_type
  9109. if v == nil {
  9110. return
  9111. }
  9112. return *v, true
  9113. }
  9114. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9115. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9117. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9118. if !m.op.Is(OpUpdateOne) {
  9119. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9120. }
  9121. if m.id == nil || m.oldValue == nil {
  9122. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9123. }
  9124. oldValue, err := m.oldValue(ctx)
  9125. if err != nil {
  9126. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9127. }
  9128. return oldValue.AbilityType, nil
  9129. }
  9130. // ResetAbilityType resets all changes to the "ability_type" field.
  9131. func (m *EmployeeMutation) ResetAbilityType() {
  9132. m.ability_type = nil
  9133. }
  9134. // SetScene sets the "scene" field.
  9135. func (m *EmployeeMutation) SetScene(s string) {
  9136. m.scene = &s
  9137. }
  9138. // Scene returns the value of the "scene" field in the mutation.
  9139. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9140. v := m.scene
  9141. if v == nil {
  9142. return
  9143. }
  9144. return *v, true
  9145. }
  9146. // OldScene returns the old "scene" field's value of the Employee entity.
  9147. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9149. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9150. if !m.op.Is(OpUpdateOne) {
  9151. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9152. }
  9153. if m.id == nil || m.oldValue == nil {
  9154. return v, errors.New("OldScene requires an ID field in the mutation")
  9155. }
  9156. oldValue, err := m.oldValue(ctx)
  9157. if err != nil {
  9158. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9159. }
  9160. return oldValue.Scene, nil
  9161. }
  9162. // ResetScene resets all changes to the "scene" field.
  9163. func (m *EmployeeMutation) ResetScene() {
  9164. m.scene = nil
  9165. }
  9166. // SetSwitchIn sets the "switch_in" field.
  9167. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9168. m.switch_in = &s
  9169. }
  9170. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9171. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9172. v := m.switch_in
  9173. if v == nil {
  9174. return
  9175. }
  9176. return *v, true
  9177. }
  9178. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9179. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9181. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9182. if !m.op.Is(OpUpdateOne) {
  9183. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9184. }
  9185. if m.id == nil || m.oldValue == nil {
  9186. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9187. }
  9188. oldValue, err := m.oldValue(ctx)
  9189. if err != nil {
  9190. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9191. }
  9192. return oldValue.SwitchIn, nil
  9193. }
  9194. // ResetSwitchIn resets all changes to the "switch_in" field.
  9195. func (m *EmployeeMutation) ResetSwitchIn() {
  9196. m.switch_in = nil
  9197. }
  9198. // SetVideoURL sets the "video_url" field.
  9199. func (m *EmployeeMutation) SetVideoURL(s string) {
  9200. m.video_url = &s
  9201. }
  9202. // VideoURL returns the value of the "video_url" field in the mutation.
  9203. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9204. v := m.video_url
  9205. if v == nil {
  9206. return
  9207. }
  9208. return *v, true
  9209. }
  9210. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9211. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9213. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9214. if !m.op.Is(OpUpdateOne) {
  9215. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9216. }
  9217. if m.id == nil || m.oldValue == nil {
  9218. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9219. }
  9220. oldValue, err := m.oldValue(ctx)
  9221. if err != nil {
  9222. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9223. }
  9224. return oldValue.VideoURL, nil
  9225. }
  9226. // ResetVideoURL resets all changes to the "video_url" field.
  9227. func (m *EmployeeMutation) ResetVideoURL() {
  9228. m.video_url = nil
  9229. }
  9230. // SetOrganizationID sets the "organization_id" field.
  9231. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9232. m.organization_id = &u
  9233. m.addorganization_id = nil
  9234. }
  9235. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9236. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9237. v := m.organization_id
  9238. if v == nil {
  9239. return
  9240. }
  9241. return *v, true
  9242. }
  9243. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9244. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9246. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9247. if !m.op.Is(OpUpdateOne) {
  9248. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9249. }
  9250. if m.id == nil || m.oldValue == nil {
  9251. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9252. }
  9253. oldValue, err := m.oldValue(ctx)
  9254. if err != nil {
  9255. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9256. }
  9257. return oldValue.OrganizationID, nil
  9258. }
  9259. // AddOrganizationID adds u to the "organization_id" field.
  9260. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  9261. if m.addorganization_id != nil {
  9262. *m.addorganization_id += u
  9263. } else {
  9264. m.addorganization_id = &u
  9265. }
  9266. }
  9267. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9268. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  9269. v := m.addorganization_id
  9270. if v == nil {
  9271. return
  9272. }
  9273. return *v, true
  9274. }
  9275. // ResetOrganizationID resets all changes to the "organization_id" field.
  9276. func (m *EmployeeMutation) ResetOrganizationID() {
  9277. m.organization_id = nil
  9278. m.addorganization_id = nil
  9279. }
  9280. // SetCategoryID sets the "category_id" field.
  9281. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  9282. m.category_id = &u
  9283. m.addcategory_id = nil
  9284. }
  9285. // CategoryID returns the value of the "category_id" field in the mutation.
  9286. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  9287. v := m.category_id
  9288. if v == nil {
  9289. return
  9290. }
  9291. return *v, true
  9292. }
  9293. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  9294. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9296. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  9297. if !m.op.Is(OpUpdateOne) {
  9298. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  9299. }
  9300. if m.id == nil || m.oldValue == nil {
  9301. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  9302. }
  9303. oldValue, err := m.oldValue(ctx)
  9304. if err != nil {
  9305. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  9306. }
  9307. return oldValue.CategoryID, nil
  9308. }
  9309. // AddCategoryID adds u to the "category_id" field.
  9310. func (m *EmployeeMutation) AddCategoryID(u int64) {
  9311. if m.addcategory_id != nil {
  9312. *m.addcategory_id += u
  9313. } else {
  9314. m.addcategory_id = &u
  9315. }
  9316. }
  9317. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  9318. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  9319. v := m.addcategory_id
  9320. if v == nil {
  9321. return
  9322. }
  9323. return *v, true
  9324. }
  9325. // ResetCategoryID resets all changes to the "category_id" field.
  9326. func (m *EmployeeMutation) ResetCategoryID() {
  9327. m.category_id = nil
  9328. m.addcategory_id = nil
  9329. }
  9330. // SetAPIBase sets the "api_base" field.
  9331. func (m *EmployeeMutation) SetAPIBase(s string) {
  9332. m.api_base = &s
  9333. }
  9334. // APIBase returns the value of the "api_base" field in the mutation.
  9335. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  9336. v := m.api_base
  9337. if v == nil {
  9338. return
  9339. }
  9340. return *v, true
  9341. }
  9342. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  9343. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9345. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  9346. if !m.op.Is(OpUpdateOne) {
  9347. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  9348. }
  9349. if m.id == nil || m.oldValue == nil {
  9350. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  9351. }
  9352. oldValue, err := m.oldValue(ctx)
  9353. if err != nil {
  9354. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  9355. }
  9356. return oldValue.APIBase, nil
  9357. }
  9358. // ResetAPIBase resets all changes to the "api_base" field.
  9359. func (m *EmployeeMutation) ResetAPIBase() {
  9360. m.api_base = nil
  9361. }
  9362. // SetAPIKey sets the "api_key" field.
  9363. func (m *EmployeeMutation) SetAPIKey(s string) {
  9364. m.api_key = &s
  9365. }
  9366. // APIKey returns the value of the "api_key" field in the mutation.
  9367. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  9368. v := m.api_key
  9369. if v == nil {
  9370. return
  9371. }
  9372. return *v, true
  9373. }
  9374. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  9375. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9377. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  9378. if !m.op.Is(OpUpdateOne) {
  9379. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  9380. }
  9381. if m.id == nil || m.oldValue == nil {
  9382. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  9383. }
  9384. oldValue, err := m.oldValue(ctx)
  9385. if err != nil {
  9386. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  9387. }
  9388. return oldValue.APIKey, nil
  9389. }
  9390. // ResetAPIKey resets all changes to the "api_key" field.
  9391. func (m *EmployeeMutation) ResetAPIKey() {
  9392. m.api_key = nil
  9393. }
  9394. // SetAiInfo sets the "ai_info" field.
  9395. func (m *EmployeeMutation) SetAiInfo(s string) {
  9396. m.ai_info = &s
  9397. }
  9398. // AiInfo returns the value of the "ai_info" field in the mutation.
  9399. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  9400. v := m.ai_info
  9401. if v == nil {
  9402. return
  9403. }
  9404. return *v, true
  9405. }
  9406. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  9407. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9409. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  9410. if !m.op.Is(OpUpdateOne) {
  9411. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  9412. }
  9413. if m.id == nil || m.oldValue == nil {
  9414. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  9415. }
  9416. oldValue, err := m.oldValue(ctx)
  9417. if err != nil {
  9418. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  9419. }
  9420. return oldValue.AiInfo, nil
  9421. }
  9422. // ClearAiInfo clears the value of the "ai_info" field.
  9423. func (m *EmployeeMutation) ClearAiInfo() {
  9424. m.ai_info = nil
  9425. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  9426. }
  9427. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  9428. func (m *EmployeeMutation) AiInfoCleared() bool {
  9429. _, ok := m.clearedFields[employee.FieldAiInfo]
  9430. return ok
  9431. }
  9432. // ResetAiInfo resets all changes to the "ai_info" field.
  9433. func (m *EmployeeMutation) ResetAiInfo() {
  9434. m.ai_info = nil
  9435. delete(m.clearedFields, employee.FieldAiInfo)
  9436. }
  9437. // SetIsVip sets the "is_vip" field.
  9438. func (m *EmployeeMutation) SetIsVip(i int) {
  9439. m.is_vip = &i
  9440. m.addis_vip = nil
  9441. }
  9442. // IsVip returns the value of the "is_vip" field in the mutation.
  9443. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  9444. v := m.is_vip
  9445. if v == nil {
  9446. return
  9447. }
  9448. return *v, true
  9449. }
  9450. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  9451. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9453. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  9454. if !m.op.Is(OpUpdateOne) {
  9455. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  9456. }
  9457. if m.id == nil || m.oldValue == nil {
  9458. return v, errors.New("OldIsVip requires an ID field in the mutation")
  9459. }
  9460. oldValue, err := m.oldValue(ctx)
  9461. if err != nil {
  9462. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  9463. }
  9464. return oldValue.IsVip, nil
  9465. }
  9466. // AddIsVip adds i to the "is_vip" field.
  9467. func (m *EmployeeMutation) AddIsVip(i int) {
  9468. if m.addis_vip != nil {
  9469. *m.addis_vip += i
  9470. } else {
  9471. m.addis_vip = &i
  9472. }
  9473. }
  9474. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  9475. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  9476. v := m.addis_vip
  9477. if v == nil {
  9478. return
  9479. }
  9480. return *v, true
  9481. }
  9482. // ResetIsVip resets all changes to the "is_vip" field.
  9483. func (m *EmployeeMutation) ResetIsVip() {
  9484. m.is_vip = nil
  9485. m.addis_vip = nil
  9486. }
  9487. // SetChatURL sets the "chat_url" field.
  9488. func (m *EmployeeMutation) SetChatURL(s string) {
  9489. m.chat_url = &s
  9490. }
  9491. // ChatURL returns the value of the "chat_url" field in the mutation.
  9492. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  9493. v := m.chat_url
  9494. if v == nil {
  9495. return
  9496. }
  9497. return *v, true
  9498. }
  9499. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  9500. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9502. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  9503. if !m.op.Is(OpUpdateOne) {
  9504. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  9505. }
  9506. if m.id == nil || m.oldValue == nil {
  9507. return v, errors.New("OldChatURL requires an ID field in the mutation")
  9508. }
  9509. oldValue, err := m.oldValue(ctx)
  9510. if err != nil {
  9511. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  9512. }
  9513. return oldValue.ChatURL, nil
  9514. }
  9515. // ResetChatURL resets all changes to the "chat_url" field.
  9516. func (m *EmployeeMutation) ResetChatURL() {
  9517. m.chat_url = nil
  9518. }
  9519. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  9520. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  9521. if m.em_work_experiences == nil {
  9522. m.em_work_experiences = make(map[uint64]struct{})
  9523. }
  9524. for i := range ids {
  9525. m.em_work_experiences[ids[i]] = struct{}{}
  9526. }
  9527. }
  9528. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  9529. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  9530. m.clearedem_work_experiences = true
  9531. }
  9532. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  9533. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  9534. return m.clearedem_work_experiences
  9535. }
  9536. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  9537. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  9538. if m.removedem_work_experiences == nil {
  9539. m.removedem_work_experiences = make(map[uint64]struct{})
  9540. }
  9541. for i := range ids {
  9542. delete(m.em_work_experiences, ids[i])
  9543. m.removedem_work_experiences[ids[i]] = struct{}{}
  9544. }
  9545. }
  9546. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  9547. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  9548. for id := range m.removedem_work_experiences {
  9549. ids = append(ids, id)
  9550. }
  9551. return
  9552. }
  9553. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  9554. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  9555. for id := range m.em_work_experiences {
  9556. ids = append(ids, id)
  9557. }
  9558. return
  9559. }
  9560. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  9561. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  9562. m.em_work_experiences = nil
  9563. m.clearedem_work_experiences = false
  9564. m.removedem_work_experiences = nil
  9565. }
  9566. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  9567. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  9568. if m.em_tutorial == nil {
  9569. m.em_tutorial = make(map[uint64]struct{})
  9570. }
  9571. for i := range ids {
  9572. m.em_tutorial[ids[i]] = struct{}{}
  9573. }
  9574. }
  9575. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  9576. func (m *EmployeeMutation) ClearEmTutorial() {
  9577. m.clearedem_tutorial = true
  9578. }
  9579. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  9580. func (m *EmployeeMutation) EmTutorialCleared() bool {
  9581. return m.clearedem_tutorial
  9582. }
  9583. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  9584. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  9585. if m.removedem_tutorial == nil {
  9586. m.removedem_tutorial = make(map[uint64]struct{})
  9587. }
  9588. for i := range ids {
  9589. delete(m.em_tutorial, ids[i])
  9590. m.removedem_tutorial[ids[i]] = struct{}{}
  9591. }
  9592. }
  9593. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  9594. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  9595. for id := range m.removedem_tutorial {
  9596. ids = append(ids, id)
  9597. }
  9598. return
  9599. }
  9600. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  9601. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  9602. for id := range m.em_tutorial {
  9603. ids = append(ids, id)
  9604. }
  9605. return
  9606. }
  9607. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  9608. func (m *EmployeeMutation) ResetEmTutorial() {
  9609. m.em_tutorial = nil
  9610. m.clearedem_tutorial = false
  9611. m.removedem_tutorial = nil
  9612. }
  9613. // Where appends a list predicates to the EmployeeMutation builder.
  9614. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  9615. m.predicates = append(m.predicates, ps...)
  9616. }
  9617. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  9618. // users can use type-assertion to append predicates that do not depend on any generated package.
  9619. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  9620. p := make([]predicate.Employee, len(ps))
  9621. for i := range ps {
  9622. p[i] = ps[i]
  9623. }
  9624. m.Where(p...)
  9625. }
  9626. // Op returns the operation name.
  9627. func (m *EmployeeMutation) Op() Op {
  9628. return m.op
  9629. }
  9630. // SetOp allows setting the mutation operation.
  9631. func (m *EmployeeMutation) SetOp(op Op) {
  9632. m.op = op
  9633. }
  9634. // Type returns the node type of this mutation (Employee).
  9635. func (m *EmployeeMutation) Type() string {
  9636. return m.typ
  9637. }
  9638. // Fields returns all fields that were changed during this mutation. Note that in
  9639. // order to get all numeric fields that were incremented/decremented, call
  9640. // AddedFields().
  9641. func (m *EmployeeMutation) Fields() []string {
  9642. fields := make([]string, 0, 23)
  9643. if m.created_at != nil {
  9644. fields = append(fields, employee.FieldCreatedAt)
  9645. }
  9646. if m.updated_at != nil {
  9647. fields = append(fields, employee.FieldUpdatedAt)
  9648. }
  9649. if m.deleted_at != nil {
  9650. fields = append(fields, employee.FieldDeletedAt)
  9651. }
  9652. if m.title != nil {
  9653. fields = append(fields, employee.FieldTitle)
  9654. }
  9655. if m.avatar != nil {
  9656. fields = append(fields, employee.FieldAvatar)
  9657. }
  9658. if m.tags != nil {
  9659. fields = append(fields, employee.FieldTags)
  9660. }
  9661. if m.hire_count != nil {
  9662. fields = append(fields, employee.FieldHireCount)
  9663. }
  9664. if m.service_count != nil {
  9665. fields = append(fields, employee.FieldServiceCount)
  9666. }
  9667. if m.achievement_count != nil {
  9668. fields = append(fields, employee.FieldAchievementCount)
  9669. }
  9670. if m.intro != nil {
  9671. fields = append(fields, employee.FieldIntro)
  9672. }
  9673. if m.estimate != nil {
  9674. fields = append(fields, employee.FieldEstimate)
  9675. }
  9676. if m.skill != nil {
  9677. fields = append(fields, employee.FieldSkill)
  9678. }
  9679. if m.ability_type != nil {
  9680. fields = append(fields, employee.FieldAbilityType)
  9681. }
  9682. if m.scene != nil {
  9683. fields = append(fields, employee.FieldScene)
  9684. }
  9685. if m.switch_in != nil {
  9686. fields = append(fields, employee.FieldSwitchIn)
  9687. }
  9688. if m.video_url != nil {
  9689. fields = append(fields, employee.FieldVideoURL)
  9690. }
  9691. if m.organization_id != nil {
  9692. fields = append(fields, employee.FieldOrganizationID)
  9693. }
  9694. if m.category_id != nil {
  9695. fields = append(fields, employee.FieldCategoryID)
  9696. }
  9697. if m.api_base != nil {
  9698. fields = append(fields, employee.FieldAPIBase)
  9699. }
  9700. if m.api_key != nil {
  9701. fields = append(fields, employee.FieldAPIKey)
  9702. }
  9703. if m.ai_info != nil {
  9704. fields = append(fields, employee.FieldAiInfo)
  9705. }
  9706. if m.is_vip != nil {
  9707. fields = append(fields, employee.FieldIsVip)
  9708. }
  9709. if m.chat_url != nil {
  9710. fields = append(fields, employee.FieldChatURL)
  9711. }
  9712. return fields
  9713. }
  9714. // Field returns the value of a field with the given name. The second boolean
  9715. // return value indicates that this field was not set, or was not defined in the
  9716. // schema.
  9717. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  9718. switch name {
  9719. case employee.FieldCreatedAt:
  9720. return m.CreatedAt()
  9721. case employee.FieldUpdatedAt:
  9722. return m.UpdatedAt()
  9723. case employee.FieldDeletedAt:
  9724. return m.DeletedAt()
  9725. case employee.FieldTitle:
  9726. return m.Title()
  9727. case employee.FieldAvatar:
  9728. return m.Avatar()
  9729. case employee.FieldTags:
  9730. return m.Tags()
  9731. case employee.FieldHireCount:
  9732. return m.HireCount()
  9733. case employee.FieldServiceCount:
  9734. return m.ServiceCount()
  9735. case employee.FieldAchievementCount:
  9736. return m.AchievementCount()
  9737. case employee.FieldIntro:
  9738. return m.Intro()
  9739. case employee.FieldEstimate:
  9740. return m.Estimate()
  9741. case employee.FieldSkill:
  9742. return m.Skill()
  9743. case employee.FieldAbilityType:
  9744. return m.AbilityType()
  9745. case employee.FieldScene:
  9746. return m.Scene()
  9747. case employee.FieldSwitchIn:
  9748. return m.SwitchIn()
  9749. case employee.FieldVideoURL:
  9750. return m.VideoURL()
  9751. case employee.FieldOrganizationID:
  9752. return m.OrganizationID()
  9753. case employee.FieldCategoryID:
  9754. return m.CategoryID()
  9755. case employee.FieldAPIBase:
  9756. return m.APIBase()
  9757. case employee.FieldAPIKey:
  9758. return m.APIKey()
  9759. case employee.FieldAiInfo:
  9760. return m.AiInfo()
  9761. case employee.FieldIsVip:
  9762. return m.IsVip()
  9763. case employee.FieldChatURL:
  9764. return m.ChatURL()
  9765. }
  9766. return nil, false
  9767. }
  9768. // OldField returns the old value of the field from the database. An error is
  9769. // returned if the mutation operation is not UpdateOne, or the query to the
  9770. // database failed.
  9771. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9772. switch name {
  9773. case employee.FieldCreatedAt:
  9774. return m.OldCreatedAt(ctx)
  9775. case employee.FieldUpdatedAt:
  9776. return m.OldUpdatedAt(ctx)
  9777. case employee.FieldDeletedAt:
  9778. return m.OldDeletedAt(ctx)
  9779. case employee.FieldTitle:
  9780. return m.OldTitle(ctx)
  9781. case employee.FieldAvatar:
  9782. return m.OldAvatar(ctx)
  9783. case employee.FieldTags:
  9784. return m.OldTags(ctx)
  9785. case employee.FieldHireCount:
  9786. return m.OldHireCount(ctx)
  9787. case employee.FieldServiceCount:
  9788. return m.OldServiceCount(ctx)
  9789. case employee.FieldAchievementCount:
  9790. return m.OldAchievementCount(ctx)
  9791. case employee.FieldIntro:
  9792. return m.OldIntro(ctx)
  9793. case employee.FieldEstimate:
  9794. return m.OldEstimate(ctx)
  9795. case employee.FieldSkill:
  9796. return m.OldSkill(ctx)
  9797. case employee.FieldAbilityType:
  9798. return m.OldAbilityType(ctx)
  9799. case employee.FieldScene:
  9800. return m.OldScene(ctx)
  9801. case employee.FieldSwitchIn:
  9802. return m.OldSwitchIn(ctx)
  9803. case employee.FieldVideoURL:
  9804. return m.OldVideoURL(ctx)
  9805. case employee.FieldOrganizationID:
  9806. return m.OldOrganizationID(ctx)
  9807. case employee.FieldCategoryID:
  9808. return m.OldCategoryID(ctx)
  9809. case employee.FieldAPIBase:
  9810. return m.OldAPIBase(ctx)
  9811. case employee.FieldAPIKey:
  9812. return m.OldAPIKey(ctx)
  9813. case employee.FieldAiInfo:
  9814. return m.OldAiInfo(ctx)
  9815. case employee.FieldIsVip:
  9816. return m.OldIsVip(ctx)
  9817. case employee.FieldChatURL:
  9818. return m.OldChatURL(ctx)
  9819. }
  9820. return nil, fmt.Errorf("unknown Employee field %s", name)
  9821. }
  9822. // SetField sets the value of a field with the given name. It returns an error if
  9823. // the field is not defined in the schema, or if the type mismatched the field
  9824. // type.
  9825. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  9826. switch name {
  9827. case employee.FieldCreatedAt:
  9828. v, ok := value.(time.Time)
  9829. if !ok {
  9830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9831. }
  9832. m.SetCreatedAt(v)
  9833. return nil
  9834. case employee.FieldUpdatedAt:
  9835. v, ok := value.(time.Time)
  9836. if !ok {
  9837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9838. }
  9839. m.SetUpdatedAt(v)
  9840. return nil
  9841. case employee.FieldDeletedAt:
  9842. v, ok := value.(time.Time)
  9843. if !ok {
  9844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9845. }
  9846. m.SetDeletedAt(v)
  9847. return nil
  9848. case employee.FieldTitle:
  9849. v, ok := value.(string)
  9850. if !ok {
  9851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9852. }
  9853. m.SetTitle(v)
  9854. return nil
  9855. case employee.FieldAvatar:
  9856. v, ok := value.(string)
  9857. if !ok {
  9858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9859. }
  9860. m.SetAvatar(v)
  9861. return nil
  9862. case employee.FieldTags:
  9863. v, ok := value.(string)
  9864. if !ok {
  9865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9866. }
  9867. m.SetTags(v)
  9868. return nil
  9869. case employee.FieldHireCount:
  9870. v, ok := value.(int)
  9871. if !ok {
  9872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9873. }
  9874. m.SetHireCount(v)
  9875. return nil
  9876. case employee.FieldServiceCount:
  9877. v, ok := value.(int)
  9878. if !ok {
  9879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9880. }
  9881. m.SetServiceCount(v)
  9882. return nil
  9883. case employee.FieldAchievementCount:
  9884. v, ok := value.(int)
  9885. if !ok {
  9886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9887. }
  9888. m.SetAchievementCount(v)
  9889. return nil
  9890. case employee.FieldIntro:
  9891. v, ok := value.(string)
  9892. if !ok {
  9893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9894. }
  9895. m.SetIntro(v)
  9896. return nil
  9897. case employee.FieldEstimate:
  9898. v, ok := value.(string)
  9899. if !ok {
  9900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9901. }
  9902. m.SetEstimate(v)
  9903. return nil
  9904. case employee.FieldSkill:
  9905. v, ok := value.(string)
  9906. if !ok {
  9907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9908. }
  9909. m.SetSkill(v)
  9910. return nil
  9911. case employee.FieldAbilityType:
  9912. v, ok := value.(string)
  9913. if !ok {
  9914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9915. }
  9916. m.SetAbilityType(v)
  9917. return nil
  9918. case employee.FieldScene:
  9919. v, ok := value.(string)
  9920. if !ok {
  9921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9922. }
  9923. m.SetScene(v)
  9924. return nil
  9925. case employee.FieldSwitchIn:
  9926. v, ok := value.(string)
  9927. if !ok {
  9928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9929. }
  9930. m.SetSwitchIn(v)
  9931. return nil
  9932. case employee.FieldVideoURL:
  9933. v, ok := value.(string)
  9934. if !ok {
  9935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9936. }
  9937. m.SetVideoURL(v)
  9938. return nil
  9939. case employee.FieldOrganizationID:
  9940. v, ok := value.(uint64)
  9941. if !ok {
  9942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9943. }
  9944. m.SetOrganizationID(v)
  9945. return nil
  9946. case employee.FieldCategoryID:
  9947. v, ok := value.(uint64)
  9948. if !ok {
  9949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9950. }
  9951. m.SetCategoryID(v)
  9952. return nil
  9953. case employee.FieldAPIBase:
  9954. v, ok := value.(string)
  9955. if !ok {
  9956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9957. }
  9958. m.SetAPIBase(v)
  9959. return nil
  9960. case employee.FieldAPIKey:
  9961. v, ok := value.(string)
  9962. if !ok {
  9963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9964. }
  9965. m.SetAPIKey(v)
  9966. return nil
  9967. case employee.FieldAiInfo:
  9968. v, ok := value.(string)
  9969. if !ok {
  9970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9971. }
  9972. m.SetAiInfo(v)
  9973. return nil
  9974. case employee.FieldIsVip:
  9975. v, ok := value.(int)
  9976. if !ok {
  9977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9978. }
  9979. m.SetIsVip(v)
  9980. return nil
  9981. case employee.FieldChatURL:
  9982. v, ok := value.(string)
  9983. if !ok {
  9984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9985. }
  9986. m.SetChatURL(v)
  9987. return nil
  9988. }
  9989. return fmt.Errorf("unknown Employee field %s", name)
  9990. }
  9991. // AddedFields returns all numeric fields that were incremented/decremented during
  9992. // this mutation.
  9993. func (m *EmployeeMutation) AddedFields() []string {
  9994. var fields []string
  9995. if m.addhire_count != nil {
  9996. fields = append(fields, employee.FieldHireCount)
  9997. }
  9998. if m.addservice_count != nil {
  9999. fields = append(fields, employee.FieldServiceCount)
  10000. }
  10001. if m.addachievement_count != nil {
  10002. fields = append(fields, employee.FieldAchievementCount)
  10003. }
  10004. if m.addorganization_id != nil {
  10005. fields = append(fields, employee.FieldOrganizationID)
  10006. }
  10007. if m.addcategory_id != nil {
  10008. fields = append(fields, employee.FieldCategoryID)
  10009. }
  10010. if m.addis_vip != nil {
  10011. fields = append(fields, employee.FieldIsVip)
  10012. }
  10013. return fields
  10014. }
  10015. // AddedField returns the numeric value that was incremented/decremented on a field
  10016. // with the given name. The second boolean return value indicates that this field
  10017. // was not set, or was not defined in the schema.
  10018. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  10019. switch name {
  10020. case employee.FieldHireCount:
  10021. return m.AddedHireCount()
  10022. case employee.FieldServiceCount:
  10023. return m.AddedServiceCount()
  10024. case employee.FieldAchievementCount:
  10025. return m.AddedAchievementCount()
  10026. case employee.FieldOrganizationID:
  10027. return m.AddedOrganizationID()
  10028. case employee.FieldCategoryID:
  10029. return m.AddedCategoryID()
  10030. case employee.FieldIsVip:
  10031. return m.AddedIsVip()
  10032. }
  10033. return nil, false
  10034. }
  10035. // AddField adds the value to the field with the given name. It returns an error if
  10036. // the field is not defined in the schema, or if the type mismatched the field
  10037. // type.
  10038. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  10039. switch name {
  10040. case employee.FieldHireCount:
  10041. v, ok := value.(int)
  10042. if !ok {
  10043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10044. }
  10045. m.AddHireCount(v)
  10046. return nil
  10047. case employee.FieldServiceCount:
  10048. v, ok := value.(int)
  10049. if !ok {
  10050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10051. }
  10052. m.AddServiceCount(v)
  10053. return nil
  10054. case employee.FieldAchievementCount:
  10055. v, ok := value.(int)
  10056. if !ok {
  10057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10058. }
  10059. m.AddAchievementCount(v)
  10060. return nil
  10061. case employee.FieldOrganizationID:
  10062. v, ok := value.(int64)
  10063. if !ok {
  10064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10065. }
  10066. m.AddOrganizationID(v)
  10067. return nil
  10068. case employee.FieldCategoryID:
  10069. v, ok := value.(int64)
  10070. if !ok {
  10071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10072. }
  10073. m.AddCategoryID(v)
  10074. return nil
  10075. case employee.FieldIsVip:
  10076. v, ok := value.(int)
  10077. if !ok {
  10078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10079. }
  10080. m.AddIsVip(v)
  10081. return nil
  10082. }
  10083. return fmt.Errorf("unknown Employee numeric field %s", name)
  10084. }
  10085. // ClearedFields returns all nullable fields that were cleared during this
  10086. // mutation.
  10087. func (m *EmployeeMutation) ClearedFields() []string {
  10088. var fields []string
  10089. if m.FieldCleared(employee.FieldDeletedAt) {
  10090. fields = append(fields, employee.FieldDeletedAt)
  10091. }
  10092. if m.FieldCleared(employee.FieldAiInfo) {
  10093. fields = append(fields, employee.FieldAiInfo)
  10094. }
  10095. return fields
  10096. }
  10097. // FieldCleared returns a boolean indicating if a field with the given name was
  10098. // cleared in this mutation.
  10099. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10100. _, ok := m.clearedFields[name]
  10101. return ok
  10102. }
  10103. // ClearField clears the value of the field with the given name. It returns an
  10104. // error if the field is not defined in the schema.
  10105. func (m *EmployeeMutation) ClearField(name string) error {
  10106. switch name {
  10107. case employee.FieldDeletedAt:
  10108. m.ClearDeletedAt()
  10109. return nil
  10110. case employee.FieldAiInfo:
  10111. m.ClearAiInfo()
  10112. return nil
  10113. }
  10114. return fmt.Errorf("unknown Employee nullable field %s", name)
  10115. }
  10116. // ResetField resets all changes in the mutation for the field with the given name.
  10117. // It returns an error if the field is not defined in the schema.
  10118. func (m *EmployeeMutation) ResetField(name string) error {
  10119. switch name {
  10120. case employee.FieldCreatedAt:
  10121. m.ResetCreatedAt()
  10122. return nil
  10123. case employee.FieldUpdatedAt:
  10124. m.ResetUpdatedAt()
  10125. return nil
  10126. case employee.FieldDeletedAt:
  10127. m.ResetDeletedAt()
  10128. return nil
  10129. case employee.FieldTitle:
  10130. m.ResetTitle()
  10131. return nil
  10132. case employee.FieldAvatar:
  10133. m.ResetAvatar()
  10134. return nil
  10135. case employee.FieldTags:
  10136. m.ResetTags()
  10137. return nil
  10138. case employee.FieldHireCount:
  10139. m.ResetHireCount()
  10140. return nil
  10141. case employee.FieldServiceCount:
  10142. m.ResetServiceCount()
  10143. return nil
  10144. case employee.FieldAchievementCount:
  10145. m.ResetAchievementCount()
  10146. return nil
  10147. case employee.FieldIntro:
  10148. m.ResetIntro()
  10149. return nil
  10150. case employee.FieldEstimate:
  10151. m.ResetEstimate()
  10152. return nil
  10153. case employee.FieldSkill:
  10154. m.ResetSkill()
  10155. return nil
  10156. case employee.FieldAbilityType:
  10157. m.ResetAbilityType()
  10158. return nil
  10159. case employee.FieldScene:
  10160. m.ResetScene()
  10161. return nil
  10162. case employee.FieldSwitchIn:
  10163. m.ResetSwitchIn()
  10164. return nil
  10165. case employee.FieldVideoURL:
  10166. m.ResetVideoURL()
  10167. return nil
  10168. case employee.FieldOrganizationID:
  10169. m.ResetOrganizationID()
  10170. return nil
  10171. case employee.FieldCategoryID:
  10172. m.ResetCategoryID()
  10173. return nil
  10174. case employee.FieldAPIBase:
  10175. m.ResetAPIBase()
  10176. return nil
  10177. case employee.FieldAPIKey:
  10178. m.ResetAPIKey()
  10179. return nil
  10180. case employee.FieldAiInfo:
  10181. m.ResetAiInfo()
  10182. return nil
  10183. case employee.FieldIsVip:
  10184. m.ResetIsVip()
  10185. return nil
  10186. case employee.FieldChatURL:
  10187. m.ResetChatURL()
  10188. return nil
  10189. }
  10190. return fmt.Errorf("unknown Employee field %s", name)
  10191. }
  10192. // AddedEdges returns all edge names that were set/added in this mutation.
  10193. func (m *EmployeeMutation) AddedEdges() []string {
  10194. edges := make([]string, 0, 2)
  10195. if m.em_work_experiences != nil {
  10196. edges = append(edges, employee.EdgeEmWorkExperiences)
  10197. }
  10198. if m.em_tutorial != nil {
  10199. edges = append(edges, employee.EdgeEmTutorial)
  10200. }
  10201. return edges
  10202. }
  10203. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10204. // name in this mutation.
  10205. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10206. switch name {
  10207. case employee.EdgeEmWorkExperiences:
  10208. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10209. for id := range m.em_work_experiences {
  10210. ids = append(ids, id)
  10211. }
  10212. return ids
  10213. case employee.EdgeEmTutorial:
  10214. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10215. for id := range m.em_tutorial {
  10216. ids = append(ids, id)
  10217. }
  10218. return ids
  10219. }
  10220. return nil
  10221. }
  10222. // RemovedEdges returns all edge names that were removed in this mutation.
  10223. func (m *EmployeeMutation) RemovedEdges() []string {
  10224. edges := make([]string, 0, 2)
  10225. if m.removedem_work_experiences != nil {
  10226. edges = append(edges, employee.EdgeEmWorkExperiences)
  10227. }
  10228. if m.removedem_tutorial != nil {
  10229. edges = append(edges, employee.EdgeEmTutorial)
  10230. }
  10231. return edges
  10232. }
  10233. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10234. // the given name in this mutation.
  10235. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10236. switch name {
  10237. case employee.EdgeEmWorkExperiences:
  10238. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10239. for id := range m.removedem_work_experiences {
  10240. ids = append(ids, id)
  10241. }
  10242. return ids
  10243. case employee.EdgeEmTutorial:
  10244. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10245. for id := range m.removedem_tutorial {
  10246. ids = append(ids, id)
  10247. }
  10248. return ids
  10249. }
  10250. return nil
  10251. }
  10252. // ClearedEdges returns all edge names that were cleared in this mutation.
  10253. func (m *EmployeeMutation) ClearedEdges() []string {
  10254. edges := make([]string, 0, 2)
  10255. if m.clearedem_work_experiences {
  10256. edges = append(edges, employee.EdgeEmWorkExperiences)
  10257. }
  10258. if m.clearedem_tutorial {
  10259. edges = append(edges, employee.EdgeEmTutorial)
  10260. }
  10261. return edges
  10262. }
  10263. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10264. // was cleared in this mutation.
  10265. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  10266. switch name {
  10267. case employee.EdgeEmWorkExperiences:
  10268. return m.clearedem_work_experiences
  10269. case employee.EdgeEmTutorial:
  10270. return m.clearedem_tutorial
  10271. }
  10272. return false
  10273. }
  10274. // ClearEdge clears the value of the edge with the given name. It returns an error
  10275. // if that edge is not defined in the schema.
  10276. func (m *EmployeeMutation) ClearEdge(name string) error {
  10277. switch name {
  10278. }
  10279. return fmt.Errorf("unknown Employee unique edge %s", name)
  10280. }
  10281. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10282. // It returns an error if the edge is not defined in the schema.
  10283. func (m *EmployeeMutation) ResetEdge(name string) error {
  10284. switch name {
  10285. case employee.EdgeEmWorkExperiences:
  10286. m.ResetEmWorkExperiences()
  10287. return nil
  10288. case employee.EdgeEmTutorial:
  10289. m.ResetEmTutorial()
  10290. return nil
  10291. }
  10292. return fmt.Errorf("unknown Employee edge %s", name)
  10293. }
  10294. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  10295. type EmployeeConfigMutation struct {
  10296. config
  10297. op Op
  10298. typ string
  10299. id *uint64
  10300. created_at *time.Time
  10301. updated_at *time.Time
  10302. deleted_at *time.Time
  10303. stype *string
  10304. title *string
  10305. photo *string
  10306. organization_id *uint64
  10307. addorganization_id *int64
  10308. clearedFields map[string]struct{}
  10309. done bool
  10310. oldValue func(context.Context) (*EmployeeConfig, error)
  10311. predicates []predicate.EmployeeConfig
  10312. }
  10313. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  10314. // employeeconfigOption allows management of the mutation configuration using functional options.
  10315. type employeeconfigOption func(*EmployeeConfigMutation)
  10316. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  10317. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  10318. m := &EmployeeConfigMutation{
  10319. config: c,
  10320. op: op,
  10321. typ: TypeEmployeeConfig,
  10322. clearedFields: make(map[string]struct{}),
  10323. }
  10324. for _, opt := range opts {
  10325. opt(m)
  10326. }
  10327. return m
  10328. }
  10329. // withEmployeeConfigID sets the ID field of the mutation.
  10330. func withEmployeeConfigID(id uint64) employeeconfigOption {
  10331. return func(m *EmployeeConfigMutation) {
  10332. var (
  10333. err error
  10334. once sync.Once
  10335. value *EmployeeConfig
  10336. )
  10337. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  10338. once.Do(func() {
  10339. if m.done {
  10340. err = errors.New("querying old values post mutation is not allowed")
  10341. } else {
  10342. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  10343. }
  10344. })
  10345. return value, err
  10346. }
  10347. m.id = &id
  10348. }
  10349. }
  10350. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  10351. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  10352. return func(m *EmployeeConfigMutation) {
  10353. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  10354. return node, nil
  10355. }
  10356. m.id = &node.ID
  10357. }
  10358. }
  10359. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10360. // executed in a transaction (ent.Tx), a transactional client is returned.
  10361. func (m EmployeeConfigMutation) Client() *Client {
  10362. client := &Client{config: m.config}
  10363. client.init()
  10364. return client
  10365. }
  10366. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10367. // it returns an error otherwise.
  10368. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  10369. if _, ok := m.driver.(*txDriver); !ok {
  10370. return nil, errors.New("ent: mutation is not running in a transaction")
  10371. }
  10372. tx := &Tx{config: m.config}
  10373. tx.init()
  10374. return tx, nil
  10375. }
  10376. // SetID sets the value of the id field. Note that this
  10377. // operation is only accepted on creation of EmployeeConfig entities.
  10378. func (m *EmployeeConfigMutation) SetID(id uint64) {
  10379. m.id = &id
  10380. }
  10381. // ID returns the ID value in the mutation. Note that the ID is only available
  10382. // if it was provided to the builder or after it was returned from the database.
  10383. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  10384. if m.id == nil {
  10385. return
  10386. }
  10387. return *m.id, true
  10388. }
  10389. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10390. // That means, if the mutation is applied within a transaction with an isolation level such
  10391. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10392. // or updated by the mutation.
  10393. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  10394. switch {
  10395. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10396. id, exists := m.ID()
  10397. if exists {
  10398. return []uint64{id}, nil
  10399. }
  10400. fallthrough
  10401. case m.op.Is(OpUpdate | OpDelete):
  10402. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  10403. default:
  10404. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10405. }
  10406. }
  10407. // SetCreatedAt sets the "created_at" field.
  10408. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  10409. m.created_at = &t
  10410. }
  10411. // CreatedAt returns the value of the "created_at" field in the mutation.
  10412. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  10413. v := m.created_at
  10414. if v == nil {
  10415. return
  10416. }
  10417. return *v, true
  10418. }
  10419. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  10420. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10422. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10423. if !m.op.Is(OpUpdateOne) {
  10424. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10425. }
  10426. if m.id == nil || m.oldValue == nil {
  10427. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10428. }
  10429. oldValue, err := m.oldValue(ctx)
  10430. if err != nil {
  10431. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10432. }
  10433. return oldValue.CreatedAt, nil
  10434. }
  10435. // ResetCreatedAt resets all changes to the "created_at" field.
  10436. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  10437. m.created_at = nil
  10438. }
  10439. // SetUpdatedAt sets the "updated_at" field.
  10440. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  10441. m.updated_at = &t
  10442. }
  10443. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10444. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  10445. v := m.updated_at
  10446. if v == nil {
  10447. return
  10448. }
  10449. return *v, true
  10450. }
  10451. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  10452. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10454. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10455. if !m.op.Is(OpUpdateOne) {
  10456. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10457. }
  10458. if m.id == nil || m.oldValue == nil {
  10459. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10460. }
  10461. oldValue, err := m.oldValue(ctx)
  10462. if err != nil {
  10463. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10464. }
  10465. return oldValue.UpdatedAt, nil
  10466. }
  10467. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10468. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  10469. m.updated_at = nil
  10470. }
  10471. // SetDeletedAt sets the "deleted_at" field.
  10472. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  10473. m.deleted_at = &t
  10474. }
  10475. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10476. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  10477. v := m.deleted_at
  10478. if v == nil {
  10479. return
  10480. }
  10481. return *v, true
  10482. }
  10483. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  10484. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10486. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10487. if !m.op.Is(OpUpdateOne) {
  10488. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10489. }
  10490. if m.id == nil || m.oldValue == nil {
  10491. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10492. }
  10493. oldValue, err := m.oldValue(ctx)
  10494. if err != nil {
  10495. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10496. }
  10497. return oldValue.DeletedAt, nil
  10498. }
  10499. // ClearDeletedAt clears the value of the "deleted_at" field.
  10500. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  10501. m.deleted_at = nil
  10502. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  10503. }
  10504. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10505. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  10506. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  10507. return ok
  10508. }
  10509. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10510. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  10511. m.deleted_at = nil
  10512. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  10513. }
  10514. // SetStype sets the "stype" field.
  10515. func (m *EmployeeConfigMutation) SetStype(s string) {
  10516. m.stype = &s
  10517. }
  10518. // Stype returns the value of the "stype" field in the mutation.
  10519. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  10520. v := m.stype
  10521. if v == nil {
  10522. return
  10523. }
  10524. return *v, true
  10525. }
  10526. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  10527. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10529. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  10530. if !m.op.Is(OpUpdateOne) {
  10531. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  10532. }
  10533. if m.id == nil || m.oldValue == nil {
  10534. return v, errors.New("OldStype requires an ID field in the mutation")
  10535. }
  10536. oldValue, err := m.oldValue(ctx)
  10537. if err != nil {
  10538. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  10539. }
  10540. return oldValue.Stype, nil
  10541. }
  10542. // ResetStype resets all changes to the "stype" field.
  10543. func (m *EmployeeConfigMutation) ResetStype() {
  10544. m.stype = nil
  10545. }
  10546. // SetTitle sets the "title" field.
  10547. func (m *EmployeeConfigMutation) SetTitle(s string) {
  10548. m.title = &s
  10549. }
  10550. // Title returns the value of the "title" field in the mutation.
  10551. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  10552. v := m.title
  10553. if v == nil {
  10554. return
  10555. }
  10556. return *v, true
  10557. }
  10558. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  10559. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10561. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  10562. if !m.op.Is(OpUpdateOne) {
  10563. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  10564. }
  10565. if m.id == nil || m.oldValue == nil {
  10566. return v, errors.New("OldTitle requires an ID field in the mutation")
  10567. }
  10568. oldValue, err := m.oldValue(ctx)
  10569. if err != nil {
  10570. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  10571. }
  10572. return oldValue.Title, nil
  10573. }
  10574. // ResetTitle resets all changes to the "title" field.
  10575. func (m *EmployeeConfigMutation) ResetTitle() {
  10576. m.title = nil
  10577. }
  10578. // SetPhoto sets the "photo" field.
  10579. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  10580. m.photo = &s
  10581. }
  10582. // Photo returns the value of the "photo" field in the mutation.
  10583. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  10584. v := m.photo
  10585. if v == nil {
  10586. return
  10587. }
  10588. return *v, true
  10589. }
  10590. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  10591. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10593. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  10594. if !m.op.Is(OpUpdateOne) {
  10595. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  10596. }
  10597. if m.id == nil || m.oldValue == nil {
  10598. return v, errors.New("OldPhoto requires an ID field in the mutation")
  10599. }
  10600. oldValue, err := m.oldValue(ctx)
  10601. if err != nil {
  10602. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  10603. }
  10604. return oldValue.Photo, nil
  10605. }
  10606. // ResetPhoto resets all changes to the "photo" field.
  10607. func (m *EmployeeConfigMutation) ResetPhoto() {
  10608. m.photo = nil
  10609. }
  10610. // SetOrganizationID sets the "organization_id" field.
  10611. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  10612. m.organization_id = &u
  10613. m.addorganization_id = nil
  10614. }
  10615. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10616. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  10617. v := m.organization_id
  10618. if v == nil {
  10619. return
  10620. }
  10621. return *v, true
  10622. }
  10623. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  10624. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10626. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10627. if !m.op.Is(OpUpdateOne) {
  10628. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10629. }
  10630. if m.id == nil || m.oldValue == nil {
  10631. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10632. }
  10633. oldValue, err := m.oldValue(ctx)
  10634. if err != nil {
  10635. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10636. }
  10637. return oldValue.OrganizationID, nil
  10638. }
  10639. // AddOrganizationID adds u to the "organization_id" field.
  10640. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  10641. if m.addorganization_id != nil {
  10642. *m.addorganization_id += u
  10643. } else {
  10644. m.addorganization_id = &u
  10645. }
  10646. }
  10647. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10648. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  10649. v := m.addorganization_id
  10650. if v == nil {
  10651. return
  10652. }
  10653. return *v, true
  10654. }
  10655. // ClearOrganizationID clears the value of the "organization_id" field.
  10656. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  10657. m.organization_id = nil
  10658. m.addorganization_id = nil
  10659. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  10660. }
  10661. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10662. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  10663. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  10664. return ok
  10665. }
  10666. // ResetOrganizationID resets all changes to the "organization_id" field.
  10667. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  10668. m.organization_id = nil
  10669. m.addorganization_id = nil
  10670. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  10671. }
  10672. // Where appends a list predicates to the EmployeeConfigMutation builder.
  10673. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  10674. m.predicates = append(m.predicates, ps...)
  10675. }
  10676. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  10677. // users can use type-assertion to append predicates that do not depend on any generated package.
  10678. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  10679. p := make([]predicate.EmployeeConfig, len(ps))
  10680. for i := range ps {
  10681. p[i] = ps[i]
  10682. }
  10683. m.Where(p...)
  10684. }
  10685. // Op returns the operation name.
  10686. func (m *EmployeeConfigMutation) Op() Op {
  10687. return m.op
  10688. }
  10689. // SetOp allows setting the mutation operation.
  10690. func (m *EmployeeConfigMutation) SetOp(op Op) {
  10691. m.op = op
  10692. }
  10693. // Type returns the node type of this mutation (EmployeeConfig).
  10694. func (m *EmployeeConfigMutation) Type() string {
  10695. return m.typ
  10696. }
  10697. // Fields returns all fields that were changed during this mutation. Note that in
  10698. // order to get all numeric fields that were incremented/decremented, call
  10699. // AddedFields().
  10700. func (m *EmployeeConfigMutation) Fields() []string {
  10701. fields := make([]string, 0, 7)
  10702. if m.created_at != nil {
  10703. fields = append(fields, employeeconfig.FieldCreatedAt)
  10704. }
  10705. if m.updated_at != nil {
  10706. fields = append(fields, employeeconfig.FieldUpdatedAt)
  10707. }
  10708. if m.deleted_at != nil {
  10709. fields = append(fields, employeeconfig.FieldDeletedAt)
  10710. }
  10711. if m.stype != nil {
  10712. fields = append(fields, employeeconfig.FieldStype)
  10713. }
  10714. if m.title != nil {
  10715. fields = append(fields, employeeconfig.FieldTitle)
  10716. }
  10717. if m.photo != nil {
  10718. fields = append(fields, employeeconfig.FieldPhoto)
  10719. }
  10720. if m.organization_id != nil {
  10721. fields = append(fields, employeeconfig.FieldOrganizationID)
  10722. }
  10723. return fields
  10724. }
  10725. // Field returns the value of a field with the given name. The second boolean
  10726. // return value indicates that this field was not set, or was not defined in the
  10727. // schema.
  10728. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  10729. switch name {
  10730. case employeeconfig.FieldCreatedAt:
  10731. return m.CreatedAt()
  10732. case employeeconfig.FieldUpdatedAt:
  10733. return m.UpdatedAt()
  10734. case employeeconfig.FieldDeletedAt:
  10735. return m.DeletedAt()
  10736. case employeeconfig.FieldStype:
  10737. return m.Stype()
  10738. case employeeconfig.FieldTitle:
  10739. return m.Title()
  10740. case employeeconfig.FieldPhoto:
  10741. return m.Photo()
  10742. case employeeconfig.FieldOrganizationID:
  10743. return m.OrganizationID()
  10744. }
  10745. return nil, false
  10746. }
  10747. // OldField returns the old value of the field from the database. An error is
  10748. // returned if the mutation operation is not UpdateOne, or the query to the
  10749. // database failed.
  10750. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10751. switch name {
  10752. case employeeconfig.FieldCreatedAt:
  10753. return m.OldCreatedAt(ctx)
  10754. case employeeconfig.FieldUpdatedAt:
  10755. return m.OldUpdatedAt(ctx)
  10756. case employeeconfig.FieldDeletedAt:
  10757. return m.OldDeletedAt(ctx)
  10758. case employeeconfig.FieldStype:
  10759. return m.OldStype(ctx)
  10760. case employeeconfig.FieldTitle:
  10761. return m.OldTitle(ctx)
  10762. case employeeconfig.FieldPhoto:
  10763. return m.OldPhoto(ctx)
  10764. case employeeconfig.FieldOrganizationID:
  10765. return m.OldOrganizationID(ctx)
  10766. }
  10767. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  10768. }
  10769. // SetField sets the value of a field with the given name. It returns an error if
  10770. // the field is not defined in the schema, or if the type mismatched the field
  10771. // type.
  10772. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  10773. switch name {
  10774. case employeeconfig.FieldCreatedAt:
  10775. v, ok := value.(time.Time)
  10776. if !ok {
  10777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10778. }
  10779. m.SetCreatedAt(v)
  10780. return nil
  10781. case employeeconfig.FieldUpdatedAt:
  10782. v, ok := value.(time.Time)
  10783. if !ok {
  10784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10785. }
  10786. m.SetUpdatedAt(v)
  10787. return nil
  10788. case employeeconfig.FieldDeletedAt:
  10789. v, ok := value.(time.Time)
  10790. if !ok {
  10791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10792. }
  10793. m.SetDeletedAt(v)
  10794. return nil
  10795. case employeeconfig.FieldStype:
  10796. v, ok := value.(string)
  10797. if !ok {
  10798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10799. }
  10800. m.SetStype(v)
  10801. return nil
  10802. case employeeconfig.FieldTitle:
  10803. v, ok := value.(string)
  10804. if !ok {
  10805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10806. }
  10807. m.SetTitle(v)
  10808. return nil
  10809. case employeeconfig.FieldPhoto:
  10810. v, ok := value.(string)
  10811. if !ok {
  10812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10813. }
  10814. m.SetPhoto(v)
  10815. return nil
  10816. case employeeconfig.FieldOrganizationID:
  10817. v, ok := value.(uint64)
  10818. if !ok {
  10819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10820. }
  10821. m.SetOrganizationID(v)
  10822. return nil
  10823. }
  10824. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10825. }
  10826. // AddedFields returns all numeric fields that were incremented/decremented during
  10827. // this mutation.
  10828. func (m *EmployeeConfigMutation) AddedFields() []string {
  10829. var fields []string
  10830. if m.addorganization_id != nil {
  10831. fields = append(fields, employeeconfig.FieldOrganizationID)
  10832. }
  10833. return fields
  10834. }
  10835. // AddedField returns the numeric value that was incremented/decremented on a field
  10836. // with the given name. The second boolean return value indicates that this field
  10837. // was not set, or was not defined in the schema.
  10838. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  10839. switch name {
  10840. case employeeconfig.FieldOrganizationID:
  10841. return m.AddedOrganizationID()
  10842. }
  10843. return nil, false
  10844. }
  10845. // AddField adds the value to the field with the given name. It returns an error if
  10846. // the field is not defined in the schema, or if the type mismatched the field
  10847. // type.
  10848. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  10849. switch name {
  10850. case employeeconfig.FieldOrganizationID:
  10851. v, ok := value.(int64)
  10852. if !ok {
  10853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10854. }
  10855. m.AddOrganizationID(v)
  10856. return nil
  10857. }
  10858. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  10859. }
  10860. // ClearedFields returns all nullable fields that were cleared during this
  10861. // mutation.
  10862. func (m *EmployeeConfigMutation) ClearedFields() []string {
  10863. var fields []string
  10864. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  10865. fields = append(fields, employeeconfig.FieldDeletedAt)
  10866. }
  10867. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  10868. fields = append(fields, employeeconfig.FieldOrganizationID)
  10869. }
  10870. return fields
  10871. }
  10872. // FieldCleared returns a boolean indicating if a field with the given name was
  10873. // cleared in this mutation.
  10874. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  10875. _, ok := m.clearedFields[name]
  10876. return ok
  10877. }
  10878. // ClearField clears the value of the field with the given name. It returns an
  10879. // error if the field is not defined in the schema.
  10880. func (m *EmployeeConfigMutation) ClearField(name string) error {
  10881. switch name {
  10882. case employeeconfig.FieldDeletedAt:
  10883. m.ClearDeletedAt()
  10884. return nil
  10885. case employeeconfig.FieldOrganizationID:
  10886. m.ClearOrganizationID()
  10887. return nil
  10888. }
  10889. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  10890. }
  10891. // ResetField resets all changes in the mutation for the field with the given name.
  10892. // It returns an error if the field is not defined in the schema.
  10893. func (m *EmployeeConfigMutation) ResetField(name string) error {
  10894. switch name {
  10895. case employeeconfig.FieldCreatedAt:
  10896. m.ResetCreatedAt()
  10897. return nil
  10898. case employeeconfig.FieldUpdatedAt:
  10899. m.ResetUpdatedAt()
  10900. return nil
  10901. case employeeconfig.FieldDeletedAt:
  10902. m.ResetDeletedAt()
  10903. return nil
  10904. case employeeconfig.FieldStype:
  10905. m.ResetStype()
  10906. return nil
  10907. case employeeconfig.FieldTitle:
  10908. m.ResetTitle()
  10909. return nil
  10910. case employeeconfig.FieldPhoto:
  10911. m.ResetPhoto()
  10912. return nil
  10913. case employeeconfig.FieldOrganizationID:
  10914. m.ResetOrganizationID()
  10915. return nil
  10916. }
  10917. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10918. }
  10919. // AddedEdges returns all edge names that were set/added in this mutation.
  10920. func (m *EmployeeConfigMutation) AddedEdges() []string {
  10921. edges := make([]string, 0, 0)
  10922. return edges
  10923. }
  10924. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10925. // name in this mutation.
  10926. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  10927. return nil
  10928. }
  10929. // RemovedEdges returns all edge names that were removed in this mutation.
  10930. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  10931. edges := make([]string, 0, 0)
  10932. return edges
  10933. }
  10934. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10935. // the given name in this mutation.
  10936. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  10937. return nil
  10938. }
  10939. // ClearedEdges returns all edge names that were cleared in this mutation.
  10940. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  10941. edges := make([]string, 0, 0)
  10942. return edges
  10943. }
  10944. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10945. // was cleared in this mutation.
  10946. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  10947. return false
  10948. }
  10949. // ClearEdge clears the value of the edge with the given name. It returns an error
  10950. // if that edge is not defined in the schema.
  10951. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  10952. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  10953. }
  10954. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10955. // It returns an error if the edge is not defined in the schema.
  10956. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  10957. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  10958. }
  10959. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  10960. type LabelMutation struct {
  10961. config
  10962. op Op
  10963. typ string
  10964. id *uint64
  10965. created_at *time.Time
  10966. updated_at *time.Time
  10967. status *uint8
  10968. addstatus *int8
  10969. _type *int
  10970. add_type *int
  10971. name *string
  10972. from *int
  10973. addfrom *int
  10974. mode *int
  10975. addmode *int
  10976. conditions *string
  10977. organization_id *uint64
  10978. addorganization_id *int64
  10979. clearedFields map[string]struct{}
  10980. label_relationships map[uint64]struct{}
  10981. removedlabel_relationships map[uint64]struct{}
  10982. clearedlabel_relationships bool
  10983. done bool
  10984. oldValue func(context.Context) (*Label, error)
  10985. predicates []predicate.Label
  10986. }
  10987. var _ ent.Mutation = (*LabelMutation)(nil)
  10988. // labelOption allows management of the mutation configuration using functional options.
  10989. type labelOption func(*LabelMutation)
  10990. // newLabelMutation creates new mutation for the Label entity.
  10991. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  10992. m := &LabelMutation{
  10993. config: c,
  10994. op: op,
  10995. typ: TypeLabel,
  10996. clearedFields: make(map[string]struct{}),
  10997. }
  10998. for _, opt := range opts {
  10999. opt(m)
  11000. }
  11001. return m
  11002. }
  11003. // withLabelID sets the ID field of the mutation.
  11004. func withLabelID(id uint64) labelOption {
  11005. return func(m *LabelMutation) {
  11006. var (
  11007. err error
  11008. once sync.Once
  11009. value *Label
  11010. )
  11011. m.oldValue = func(ctx context.Context) (*Label, error) {
  11012. once.Do(func() {
  11013. if m.done {
  11014. err = errors.New("querying old values post mutation is not allowed")
  11015. } else {
  11016. value, err = m.Client().Label.Get(ctx, id)
  11017. }
  11018. })
  11019. return value, err
  11020. }
  11021. m.id = &id
  11022. }
  11023. }
  11024. // withLabel sets the old Label of the mutation.
  11025. func withLabel(node *Label) labelOption {
  11026. return func(m *LabelMutation) {
  11027. m.oldValue = func(context.Context) (*Label, error) {
  11028. return node, nil
  11029. }
  11030. m.id = &node.ID
  11031. }
  11032. }
  11033. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11034. // executed in a transaction (ent.Tx), a transactional client is returned.
  11035. func (m LabelMutation) Client() *Client {
  11036. client := &Client{config: m.config}
  11037. client.init()
  11038. return client
  11039. }
  11040. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11041. // it returns an error otherwise.
  11042. func (m LabelMutation) Tx() (*Tx, error) {
  11043. if _, ok := m.driver.(*txDriver); !ok {
  11044. return nil, errors.New("ent: mutation is not running in a transaction")
  11045. }
  11046. tx := &Tx{config: m.config}
  11047. tx.init()
  11048. return tx, nil
  11049. }
  11050. // SetID sets the value of the id field. Note that this
  11051. // operation is only accepted on creation of Label entities.
  11052. func (m *LabelMutation) SetID(id uint64) {
  11053. m.id = &id
  11054. }
  11055. // ID returns the ID value in the mutation. Note that the ID is only available
  11056. // if it was provided to the builder or after it was returned from the database.
  11057. func (m *LabelMutation) ID() (id uint64, exists bool) {
  11058. if m.id == nil {
  11059. return
  11060. }
  11061. return *m.id, true
  11062. }
  11063. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11064. // That means, if the mutation is applied within a transaction with an isolation level such
  11065. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11066. // or updated by the mutation.
  11067. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11068. switch {
  11069. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11070. id, exists := m.ID()
  11071. if exists {
  11072. return []uint64{id}, nil
  11073. }
  11074. fallthrough
  11075. case m.op.Is(OpUpdate | OpDelete):
  11076. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11077. default:
  11078. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11079. }
  11080. }
  11081. // SetCreatedAt sets the "created_at" field.
  11082. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11083. m.created_at = &t
  11084. }
  11085. // CreatedAt returns the value of the "created_at" field in the mutation.
  11086. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11087. v := m.created_at
  11088. if v == nil {
  11089. return
  11090. }
  11091. return *v, true
  11092. }
  11093. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11094. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11096. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11097. if !m.op.Is(OpUpdateOne) {
  11098. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11099. }
  11100. if m.id == nil || m.oldValue == nil {
  11101. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11102. }
  11103. oldValue, err := m.oldValue(ctx)
  11104. if err != nil {
  11105. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11106. }
  11107. return oldValue.CreatedAt, nil
  11108. }
  11109. // ResetCreatedAt resets all changes to the "created_at" field.
  11110. func (m *LabelMutation) ResetCreatedAt() {
  11111. m.created_at = nil
  11112. }
  11113. // SetUpdatedAt sets the "updated_at" field.
  11114. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11115. m.updated_at = &t
  11116. }
  11117. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11118. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11119. v := m.updated_at
  11120. if v == nil {
  11121. return
  11122. }
  11123. return *v, true
  11124. }
  11125. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11126. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11128. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11129. if !m.op.Is(OpUpdateOne) {
  11130. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11131. }
  11132. if m.id == nil || m.oldValue == nil {
  11133. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11134. }
  11135. oldValue, err := m.oldValue(ctx)
  11136. if err != nil {
  11137. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11138. }
  11139. return oldValue.UpdatedAt, nil
  11140. }
  11141. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11142. func (m *LabelMutation) ResetUpdatedAt() {
  11143. m.updated_at = nil
  11144. }
  11145. // SetStatus sets the "status" field.
  11146. func (m *LabelMutation) SetStatus(u uint8) {
  11147. m.status = &u
  11148. m.addstatus = nil
  11149. }
  11150. // Status returns the value of the "status" field in the mutation.
  11151. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11152. v := m.status
  11153. if v == nil {
  11154. return
  11155. }
  11156. return *v, true
  11157. }
  11158. // OldStatus returns the old "status" field's value of the Label entity.
  11159. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11161. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11162. if !m.op.Is(OpUpdateOne) {
  11163. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11164. }
  11165. if m.id == nil || m.oldValue == nil {
  11166. return v, errors.New("OldStatus requires an ID field in the mutation")
  11167. }
  11168. oldValue, err := m.oldValue(ctx)
  11169. if err != nil {
  11170. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11171. }
  11172. return oldValue.Status, nil
  11173. }
  11174. // AddStatus adds u to the "status" field.
  11175. func (m *LabelMutation) AddStatus(u int8) {
  11176. if m.addstatus != nil {
  11177. *m.addstatus += u
  11178. } else {
  11179. m.addstatus = &u
  11180. }
  11181. }
  11182. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11183. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11184. v := m.addstatus
  11185. if v == nil {
  11186. return
  11187. }
  11188. return *v, true
  11189. }
  11190. // ClearStatus clears the value of the "status" field.
  11191. func (m *LabelMutation) ClearStatus() {
  11192. m.status = nil
  11193. m.addstatus = nil
  11194. m.clearedFields[label.FieldStatus] = struct{}{}
  11195. }
  11196. // StatusCleared returns if the "status" field was cleared in this mutation.
  11197. func (m *LabelMutation) StatusCleared() bool {
  11198. _, ok := m.clearedFields[label.FieldStatus]
  11199. return ok
  11200. }
  11201. // ResetStatus resets all changes to the "status" field.
  11202. func (m *LabelMutation) ResetStatus() {
  11203. m.status = nil
  11204. m.addstatus = nil
  11205. delete(m.clearedFields, label.FieldStatus)
  11206. }
  11207. // SetType sets the "type" field.
  11208. func (m *LabelMutation) SetType(i int) {
  11209. m._type = &i
  11210. m.add_type = nil
  11211. }
  11212. // GetType returns the value of the "type" field in the mutation.
  11213. func (m *LabelMutation) GetType() (r int, exists bool) {
  11214. v := m._type
  11215. if v == nil {
  11216. return
  11217. }
  11218. return *v, true
  11219. }
  11220. // OldType returns the old "type" field's value of the Label entity.
  11221. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11223. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11224. if !m.op.Is(OpUpdateOne) {
  11225. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11226. }
  11227. if m.id == nil || m.oldValue == nil {
  11228. return v, errors.New("OldType requires an ID field in the mutation")
  11229. }
  11230. oldValue, err := m.oldValue(ctx)
  11231. if err != nil {
  11232. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11233. }
  11234. return oldValue.Type, nil
  11235. }
  11236. // AddType adds i to the "type" field.
  11237. func (m *LabelMutation) AddType(i int) {
  11238. if m.add_type != nil {
  11239. *m.add_type += i
  11240. } else {
  11241. m.add_type = &i
  11242. }
  11243. }
  11244. // AddedType returns the value that was added to the "type" field in this mutation.
  11245. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11246. v := m.add_type
  11247. if v == nil {
  11248. return
  11249. }
  11250. return *v, true
  11251. }
  11252. // ResetType resets all changes to the "type" field.
  11253. func (m *LabelMutation) ResetType() {
  11254. m._type = nil
  11255. m.add_type = nil
  11256. }
  11257. // SetName sets the "name" field.
  11258. func (m *LabelMutation) SetName(s string) {
  11259. m.name = &s
  11260. }
  11261. // Name returns the value of the "name" field in the mutation.
  11262. func (m *LabelMutation) Name() (r string, exists bool) {
  11263. v := m.name
  11264. if v == nil {
  11265. return
  11266. }
  11267. return *v, true
  11268. }
  11269. // OldName returns the old "name" field's value of the Label entity.
  11270. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11272. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  11273. if !m.op.Is(OpUpdateOne) {
  11274. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11275. }
  11276. if m.id == nil || m.oldValue == nil {
  11277. return v, errors.New("OldName requires an ID field in the mutation")
  11278. }
  11279. oldValue, err := m.oldValue(ctx)
  11280. if err != nil {
  11281. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11282. }
  11283. return oldValue.Name, nil
  11284. }
  11285. // ResetName resets all changes to the "name" field.
  11286. func (m *LabelMutation) ResetName() {
  11287. m.name = nil
  11288. }
  11289. // SetFrom sets the "from" field.
  11290. func (m *LabelMutation) SetFrom(i int) {
  11291. m.from = &i
  11292. m.addfrom = nil
  11293. }
  11294. // From returns the value of the "from" field in the mutation.
  11295. func (m *LabelMutation) From() (r int, exists bool) {
  11296. v := m.from
  11297. if v == nil {
  11298. return
  11299. }
  11300. return *v, true
  11301. }
  11302. // OldFrom returns the old "from" field's value of the Label entity.
  11303. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11305. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  11306. if !m.op.Is(OpUpdateOne) {
  11307. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  11308. }
  11309. if m.id == nil || m.oldValue == nil {
  11310. return v, errors.New("OldFrom requires an ID field in the mutation")
  11311. }
  11312. oldValue, err := m.oldValue(ctx)
  11313. if err != nil {
  11314. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  11315. }
  11316. return oldValue.From, nil
  11317. }
  11318. // AddFrom adds i to the "from" field.
  11319. func (m *LabelMutation) AddFrom(i int) {
  11320. if m.addfrom != nil {
  11321. *m.addfrom += i
  11322. } else {
  11323. m.addfrom = &i
  11324. }
  11325. }
  11326. // AddedFrom returns the value that was added to the "from" field in this mutation.
  11327. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  11328. v := m.addfrom
  11329. if v == nil {
  11330. return
  11331. }
  11332. return *v, true
  11333. }
  11334. // ResetFrom resets all changes to the "from" field.
  11335. func (m *LabelMutation) ResetFrom() {
  11336. m.from = nil
  11337. m.addfrom = nil
  11338. }
  11339. // SetMode sets the "mode" field.
  11340. func (m *LabelMutation) SetMode(i int) {
  11341. m.mode = &i
  11342. m.addmode = nil
  11343. }
  11344. // Mode returns the value of the "mode" field in the mutation.
  11345. func (m *LabelMutation) Mode() (r int, exists bool) {
  11346. v := m.mode
  11347. if v == nil {
  11348. return
  11349. }
  11350. return *v, true
  11351. }
  11352. // OldMode returns the old "mode" field's value of the Label entity.
  11353. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11355. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  11356. if !m.op.Is(OpUpdateOne) {
  11357. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  11358. }
  11359. if m.id == nil || m.oldValue == nil {
  11360. return v, errors.New("OldMode requires an ID field in the mutation")
  11361. }
  11362. oldValue, err := m.oldValue(ctx)
  11363. if err != nil {
  11364. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  11365. }
  11366. return oldValue.Mode, nil
  11367. }
  11368. // AddMode adds i to the "mode" field.
  11369. func (m *LabelMutation) AddMode(i int) {
  11370. if m.addmode != nil {
  11371. *m.addmode += i
  11372. } else {
  11373. m.addmode = &i
  11374. }
  11375. }
  11376. // AddedMode returns the value that was added to the "mode" field in this mutation.
  11377. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  11378. v := m.addmode
  11379. if v == nil {
  11380. return
  11381. }
  11382. return *v, true
  11383. }
  11384. // ResetMode resets all changes to the "mode" field.
  11385. func (m *LabelMutation) ResetMode() {
  11386. m.mode = nil
  11387. m.addmode = nil
  11388. }
  11389. // SetConditions sets the "conditions" field.
  11390. func (m *LabelMutation) SetConditions(s string) {
  11391. m.conditions = &s
  11392. }
  11393. // Conditions returns the value of the "conditions" field in the mutation.
  11394. func (m *LabelMutation) Conditions() (r string, exists bool) {
  11395. v := m.conditions
  11396. if v == nil {
  11397. return
  11398. }
  11399. return *v, true
  11400. }
  11401. // OldConditions returns the old "conditions" field's value of the Label entity.
  11402. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11404. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  11405. if !m.op.Is(OpUpdateOne) {
  11406. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  11407. }
  11408. if m.id == nil || m.oldValue == nil {
  11409. return v, errors.New("OldConditions requires an ID field in the mutation")
  11410. }
  11411. oldValue, err := m.oldValue(ctx)
  11412. if err != nil {
  11413. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  11414. }
  11415. return oldValue.Conditions, nil
  11416. }
  11417. // ClearConditions clears the value of the "conditions" field.
  11418. func (m *LabelMutation) ClearConditions() {
  11419. m.conditions = nil
  11420. m.clearedFields[label.FieldConditions] = struct{}{}
  11421. }
  11422. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  11423. func (m *LabelMutation) ConditionsCleared() bool {
  11424. _, ok := m.clearedFields[label.FieldConditions]
  11425. return ok
  11426. }
  11427. // ResetConditions resets all changes to the "conditions" field.
  11428. func (m *LabelMutation) ResetConditions() {
  11429. m.conditions = nil
  11430. delete(m.clearedFields, label.FieldConditions)
  11431. }
  11432. // SetOrganizationID sets the "organization_id" field.
  11433. func (m *LabelMutation) SetOrganizationID(u uint64) {
  11434. m.organization_id = &u
  11435. m.addorganization_id = nil
  11436. }
  11437. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11438. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  11439. v := m.organization_id
  11440. if v == nil {
  11441. return
  11442. }
  11443. return *v, true
  11444. }
  11445. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  11446. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11448. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11449. if !m.op.Is(OpUpdateOne) {
  11450. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11451. }
  11452. if m.id == nil || m.oldValue == nil {
  11453. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11454. }
  11455. oldValue, err := m.oldValue(ctx)
  11456. if err != nil {
  11457. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11458. }
  11459. return oldValue.OrganizationID, nil
  11460. }
  11461. // AddOrganizationID adds u to the "organization_id" field.
  11462. func (m *LabelMutation) AddOrganizationID(u int64) {
  11463. if m.addorganization_id != nil {
  11464. *m.addorganization_id += u
  11465. } else {
  11466. m.addorganization_id = &u
  11467. }
  11468. }
  11469. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11470. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  11471. v := m.addorganization_id
  11472. if v == nil {
  11473. return
  11474. }
  11475. return *v, true
  11476. }
  11477. // ClearOrganizationID clears the value of the "organization_id" field.
  11478. func (m *LabelMutation) ClearOrganizationID() {
  11479. m.organization_id = nil
  11480. m.addorganization_id = nil
  11481. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  11482. }
  11483. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11484. func (m *LabelMutation) OrganizationIDCleared() bool {
  11485. _, ok := m.clearedFields[label.FieldOrganizationID]
  11486. return ok
  11487. }
  11488. // ResetOrganizationID resets all changes to the "organization_id" field.
  11489. func (m *LabelMutation) ResetOrganizationID() {
  11490. m.organization_id = nil
  11491. m.addorganization_id = nil
  11492. delete(m.clearedFields, label.FieldOrganizationID)
  11493. }
  11494. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  11495. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  11496. if m.label_relationships == nil {
  11497. m.label_relationships = make(map[uint64]struct{})
  11498. }
  11499. for i := range ids {
  11500. m.label_relationships[ids[i]] = struct{}{}
  11501. }
  11502. }
  11503. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  11504. func (m *LabelMutation) ClearLabelRelationships() {
  11505. m.clearedlabel_relationships = true
  11506. }
  11507. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  11508. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  11509. return m.clearedlabel_relationships
  11510. }
  11511. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  11512. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  11513. if m.removedlabel_relationships == nil {
  11514. m.removedlabel_relationships = make(map[uint64]struct{})
  11515. }
  11516. for i := range ids {
  11517. delete(m.label_relationships, ids[i])
  11518. m.removedlabel_relationships[ids[i]] = struct{}{}
  11519. }
  11520. }
  11521. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  11522. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  11523. for id := range m.removedlabel_relationships {
  11524. ids = append(ids, id)
  11525. }
  11526. return
  11527. }
  11528. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  11529. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  11530. for id := range m.label_relationships {
  11531. ids = append(ids, id)
  11532. }
  11533. return
  11534. }
  11535. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  11536. func (m *LabelMutation) ResetLabelRelationships() {
  11537. m.label_relationships = nil
  11538. m.clearedlabel_relationships = false
  11539. m.removedlabel_relationships = nil
  11540. }
  11541. // Where appends a list predicates to the LabelMutation builder.
  11542. func (m *LabelMutation) Where(ps ...predicate.Label) {
  11543. m.predicates = append(m.predicates, ps...)
  11544. }
  11545. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  11546. // users can use type-assertion to append predicates that do not depend on any generated package.
  11547. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  11548. p := make([]predicate.Label, len(ps))
  11549. for i := range ps {
  11550. p[i] = ps[i]
  11551. }
  11552. m.Where(p...)
  11553. }
  11554. // Op returns the operation name.
  11555. func (m *LabelMutation) Op() Op {
  11556. return m.op
  11557. }
  11558. // SetOp allows setting the mutation operation.
  11559. func (m *LabelMutation) SetOp(op Op) {
  11560. m.op = op
  11561. }
  11562. // Type returns the node type of this mutation (Label).
  11563. func (m *LabelMutation) Type() string {
  11564. return m.typ
  11565. }
  11566. // Fields returns all fields that were changed during this mutation. Note that in
  11567. // order to get all numeric fields that were incremented/decremented, call
  11568. // AddedFields().
  11569. func (m *LabelMutation) Fields() []string {
  11570. fields := make([]string, 0, 9)
  11571. if m.created_at != nil {
  11572. fields = append(fields, label.FieldCreatedAt)
  11573. }
  11574. if m.updated_at != nil {
  11575. fields = append(fields, label.FieldUpdatedAt)
  11576. }
  11577. if m.status != nil {
  11578. fields = append(fields, label.FieldStatus)
  11579. }
  11580. if m._type != nil {
  11581. fields = append(fields, label.FieldType)
  11582. }
  11583. if m.name != nil {
  11584. fields = append(fields, label.FieldName)
  11585. }
  11586. if m.from != nil {
  11587. fields = append(fields, label.FieldFrom)
  11588. }
  11589. if m.mode != nil {
  11590. fields = append(fields, label.FieldMode)
  11591. }
  11592. if m.conditions != nil {
  11593. fields = append(fields, label.FieldConditions)
  11594. }
  11595. if m.organization_id != nil {
  11596. fields = append(fields, label.FieldOrganizationID)
  11597. }
  11598. return fields
  11599. }
  11600. // Field returns the value of a field with the given name. The second boolean
  11601. // return value indicates that this field was not set, or was not defined in the
  11602. // schema.
  11603. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  11604. switch name {
  11605. case label.FieldCreatedAt:
  11606. return m.CreatedAt()
  11607. case label.FieldUpdatedAt:
  11608. return m.UpdatedAt()
  11609. case label.FieldStatus:
  11610. return m.Status()
  11611. case label.FieldType:
  11612. return m.GetType()
  11613. case label.FieldName:
  11614. return m.Name()
  11615. case label.FieldFrom:
  11616. return m.From()
  11617. case label.FieldMode:
  11618. return m.Mode()
  11619. case label.FieldConditions:
  11620. return m.Conditions()
  11621. case label.FieldOrganizationID:
  11622. return m.OrganizationID()
  11623. }
  11624. return nil, false
  11625. }
  11626. // OldField returns the old value of the field from the database. An error is
  11627. // returned if the mutation operation is not UpdateOne, or the query to the
  11628. // database failed.
  11629. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11630. switch name {
  11631. case label.FieldCreatedAt:
  11632. return m.OldCreatedAt(ctx)
  11633. case label.FieldUpdatedAt:
  11634. return m.OldUpdatedAt(ctx)
  11635. case label.FieldStatus:
  11636. return m.OldStatus(ctx)
  11637. case label.FieldType:
  11638. return m.OldType(ctx)
  11639. case label.FieldName:
  11640. return m.OldName(ctx)
  11641. case label.FieldFrom:
  11642. return m.OldFrom(ctx)
  11643. case label.FieldMode:
  11644. return m.OldMode(ctx)
  11645. case label.FieldConditions:
  11646. return m.OldConditions(ctx)
  11647. case label.FieldOrganizationID:
  11648. return m.OldOrganizationID(ctx)
  11649. }
  11650. return nil, fmt.Errorf("unknown Label field %s", name)
  11651. }
  11652. // SetField sets the value of a field with the given name. It returns an error if
  11653. // the field is not defined in the schema, or if the type mismatched the field
  11654. // type.
  11655. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  11656. switch name {
  11657. case label.FieldCreatedAt:
  11658. v, ok := value.(time.Time)
  11659. if !ok {
  11660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11661. }
  11662. m.SetCreatedAt(v)
  11663. return nil
  11664. case label.FieldUpdatedAt:
  11665. v, ok := value.(time.Time)
  11666. if !ok {
  11667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11668. }
  11669. m.SetUpdatedAt(v)
  11670. return nil
  11671. case label.FieldStatus:
  11672. v, ok := value.(uint8)
  11673. if !ok {
  11674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11675. }
  11676. m.SetStatus(v)
  11677. return nil
  11678. case label.FieldType:
  11679. v, ok := value.(int)
  11680. if !ok {
  11681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11682. }
  11683. m.SetType(v)
  11684. return nil
  11685. case label.FieldName:
  11686. v, ok := value.(string)
  11687. if !ok {
  11688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11689. }
  11690. m.SetName(v)
  11691. return nil
  11692. case label.FieldFrom:
  11693. v, ok := value.(int)
  11694. if !ok {
  11695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11696. }
  11697. m.SetFrom(v)
  11698. return nil
  11699. case label.FieldMode:
  11700. v, ok := value.(int)
  11701. if !ok {
  11702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11703. }
  11704. m.SetMode(v)
  11705. return nil
  11706. case label.FieldConditions:
  11707. v, ok := value.(string)
  11708. if !ok {
  11709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11710. }
  11711. m.SetConditions(v)
  11712. return nil
  11713. case label.FieldOrganizationID:
  11714. v, ok := value.(uint64)
  11715. if !ok {
  11716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11717. }
  11718. m.SetOrganizationID(v)
  11719. return nil
  11720. }
  11721. return fmt.Errorf("unknown Label field %s", name)
  11722. }
  11723. // AddedFields returns all numeric fields that were incremented/decremented during
  11724. // this mutation.
  11725. func (m *LabelMutation) AddedFields() []string {
  11726. var fields []string
  11727. if m.addstatus != nil {
  11728. fields = append(fields, label.FieldStatus)
  11729. }
  11730. if m.add_type != nil {
  11731. fields = append(fields, label.FieldType)
  11732. }
  11733. if m.addfrom != nil {
  11734. fields = append(fields, label.FieldFrom)
  11735. }
  11736. if m.addmode != nil {
  11737. fields = append(fields, label.FieldMode)
  11738. }
  11739. if m.addorganization_id != nil {
  11740. fields = append(fields, label.FieldOrganizationID)
  11741. }
  11742. return fields
  11743. }
  11744. // AddedField returns the numeric value that was incremented/decremented on a field
  11745. // with the given name. The second boolean return value indicates that this field
  11746. // was not set, or was not defined in the schema.
  11747. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  11748. switch name {
  11749. case label.FieldStatus:
  11750. return m.AddedStatus()
  11751. case label.FieldType:
  11752. return m.AddedType()
  11753. case label.FieldFrom:
  11754. return m.AddedFrom()
  11755. case label.FieldMode:
  11756. return m.AddedMode()
  11757. case label.FieldOrganizationID:
  11758. return m.AddedOrganizationID()
  11759. }
  11760. return nil, false
  11761. }
  11762. // AddField adds the value to the field with the given name. It returns an error if
  11763. // the field is not defined in the schema, or if the type mismatched the field
  11764. // type.
  11765. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  11766. switch name {
  11767. case label.FieldStatus:
  11768. v, ok := value.(int8)
  11769. if !ok {
  11770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11771. }
  11772. m.AddStatus(v)
  11773. return nil
  11774. case label.FieldType:
  11775. v, ok := value.(int)
  11776. if !ok {
  11777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11778. }
  11779. m.AddType(v)
  11780. return nil
  11781. case label.FieldFrom:
  11782. v, ok := value.(int)
  11783. if !ok {
  11784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11785. }
  11786. m.AddFrom(v)
  11787. return nil
  11788. case label.FieldMode:
  11789. v, ok := value.(int)
  11790. if !ok {
  11791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11792. }
  11793. m.AddMode(v)
  11794. return nil
  11795. case label.FieldOrganizationID:
  11796. v, ok := value.(int64)
  11797. if !ok {
  11798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11799. }
  11800. m.AddOrganizationID(v)
  11801. return nil
  11802. }
  11803. return fmt.Errorf("unknown Label numeric field %s", name)
  11804. }
  11805. // ClearedFields returns all nullable fields that were cleared during this
  11806. // mutation.
  11807. func (m *LabelMutation) ClearedFields() []string {
  11808. var fields []string
  11809. if m.FieldCleared(label.FieldStatus) {
  11810. fields = append(fields, label.FieldStatus)
  11811. }
  11812. if m.FieldCleared(label.FieldConditions) {
  11813. fields = append(fields, label.FieldConditions)
  11814. }
  11815. if m.FieldCleared(label.FieldOrganizationID) {
  11816. fields = append(fields, label.FieldOrganizationID)
  11817. }
  11818. return fields
  11819. }
  11820. // FieldCleared returns a boolean indicating if a field with the given name was
  11821. // cleared in this mutation.
  11822. func (m *LabelMutation) FieldCleared(name string) bool {
  11823. _, ok := m.clearedFields[name]
  11824. return ok
  11825. }
  11826. // ClearField clears the value of the field with the given name. It returns an
  11827. // error if the field is not defined in the schema.
  11828. func (m *LabelMutation) ClearField(name string) error {
  11829. switch name {
  11830. case label.FieldStatus:
  11831. m.ClearStatus()
  11832. return nil
  11833. case label.FieldConditions:
  11834. m.ClearConditions()
  11835. return nil
  11836. case label.FieldOrganizationID:
  11837. m.ClearOrganizationID()
  11838. return nil
  11839. }
  11840. return fmt.Errorf("unknown Label nullable field %s", name)
  11841. }
  11842. // ResetField resets all changes in the mutation for the field with the given name.
  11843. // It returns an error if the field is not defined in the schema.
  11844. func (m *LabelMutation) ResetField(name string) error {
  11845. switch name {
  11846. case label.FieldCreatedAt:
  11847. m.ResetCreatedAt()
  11848. return nil
  11849. case label.FieldUpdatedAt:
  11850. m.ResetUpdatedAt()
  11851. return nil
  11852. case label.FieldStatus:
  11853. m.ResetStatus()
  11854. return nil
  11855. case label.FieldType:
  11856. m.ResetType()
  11857. return nil
  11858. case label.FieldName:
  11859. m.ResetName()
  11860. return nil
  11861. case label.FieldFrom:
  11862. m.ResetFrom()
  11863. return nil
  11864. case label.FieldMode:
  11865. m.ResetMode()
  11866. return nil
  11867. case label.FieldConditions:
  11868. m.ResetConditions()
  11869. return nil
  11870. case label.FieldOrganizationID:
  11871. m.ResetOrganizationID()
  11872. return nil
  11873. }
  11874. return fmt.Errorf("unknown Label field %s", name)
  11875. }
  11876. // AddedEdges returns all edge names that were set/added in this mutation.
  11877. func (m *LabelMutation) AddedEdges() []string {
  11878. edges := make([]string, 0, 1)
  11879. if m.label_relationships != nil {
  11880. edges = append(edges, label.EdgeLabelRelationships)
  11881. }
  11882. return edges
  11883. }
  11884. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11885. // name in this mutation.
  11886. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  11887. switch name {
  11888. case label.EdgeLabelRelationships:
  11889. ids := make([]ent.Value, 0, len(m.label_relationships))
  11890. for id := range m.label_relationships {
  11891. ids = append(ids, id)
  11892. }
  11893. return ids
  11894. }
  11895. return nil
  11896. }
  11897. // RemovedEdges returns all edge names that were removed in this mutation.
  11898. func (m *LabelMutation) RemovedEdges() []string {
  11899. edges := make([]string, 0, 1)
  11900. if m.removedlabel_relationships != nil {
  11901. edges = append(edges, label.EdgeLabelRelationships)
  11902. }
  11903. return edges
  11904. }
  11905. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11906. // the given name in this mutation.
  11907. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  11908. switch name {
  11909. case label.EdgeLabelRelationships:
  11910. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  11911. for id := range m.removedlabel_relationships {
  11912. ids = append(ids, id)
  11913. }
  11914. return ids
  11915. }
  11916. return nil
  11917. }
  11918. // ClearedEdges returns all edge names that were cleared in this mutation.
  11919. func (m *LabelMutation) ClearedEdges() []string {
  11920. edges := make([]string, 0, 1)
  11921. if m.clearedlabel_relationships {
  11922. edges = append(edges, label.EdgeLabelRelationships)
  11923. }
  11924. return edges
  11925. }
  11926. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11927. // was cleared in this mutation.
  11928. func (m *LabelMutation) EdgeCleared(name string) bool {
  11929. switch name {
  11930. case label.EdgeLabelRelationships:
  11931. return m.clearedlabel_relationships
  11932. }
  11933. return false
  11934. }
  11935. // ClearEdge clears the value of the edge with the given name. It returns an error
  11936. // if that edge is not defined in the schema.
  11937. func (m *LabelMutation) ClearEdge(name string) error {
  11938. switch name {
  11939. }
  11940. return fmt.Errorf("unknown Label unique edge %s", name)
  11941. }
  11942. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11943. // It returns an error if the edge is not defined in the schema.
  11944. func (m *LabelMutation) ResetEdge(name string) error {
  11945. switch name {
  11946. case label.EdgeLabelRelationships:
  11947. m.ResetLabelRelationships()
  11948. return nil
  11949. }
  11950. return fmt.Errorf("unknown Label edge %s", name)
  11951. }
  11952. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  11953. type LabelRelationshipMutation struct {
  11954. config
  11955. op Op
  11956. typ string
  11957. id *uint64
  11958. created_at *time.Time
  11959. updated_at *time.Time
  11960. status *uint8
  11961. addstatus *int8
  11962. organization_id *uint64
  11963. addorganization_id *int64
  11964. clearedFields map[string]struct{}
  11965. contacts *uint64
  11966. clearedcontacts bool
  11967. labels *uint64
  11968. clearedlabels bool
  11969. done bool
  11970. oldValue func(context.Context) (*LabelRelationship, error)
  11971. predicates []predicate.LabelRelationship
  11972. }
  11973. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  11974. // labelrelationshipOption allows management of the mutation configuration using functional options.
  11975. type labelrelationshipOption func(*LabelRelationshipMutation)
  11976. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  11977. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  11978. m := &LabelRelationshipMutation{
  11979. config: c,
  11980. op: op,
  11981. typ: TypeLabelRelationship,
  11982. clearedFields: make(map[string]struct{}),
  11983. }
  11984. for _, opt := range opts {
  11985. opt(m)
  11986. }
  11987. return m
  11988. }
  11989. // withLabelRelationshipID sets the ID field of the mutation.
  11990. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  11991. return func(m *LabelRelationshipMutation) {
  11992. var (
  11993. err error
  11994. once sync.Once
  11995. value *LabelRelationship
  11996. )
  11997. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  11998. once.Do(func() {
  11999. if m.done {
  12000. err = errors.New("querying old values post mutation is not allowed")
  12001. } else {
  12002. value, err = m.Client().LabelRelationship.Get(ctx, id)
  12003. }
  12004. })
  12005. return value, err
  12006. }
  12007. m.id = &id
  12008. }
  12009. }
  12010. // withLabelRelationship sets the old LabelRelationship of the mutation.
  12011. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  12012. return func(m *LabelRelationshipMutation) {
  12013. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12014. return node, nil
  12015. }
  12016. m.id = &node.ID
  12017. }
  12018. }
  12019. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12020. // executed in a transaction (ent.Tx), a transactional client is returned.
  12021. func (m LabelRelationshipMutation) Client() *Client {
  12022. client := &Client{config: m.config}
  12023. client.init()
  12024. return client
  12025. }
  12026. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12027. // it returns an error otherwise.
  12028. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12029. if _, ok := m.driver.(*txDriver); !ok {
  12030. return nil, errors.New("ent: mutation is not running in a transaction")
  12031. }
  12032. tx := &Tx{config: m.config}
  12033. tx.init()
  12034. return tx, nil
  12035. }
  12036. // SetID sets the value of the id field. Note that this
  12037. // operation is only accepted on creation of LabelRelationship entities.
  12038. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12039. m.id = &id
  12040. }
  12041. // ID returns the ID value in the mutation. Note that the ID is only available
  12042. // if it was provided to the builder or after it was returned from the database.
  12043. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12044. if m.id == nil {
  12045. return
  12046. }
  12047. return *m.id, true
  12048. }
  12049. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12050. // That means, if the mutation is applied within a transaction with an isolation level such
  12051. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12052. // or updated by the mutation.
  12053. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12054. switch {
  12055. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12056. id, exists := m.ID()
  12057. if exists {
  12058. return []uint64{id}, nil
  12059. }
  12060. fallthrough
  12061. case m.op.Is(OpUpdate | OpDelete):
  12062. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12063. default:
  12064. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12065. }
  12066. }
  12067. // SetCreatedAt sets the "created_at" field.
  12068. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12069. m.created_at = &t
  12070. }
  12071. // CreatedAt returns the value of the "created_at" field in the mutation.
  12072. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12073. v := m.created_at
  12074. if v == nil {
  12075. return
  12076. }
  12077. return *v, true
  12078. }
  12079. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12080. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12082. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12083. if !m.op.Is(OpUpdateOne) {
  12084. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12085. }
  12086. if m.id == nil || m.oldValue == nil {
  12087. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12088. }
  12089. oldValue, err := m.oldValue(ctx)
  12090. if err != nil {
  12091. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12092. }
  12093. return oldValue.CreatedAt, nil
  12094. }
  12095. // ResetCreatedAt resets all changes to the "created_at" field.
  12096. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12097. m.created_at = nil
  12098. }
  12099. // SetUpdatedAt sets the "updated_at" field.
  12100. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12101. m.updated_at = &t
  12102. }
  12103. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12104. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12105. v := m.updated_at
  12106. if v == nil {
  12107. return
  12108. }
  12109. return *v, true
  12110. }
  12111. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12112. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12114. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12115. if !m.op.Is(OpUpdateOne) {
  12116. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12117. }
  12118. if m.id == nil || m.oldValue == nil {
  12119. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12120. }
  12121. oldValue, err := m.oldValue(ctx)
  12122. if err != nil {
  12123. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12124. }
  12125. return oldValue.UpdatedAt, nil
  12126. }
  12127. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12128. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12129. m.updated_at = nil
  12130. }
  12131. // SetStatus sets the "status" field.
  12132. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12133. m.status = &u
  12134. m.addstatus = nil
  12135. }
  12136. // Status returns the value of the "status" field in the mutation.
  12137. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12138. v := m.status
  12139. if v == nil {
  12140. return
  12141. }
  12142. return *v, true
  12143. }
  12144. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12145. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12147. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12148. if !m.op.Is(OpUpdateOne) {
  12149. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12150. }
  12151. if m.id == nil || m.oldValue == nil {
  12152. return v, errors.New("OldStatus requires an ID field in the mutation")
  12153. }
  12154. oldValue, err := m.oldValue(ctx)
  12155. if err != nil {
  12156. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12157. }
  12158. return oldValue.Status, nil
  12159. }
  12160. // AddStatus adds u to the "status" field.
  12161. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12162. if m.addstatus != nil {
  12163. *m.addstatus += u
  12164. } else {
  12165. m.addstatus = &u
  12166. }
  12167. }
  12168. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12169. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12170. v := m.addstatus
  12171. if v == nil {
  12172. return
  12173. }
  12174. return *v, true
  12175. }
  12176. // ClearStatus clears the value of the "status" field.
  12177. func (m *LabelRelationshipMutation) ClearStatus() {
  12178. m.status = nil
  12179. m.addstatus = nil
  12180. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12181. }
  12182. // StatusCleared returns if the "status" field was cleared in this mutation.
  12183. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12184. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12185. return ok
  12186. }
  12187. // ResetStatus resets all changes to the "status" field.
  12188. func (m *LabelRelationshipMutation) ResetStatus() {
  12189. m.status = nil
  12190. m.addstatus = nil
  12191. delete(m.clearedFields, labelrelationship.FieldStatus)
  12192. }
  12193. // SetLabelID sets the "label_id" field.
  12194. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12195. m.labels = &u
  12196. }
  12197. // LabelID returns the value of the "label_id" field in the mutation.
  12198. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12199. v := m.labels
  12200. if v == nil {
  12201. return
  12202. }
  12203. return *v, true
  12204. }
  12205. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12206. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12208. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12209. if !m.op.Is(OpUpdateOne) {
  12210. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12211. }
  12212. if m.id == nil || m.oldValue == nil {
  12213. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12214. }
  12215. oldValue, err := m.oldValue(ctx)
  12216. if err != nil {
  12217. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  12218. }
  12219. return oldValue.LabelID, nil
  12220. }
  12221. // ResetLabelID resets all changes to the "label_id" field.
  12222. func (m *LabelRelationshipMutation) ResetLabelID() {
  12223. m.labels = nil
  12224. }
  12225. // SetContactID sets the "contact_id" field.
  12226. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  12227. m.contacts = &u
  12228. }
  12229. // ContactID returns the value of the "contact_id" field in the mutation.
  12230. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  12231. v := m.contacts
  12232. if v == nil {
  12233. return
  12234. }
  12235. return *v, true
  12236. }
  12237. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  12238. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12240. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12241. if !m.op.Is(OpUpdateOne) {
  12242. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12243. }
  12244. if m.id == nil || m.oldValue == nil {
  12245. return v, errors.New("OldContactID requires an ID field in the mutation")
  12246. }
  12247. oldValue, err := m.oldValue(ctx)
  12248. if err != nil {
  12249. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12250. }
  12251. return oldValue.ContactID, nil
  12252. }
  12253. // ResetContactID resets all changes to the "contact_id" field.
  12254. func (m *LabelRelationshipMutation) ResetContactID() {
  12255. m.contacts = nil
  12256. }
  12257. // SetOrganizationID sets the "organization_id" field.
  12258. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  12259. m.organization_id = &u
  12260. m.addorganization_id = nil
  12261. }
  12262. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12263. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  12264. v := m.organization_id
  12265. if v == nil {
  12266. return
  12267. }
  12268. return *v, true
  12269. }
  12270. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  12271. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12273. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12274. if !m.op.Is(OpUpdateOne) {
  12275. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12276. }
  12277. if m.id == nil || m.oldValue == nil {
  12278. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12279. }
  12280. oldValue, err := m.oldValue(ctx)
  12281. if err != nil {
  12282. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12283. }
  12284. return oldValue.OrganizationID, nil
  12285. }
  12286. // AddOrganizationID adds u to the "organization_id" field.
  12287. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  12288. if m.addorganization_id != nil {
  12289. *m.addorganization_id += u
  12290. } else {
  12291. m.addorganization_id = &u
  12292. }
  12293. }
  12294. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12295. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  12296. v := m.addorganization_id
  12297. if v == nil {
  12298. return
  12299. }
  12300. return *v, true
  12301. }
  12302. // ClearOrganizationID clears the value of the "organization_id" field.
  12303. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  12304. m.organization_id = nil
  12305. m.addorganization_id = nil
  12306. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  12307. }
  12308. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12309. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  12310. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  12311. return ok
  12312. }
  12313. // ResetOrganizationID resets all changes to the "organization_id" field.
  12314. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  12315. m.organization_id = nil
  12316. m.addorganization_id = nil
  12317. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  12318. }
  12319. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  12320. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  12321. m.contacts = &id
  12322. }
  12323. // ClearContacts clears the "contacts" edge to the Contact entity.
  12324. func (m *LabelRelationshipMutation) ClearContacts() {
  12325. m.clearedcontacts = true
  12326. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  12327. }
  12328. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  12329. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  12330. return m.clearedcontacts
  12331. }
  12332. // ContactsID returns the "contacts" edge ID in the mutation.
  12333. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  12334. if m.contacts != nil {
  12335. return *m.contacts, true
  12336. }
  12337. return
  12338. }
  12339. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  12340. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12341. // ContactsID instead. It exists only for internal usage by the builders.
  12342. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  12343. if id := m.contacts; id != nil {
  12344. ids = append(ids, *id)
  12345. }
  12346. return
  12347. }
  12348. // ResetContacts resets all changes to the "contacts" edge.
  12349. func (m *LabelRelationshipMutation) ResetContacts() {
  12350. m.contacts = nil
  12351. m.clearedcontacts = false
  12352. }
  12353. // SetLabelsID sets the "labels" edge to the Label entity by id.
  12354. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  12355. m.labels = &id
  12356. }
  12357. // ClearLabels clears the "labels" edge to the Label entity.
  12358. func (m *LabelRelationshipMutation) ClearLabels() {
  12359. m.clearedlabels = true
  12360. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  12361. }
  12362. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  12363. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  12364. return m.clearedlabels
  12365. }
  12366. // LabelsID returns the "labels" edge ID in the mutation.
  12367. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  12368. if m.labels != nil {
  12369. return *m.labels, true
  12370. }
  12371. return
  12372. }
  12373. // LabelsIDs returns the "labels" edge IDs in the mutation.
  12374. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12375. // LabelsID instead. It exists only for internal usage by the builders.
  12376. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  12377. if id := m.labels; id != nil {
  12378. ids = append(ids, *id)
  12379. }
  12380. return
  12381. }
  12382. // ResetLabels resets all changes to the "labels" edge.
  12383. func (m *LabelRelationshipMutation) ResetLabels() {
  12384. m.labels = nil
  12385. m.clearedlabels = false
  12386. }
  12387. // Where appends a list predicates to the LabelRelationshipMutation builder.
  12388. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  12389. m.predicates = append(m.predicates, ps...)
  12390. }
  12391. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  12392. // users can use type-assertion to append predicates that do not depend on any generated package.
  12393. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  12394. p := make([]predicate.LabelRelationship, len(ps))
  12395. for i := range ps {
  12396. p[i] = ps[i]
  12397. }
  12398. m.Where(p...)
  12399. }
  12400. // Op returns the operation name.
  12401. func (m *LabelRelationshipMutation) Op() Op {
  12402. return m.op
  12403. }
  12404. // SetOp allows setting the mutation operation.
  12405. func (m *LabelRelationshipMutation) SetOp(op Op) {
  12406. m.op = op
  12407. }
  12408. // Type returns the node type of this mutation (LabelRelationship).
  12409. func (m *LabelRelationshipMutation) Type() string {
  12410. return m.typ
  12411. }
  12412. // Fields returns all fields that were changed during this mutation. Note that in
  12413. // order to get all numeric fields that were incremented/decremented, call
  12414. // AddedFields().
  12415. func (m *LabelRelationshipMutation) Fields() []string {
  12416. fields := make([]string, 0, 6)
  12417. if m.created_at != nil {
  12418. fields = append(fields, labelrelationship.FieldCreatedAt)
  12419. }
  12420. if m.updated_at != nil {
  12421. fields = append(fields, labelrelationship.FieldUpdatedAt)
  12422. }
  12423. if m.status != nil {
  12424. fields = append(fields, labelrelationship.FieldStatus)
  12425. }
  12426. if m.labels != nil {
  12427. fields = append(fields, labelrelationship.FieldLabelID)
  12428. }
  12429. if m.contacts != nil {
  12430. fields = append(fields, labelrelationship.FieldContactID)
  12431. }
  12432. if m.organization_id != nil {
  12433. fields = append(fields, labelrelationship.FieldOrganizationID)
  12434. }
  12435. return fields
  12436. }
  12437. // Field returns the value of a field with the given name. The second boolean
  12438. // return value indicates that this field was not set, or was not defined in the
  12439. // schema.
  12440. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  12441. switch name {
  12442. case labelrelationship.FieldCreatedAt:
  12443. return m.CreatedAt()
  12444. case labelrelationship.FieldUpdatedAt:
  12445. return m.UpdatedAt()
  12446. case labelrelationship.FieldStatus:
  12447. return m.Status()
  12448. case labelrelationship.FieldLabelID:
  12449. return m.LabelID()
  12450. case labelrelationship.FieldContactID:
  12451. return m.ContactID()
  12452. case labelrelationship.FieldOrganizationID:
  12453. return m.OrganizationID()
  12454. }
  12455. return nil, false
  12456. }
  12457. // OldField returns the old value of the field from the database. An error is
  12458. // returned if the mutation operation is not UpdateOne, or the query to the
  12459. // database failed.
  12460. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12461. switch name {
  12462. case labelrelationship.FieldCreatedAt:
  12463. return m.OldCreatedAt(ctx)
  12464. case labelrelationship.FieldUpdatedAt:
  12465. return m.OldUpdatedAt(ctx)
  12466. case labelrelationship.FieldStatus:
  12467. return m.OldStatus(ctx)
  12468. case labelrelationship.FieldLabelID:
  12469. return m.OldLabelID(ctx)
  12470. case labelrelationship.FieldContactID:
  12471. return m.OldContactID(ctx)
  12472. case labelrelationship.FieldOrganizationID:
  12473. return m.OldOrganizationID(ctx)
  12474. }
  12475. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  12476. }
  12477. // SetField sets the value of a field with the given name. It returns an error if
  12478. // the field is not defined in the schema, or if the type mismatched the field
  12479. // type.
  12480. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  12481. switch name {
  12482. case labelrelationship.FieldCreatedAt:
  12483. v, ok := value.(time.Time)
  12484. if !ok {
  12485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12486. }
  12487. m.SetCreatedAt(v)
  12488. return nil
  12489. case labelrelationship.FieldUpdatedAt:
  12490. v, ok := value.(time.Time)
  12491. if !ok {
  12492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12493. }
  12494. m.SetUpdatedAt(v)
  12495. return nil
  12496. case labelrelationship.FieldStatus:
  12497. v, ok := value.(uint8)
  12498. if !ok {
  12499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12500. }
  12501. m.SetStatus(v)
  12502. return nil
  12503. case labelrelationship.FieldLabelID:
  12504. v, ok := value.(uint64)
  12505. if !ok {
  12506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12507. }
  12508. m.SetLabelID(v)
  12509. return nil
  12510. case labelrelationship.FieldContactID:
  12511. v, ok := value.(uint64)
  12512. if !ok {
  12513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12514. }
  12515. m.SetContactID(v)
  12516. return nil
  12517. case labelrelationship.FieldOrganizationID:
  12518. v, ok := value.(uint64)
  12519. if !ok {
  12520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12521. }
  12522. m.SetOrganizationID(v)
  12523. return nil
  12524. }
  12525. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12526. }
  12527. // AddedFields returns all numeric fields that were incremented/decremented during
  12528. // this mutation.
  12529. func (m *LabelRelationshipMutation) AddedFields() []string {
  12530. var fields []string
  12531. if m.addstatus != nil {
  12532. fields = append(fields, labelrelationship.FieldStatus)
  12533. }
  12534. if m.addorganization_id != nil {
  12535. fields = append(fields, labelrelationship.FieldOrganizationID)
  12536. }
  12537. return fields
  12538. }
  12539. // AddedField returns the numeric value that was incremented/decremented on a field
  12540. // with the given name. The second boolean return value indicates that this field
  12541. // was not set, or was not defined in the schema.
  12542. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  12543. switch name {
  12544. case labelrelationship.FieldStatus:
  12545. return m.AddedStatus()
  12546. case labelrelationship.FieldOrganizationID:
  12547. return m.AddedOrganizationID()
  12548. }
  12549. return nil, false
  12550. }
  12551. // AddField adds the value to the field with the given name. It returns an error if
  12552. // the field is not defined in the schema, or if the type mismatched the field
  12553. // type.
  12554. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  12555. switch name {
  12556. case labelrelationship.FieldStatus:
  12557. v, ok := value.(int8)
  12558. if !ok {
  12559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12560. }
  12561. m.AddStatus(v)
  12562. return nil
  12563. case labelrelationship.FieldOrganizationID:
  12564. v, ok := value.(int64)
  12565. if !ok {
  12566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12567. }
  12568. m.AddOrganizationID(v)
  12569. return nil
  12570. }
  12571. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  12572. }
  12573. // ClearedFields returns all nullable fields that were cleared during this
  12574. // mutation.
  12575. func (m *LabelRelationshipMutation) ClearedFields() []string {
  12576. var fields []string
  12577. if m.FieldCleared(labelrelationship.FieldStatus) {
  12578. fields = append(fields, labelrelationship.FieldStatus)
  12579. }
  12580. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  12581. fields = append(fields, labelrelationship.FieldOrganizationID)
  12582. }
  12583. return fields
  12584. }
  12585. // FieldCleared returns a boolean indicating if a field with the given name was
  12586. // cleared in this mutation.
  12587. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  12588. _, ok := m.clearedFields[name]
  12589. return ok
  12590. }
  12591. // ClearField clears the value of the field with the given name. It returns an
  12592. // error if the field is not defined in the schema.
  12593. func (m *LabelRelationshipMutation) ClearField(name string) error {
  12594. switch name {
  12595. case labelrelationship.FieldStatus:
  12596. m.ClearStatus()
  12597. return nil
  12598. case labelrelationship.FieldOrganizationID:
  12599. m.ClearOrganizationID()
  12600. return nil
  12601. }
  12602. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  12603. }
  12604. // ResetField resets all changes in the mutation for the field with the given name.
  12605. // It returns an error if the field is not defined in the schema.
  12606. func (m *LabelRelationshipMutation) ResetField(name string) error {
  12607. switch name {
  12608. case labelrelationship.FieldCreatedAt:
  12609. m.ResetCreatedAt()
  12610. return nil
  12611. case labelrelationship.FieldUpdatedAt:
  12612. m.ResetUpdatedAt()
  12613. return nil
  12614. case labelrelationship.FieldStatus:
  12615. m.ResetStatus()
  12616. return nil
  12617. case labelrelationship.FieldLabelID:
  12618. m.ResetLabelID()
  12619. return nil
  12620. case labelrelationship.FieldContactID:
  12621. m.ResetContactID()
  12622. return nil
  12623. case labelrelationship.FieldOrganizationID:
  12624. m.ResetOrganizationID()
  12625. return nil
  12626. }
  12627. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12628. }
  12629. // AddedEdges returns all edge names that were set/added in this mutation.
  12630. func (m *LabelRelationshipMutation) AddedEdges() []string {
  12631. edges := make([]string, 0, 2)
  12632. if m.contacts != nil {
  12633. edges = append(edges, labelrelationship.EdgeContacts)
  12634. }
  12635. if m.labels != nil {
  12636. edges = append(edges, labelrelationship.EdgeLabels)
  12637. }
  12638. return edges
  12639. }
  12640. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12641. // name in this mutation.
  12642. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  12643. switch name {
  12644. case labelrelationship.EdgeContacts:
  12645. if id := m.contacts; id != nil {
  12646. return []ent.Value{*id}
  12647. }
  12648. case labelrelationship.EdgeLabels:
  12649. if id := m.labels; id != nil {
  12650. return []ent.Value{*id}
  12651. }
  12652. }
  12653. return nil
  12654. }
  12655. // RemovedEdges returns all edge names that were removed in this mutation.
  12656. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  12657. edges := make([]string, 0, 2)
  12658. return edges
  12659. }
  12660. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12661. // the given name in this mutation.
  12662. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  12663. return nil
  12664. }
  12665. // ClearedEdges returns all edge names that were cleared in this mutation.
  12666. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  12667. edges := make([]string, 0, 2)
  12668. if m.clearedcontacts {
  12669. edges = append(edges, labelrelationship.EdgeContacts)
  12670. }
  12671. if m.clearedlabels {
  12672. edges = append(edges, labelrelationship.EdgeLabels)
  12673. }
  12674. return edges
  12675. }
  12676. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12677. // was cleared in this mutation.
  12678. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  12679. switch name {
  12680. case labelrelationship.EdgeContacts:
  12681. return m.clearedcontacts
  12682. case labelrelationship.EdgeLabels:
  12683. return m.clearedlabels
  12684. }
  12685. return false
  12686. }
  12687. // ClearEdge clears the value of the edge with the given name. It returns an error
  12688. // if that edge is not defined in the schema.
  12689. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  12690. switch name {
  12691. case labelrelationship.EdgeContacts:
  12692. m.ClearContacts()
  12693. return nil
  12694. case labelrelationship.EdgeLabels:
  12695. m.ClearLabels()
  12696. return nil
  12697. }
  12698. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  12699. }
  12700. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12701. // It returns an error if the edge is not defined in the schema.
  12702. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  12703. switch name {
  12704. case labelrelationship.EdgeContacts:
  12705. m.ResetContacts()
  12706. return nil
  12707. case labelrelationship.EdgeLabels:
  12708. m.ResetLabels()
  12709. return nil
  12710. }
  12711. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  12712. }
  12713. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  12714. type MessageMutation struct {
  12715. config
  12716. op Op
  12717. typ string
  12718. id *int
  12719. wx_wxid *string
  12720. wxid *string
  12721. content *string
  12722. clearedFields map[string]struct{}
  12723. done bool
  12724. oldValue func(context.Context) (*Message, error)
  12725. predicates []predicate.Message
  12726. }
  12727. var _ ent.Mutation = (*MessageMutation)(nil)
  12728. // messageOption allows management of the mutation configuration using functional options.
  12729. type messageOption func(*MessageMutation)
  12730. // newMessageMutation creates new mutation for the Message entity.
  12731. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  12732. m := &MessageMutation{
  12733. config: c,
  12734. op: op,
  12735. typ: TypeMessage,
  12736. clearedFields: make(map[string]struct{}),
  12737. }
  12738. for _, opt := range opts {
  12739. opt(m)
  12740. }
  12741. return m
  12742. }
  12743. // withMessageID sets the ID field of the mutation.
  12744. func withMessageID(id int) messageOption {
  12745. return func(m *MessageMutation) {
  12746. var (
  12747. err error
  12748. once sync.Once
  12749. value *Message
  12750. )
  12751. m.oldValue = func(ctx context.Context) (*Message, error) {
  12752. once.Do(func() {
  12753. if m.done {
  12754. err = errors.New("querying old values post mutation is not allowed")
  12755. } else {
  12756. value, err = m.Client().Message.Get(ctx, id)
  12757. }
  12758. })
  12759. return value, err
  12760. }
  12761. m.id = &id
  12762. }
  12763. }
  12764. // withMessage sets the old Message of the mutation.
  12765. func withMessage(node *Message) messageOption {
  12766. return func(m *MessageMutation) {
  12767. m.oldValue = func(context.Context) (*Message, error) {
  12768. return node, nil
  12769. }
  12770. m.id = &node.ID
  12771. }
  12772. }
  12773. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12774. // executed in a transaction (ent.Tx), a transactional client is returned.
  12775. func (m MessageMutation) Client() *Client {
  12776. client := &Client{config: m.config}
  12777. client.init()
  12778. return client
  12779. }
  12780. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12781. // it returns an error otherwise.
  12782. func (m MessageMutation) Tx() (*Tx, error) {
  12783. if _, ok := m.driver.(*txDriver); !ok {
  12784. return nil, errors.New("ent: mutation is not running in a transaction")
  12785. }
  12786. tx := &Tx{config: m.config}
  12787. tx.init()
  12788. return tx, nil
  12789. }
  12790. // ID returns the ID value in the mutation. Note that the ID is only available
  12791. // if it was provided to the builder or after it was returned from the database.
  12792. func (m *MessageMutation) ID() (id int, exists bool) {
  12793. if m.id == nil {
  12794. return
  12795. }
  12796. return *m.id, true
  12797. }
  12798. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12799. // That means, if the mutation is applied within a transaction with an isolation level such
  12800. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12801. // or updated by the mutation.
  12802. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  12803. switch {
  12804. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12805. id, exists := m.ID()
  12806. if exists {
  12807. return []int{id}, nil
  12808. }
  12809. fallthrough
  12810. case m.op.Is(OpUpdate | OpDelete):
  12811. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  12812. default:
  12813. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12814. }
  12815. }
  12816. // SetWxWxid sets the "wx_wxid" field.
  12817. func (m *MessageMutation) SetWxWxid(s string) {
  12818. m.wx_wxid = &s
  12819. }
  12820. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12821. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  12822. v := m.wx_wxid
  12823. if v == nil {
  12824. return
  12825. }
  12826. return *v, true
  12827. }
  12828. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  12829. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12831. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12832. if !m.op.Is(OpUpdateOne) {
  12833. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12834. }
  12835. if m.id == nil || m.oldValue == nil {
  12836. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12837. }
  12838. oldValue, err := m.oldValue(ctx)
  12839. if err != nil {
  12840. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12841. }
  12842. return oldValue.WxWxid, nil
  12843. }
  12844. // ClearWxWxid clears the value of the "wx_wxid" field.
  12845. func (m *MessageMutation) ClearWxWxid() {
  12846. m.wx_wxid = nil
  12847. m.clearedFields[message.FieldWxWxid] = struct{}{}
  12848. }
  12849. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  12850. func (m *MessageMutation) WxWxidCleared() bool {
  12851. _, ok := m.clearedFields[message.FieldWxWxid]
  12852. return ok
  12853. }
  12854. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12855. func (m *MessageMutation) ResetWxWxid() {
  12856. m.wx_wxid = nil
  12857. delete(m.clearedFields, message.FieldWxWxid)
  12858. }
  12859. // SetWxid sets the "wxid" field.
  12860. func (m *MessageMutation) SetWxid(s string) {
  12861. m.wxid = &s
  12862. }
  12863. // Wxid returns the value of the "wxid" field in the mutation.
  12864. func (m *MessageMutation) Wxid() (r string, exists bool) {
  12865. v := m.wxid
  12866. if v == nil {
  12867. return
  12868. }
  12869. return *v, true
  12870. }
  12871. // OldWxid returns the old "wxid" field's value of the Message entity.
  12872. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12874. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  12875. if !m.op.Is(OpUpdateOne) {
  12876. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12877. }
  12878. if m.id == nil || m.oldValue == nil {
  12879. return v, errors.New("OldWxid requires an ID field in the mutation")
  12880. }
  12881. oldValue, err := m.oldValue(ctx)
  12882. if err != nil {
  12883. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12884. }
  12885. return oldValue.Wxid, nil
  12886. }
  12887. // ResetWxid resets all changes to the "wxid" field.
  12888. func (m *MessageMutation) ResetWxid() {
  12889. m.wxid = nil
  12890. }
  12891. // SetContent sets the "content" field.
  12892. func (m *MessageMutation) SetContent(s string) {
  12893. m.content = &s
  12894. }
  12895. // Content returns the value of the "content" field in the mutation.
  12896. func (m *MessageMutation) Content() (r string, exists bool) {
  12897. v := m.content
  12898. if v == nil {
  12899. return
  12900. }
  12901. return *v, true
  12902. }
  12903. // OldContent returns the old "content" field's value of the Message entity.
  12904. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12906. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  12907. if !m.op.Is(OpUpdateOne) {
  12908. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  12909. }
  12910. if m.id == nil || m.oldValue == nil {
  12911. return v, errors.New("OldContent requires an ID field in the mutation")
  12912. }
  12913. oldValue, err := m.oldValue(ctx)
  12914. if err != nil {
  12915. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  12916. }
  12917. return oldValue.Content, nil
  12918. }
  12919. // ResetContent resets all changes to the "content" field.
  12920. func (m *MessageMutation) ResetContent() {
  12921. m.content = nil
  12922. }
  12923. // Where appends a list predicates to the MessageMutation builder.
  12924. func (m *MessageMutation) Where(ps ...predicate.Message) {
  12925. m.predicates = append(m.predicates, ps...)
  12926. }
  12927. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  12928. // users can use type-assertion to append predicates that do not depend on any generated package.
  12929. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  12930. p := make([]predicate.Message, len(ps))
  12931. for i := range ps {
  12932. p[i] = ps[i]
  12933. }
  12934. m.Where(p...)
  12935. }
  12936. // Op returns the operation name.
  12937. func (m *MessageMutation) Op() Op {
  12938. return m.op
  12939. }
  12940. // SetOp allows setting the mutation operation.
  12941. func (m *MessageMutation) SetOp(op Op) {
  12942. m.op = op
  12943. }
  12944. // Type returns the node type of this mutation (Message).
  12945. func (m *MessageMutation) Type() string {
  12946. return m.typ
  12947. }
  12948. // Fields returns all fields that were changed during this mutation. Note that in
  12949. // order to get all numeric fields that were incremented/decremented, call
  12950. // AddedFields().
  12951. func (m *MessageMutation) Fields() []string {
  12952. fields := make([]string, 0, 3)
  12953. if m.wx_wxid != nil {
  12954. fields = append(fields, message.FieldWxWxid)
  12955. }
  12956. if m.wxid != nil {
  12957. fields = append(fields, message.FieldWxid)
  12958. }
  12959. if m.content != nil {
  12960. fields = append(fields, message.FieldContent)
  12961. }
  12962. return fields
  12963. }
  12964. // Field returns the value of a field with the given name. The second boolean
  12965. // return value indicates that this field was not set, or was not defined in the
  12966. // schema.
  12967. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  12968. switch name {
  12969. case message.FieldWxWxid:
  12970. return m.WxWxid()
  12971. case message.FieldWxid:
  12972. return m.Wxid()
  12973. case message.FieldContent:
  12974. return m.Content()
  12975. }
  12976. return nil, false
  12977. }
  12978. // OldField returns the old value of the field from the database. An error is
  12979. // returned if the mutation operation is not UpdateOne, or the query to the
  12980. // database failed.
  12981. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12982. switch name {
  12983. case message.FieldWxWxid:
  12984. return m.OldWxWxid(ctx)
  12985. case message.FieldWxid:
  12986. return m.OldWxid(ctx)
  12987. case message.FieldContent:
  12988. return m.OldContent(ctx)
  12989. }
  12990. return nil, fmt.Errorf("unknown Message field %s", name)
  12991. }
  12992. // SetField sets the value of a field with the given name. It returns an error if
  12993. // the field is not defined in the schema, or if the type mismatched the field
  12994. // type.
  12995. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  12996. switch name {
  12997. case message.FieldWxWxid:
  12998. v, ok := value.(string)
  12999. if !ok {
  13000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13001. }
  13002. m.SetWxWxid(v)
  13003. return nil
  13004. case message.FieldWxid:
  13005. v, ok := value.(string)
  13006. if !ok {
  13007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13008. }
  13009. m.SetWxid(v)
  13010. return nil
  13011. case message.FieldContent:
  13012. v, ok := value.(string)
  13013. if !ok {
  13014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13015. }
  13016. m.SetContent(v)
  13017. return nil
  13018. }
  13019. return fmt.Errorf("unknown Message field %s", name)
  13020. }
  13021. // AddedFields returns all numeric fields that were incremented/decremented during
  13022. // this mutation.
  13023. func (m *MessageMutation) AddedFields() []string {
  13024. return nil
  13025. }
  13026. // AddedField returns the numeric value that was incremented/decremented on a field
  13027. // with the given name. The second boolean return value indicates that this field
  13028. // was not set, or was not defined in the schema.
  13029. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  13030. return nil, false
  13031. }
  13032. // AddField adds the value to the field with the given name. It returns an error if
  13033. // the field is not defined in the schema, or if the type mismatched the field
  13034. // type.
  13035. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  13036. switch name {
  13037. }
  13038. return fmt.Errorf("unknown Message numeric field %s", name)
  13039. }
  13040. // ClearedFields returns all nullable fields that were cleared during this
  13041. // mutation.
  13042. func (m *MessageMutation) ClearedFields() []string {
  13043. var fields []string
  13044. if m.FieldCleared(message.FieldWxWxid) {
  13045. fields = append(fields, message.FieldWxWxid)
  13046. }
  13047. return fields
  13048. }
  13049. // FieldCleared returns a boolean indicating if a field with the given name was
  13050. // cleared in this mutation.
  13051. func (m *MessageMutation) FieldCleared(name string) bool {
  13052. _, ok := m.clearedFields[name]
  13053. return ok
  13054. }
  13055. // ClearField clears the value of the field with the given name. It returns an
  13056. // error if the field is not defined in the schema.
  13057. func (m *MessageMutation) ClearField(name string) error {
  13058. switch name {
  13059. case message.FieldWxWxid:
  13060. m.ClearWxWxid()
  13061. return nil
  13062. }
  13063. return fmt.Errorf("unknown Message nullable field %s", name)
  13064. }
  13065. // ResetField resets all changes in the mutation for the field with the given name.
  13066. // It returns an error if the field is not defined in the schema.
  13067. func (m *MessageMutation) ResetField(name string) error {
  13068. switch name {
  13069. case message.FieldWxWxid:
  13070. m.ResetWxWxid()
  13071. return nil
  13072. case message.FieldWxid:
  13073. m.ResetWxid()
  13074. return nil
  13075. case message.FieldContent:
  13076. m.ResetContent()
  13077. return nil
  13078. }
  13079. return fmt.Errorf("unknown Message field %s", name)
  13080. }
  13081. // AddedEdges returns all edge names that were set/added in this mutation.
  13082. func (m *MessageMutation) AddedEdges() []string {
  13083. edges := make([]string, 0, 0)
  13084. return edges
  13085. }
  13086. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13087. // name in this mutation.
  13088. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  13089. return nil
  13090. }
  13091. // RemovedEdges returns all edge names that were removed in this mutation.
  13092. func (m *MessageMutation) RemovedEdges() []string {
  13093. edges := make([]string, 0, 0)
  13094. return edges
  13095. }
  13096. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13097. // the given name in this mutation.
  13098. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  13099. return nil
  13100. }
  13101. // ClearedEdges returns all edge names that were cleared in this mutation.
  13102. func (m *MessageMutation) ClearedEdges() []string {
  13103. edges := make([]string, 0, 0)
  13104. return edges
  13105. }
  13106. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13107. // was cleared in this mutation.
  13108. func (m *MessageMutation) EdgeCleared(name string) bool {
  13109. return false
  13110. }
  13111. // ClearEdge clears the value of the edge with the given name. It returns an error
  13112. // if that edge is not defined in the schema.
  13113. func (m *MessageMutation) ClearEdge(name string) error {
  13114. return fmt.Errorf("unknown Message unique edge %s", name)
  13115. }
  13116. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13117. // It returns an error if the edge is not defined in the schema.
  13118. func (m *MessageMutation) ResetEdge(name string) error {
  13119. return fmt.Errorf("unknown Message edge %s", name)
  13120. }
  13121. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  13122. type MessageRecordsMutation struct {
  13123. config
  13124. op Op
  13125. typ string
  13126. id *uint64
  13127. created_at *time.Time
  13128. updated_at *time.Time
  13129. status *uint8
  13130. addstatus *int8
  13131. bot_wxid *string
  13132. contact_type *int
  13133. addcontact_type *int
  13134. contact_wxid *string
  13135. content_type *int
  13136. addcontent_type *int
  13137. content *string
  13138. meta *custom_types.Meta
  13139. error_detail *string
  13140. send_time *time.Time
  13141. source_type *int
  13142. addsource_type *int
  13143. organization_id *uint64
  13144. addorganization_id *int64
  13145. clearedFields map[string]struct{}
  13146. sop_stage *uint64
  13147. clearedsop_stage bool
  13148. sop_node *uint64
  13149. clearedsop_node bool
  13150. message_contact *uint64
  13151. clearedmessage_contact bool
  13152. done bool
  13153. oldValue func(context.Context) (*MessageRecords, error)
  13154. predicates []predicate.MessageRecords
  13155. }
  13156. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  13157. // messagerecordsOption allows management of the mutation configuration using functional options.
  13158. type messagerecordsOption func(*MessageRecordsMutation)
  13159. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  13160. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  13161. m := &MessageRecordsMutation{
  13162. config: c,
  13163. op: op,
  13164. typ: TypeMessageRecords,
  13165. clearedFields: make(map[string]struct{}),
  13166. }
  13167. for _, opt := range opts {
  13168. opt(m)
  13169. }
  13170. return m
  13171. }
  13172. // withMessageRecordsID sets the ID field of the mutation.
  13173. func withMessageRecordsID(id uint64) messagerecordsOption {
  13174. return func(m *MessageRecordsMutation) {
  13175. var (
  13176. err error
  13177. once sync.Once
  13178. value *MessageRecords
  13179. )
  13180. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  13181. once.Do(func() {
  13182. if m.done {
  13183. err = errors.New("querying old values post mutation is not allowed")
  13184. } else {
  13185. value, err = m.Client().MessageRecords.Get(ctx, id)
  13186. }
  13187. })
  13188. return value, err
  13189. }
  13190. m.id = &id
  13191. }
  13192. }
  13193. // withMessageRecords sets the old MessageRecords of the mutation.
  13194. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  13195. return func(m *MessageRecordsMutation) {
  13196. m.oldValue = func(context.Context) (*MessageRecords, error) {
  13197. return node, nil
  13198. }
  13199. m.id = &node.ID
  13200. }
  13201. }
  13202. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13203. // executed in a transaction (ent.Tx), a transactional client is returned.
  13204. func (m MessageRecordsMutation) Client() *Client {
  13205. client := &Client{config: m.config}
  13206. client.init()
  13207. return client
  13208. }
  13209. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13210. // it returns an error otherwise.
  13211. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  13212. if _, ok := m.driver.(*txDriver); !ok {
  13213. return nil, errors.New("ent: mutation is not running in a transaction")
  13214. }
  13215. tx := &Tx{config: m.config}
  13216. tx.init()
  13217. return tx, nil
  13218. }
  13219. // SetID sets the value of the id field. Note that this
  13220. // operation is only accepted on creation of MessageRecords entities.
  13221. func (m *MessageRecordsMutation) SetID(id uint64) {
  13222. m.id = &id
  13223. }
  13224. // ID returns the ID value in the mutation. Note that the ID is only available
  13225. // if it was provided to the builder or after it was returned from the database.
  13226. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  13227. if m.id == nil {
  13228. return
  13229. }
  13230. return *m.id, true
  13231. }
  13232. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13233. // That means, if the mutation is applied within a transaction with an isolation level such
  13234. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13235. // or updated by the mutation.
  13236. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  13237. switch {
  13238. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13239. id, exists := m.ID()
  13240. if exists {
  13241. return []uint64{id}, nil
  13242. }
  13243. fallthrough
  13244. case m.op.Is(OpUpdate | OpDelete):
  13245. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  13246. default:
  13247. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13248. }
  13249. }
  13250. // SetCreatedAt sets the "created_at" field.
  13251. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  13252. m.created_at = &t
  13253. }
  13254. // CreatedAt returns the value of the "created_at" field in the mutation.
  13255. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  13256. v := m.created_at
  13257. if v == nil {
  13258. return
  13259. }
  13260. return *v, true
  13261. }
  13262. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  13263. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13265. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13266. if !m.op.Is(OpUpdateOne) {
  13267. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13268. }
  13269. if m.id == nil || m.oldValue == nil {
  13270. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13271. }
  13272. oldValue, err := m.oldValue(ctx)
  13273. if err != nil {
  13274. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13275. }
  13276. return oldValue.CreatedAt, nil
  13277. }
  13278. // ResetCreatedAt resets all changes to the "created_at" field.
  13279. func (m *MessageRecordsMutation) ResetCreatedAt() {
  13280. m.created_at = nil
  13281. }
  13282. // SetUpdatedAt sets the "updated_at" field.
  13283. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  13284. m.updated_at = &t
  13285. }
  13286. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13287. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  13288. v := m.updated_at
  13289. if v == nil {
  13290. return
  13291. }
  13292. return *v, true
  13293. }
  13294. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  13295. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13297. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13298. if !m.op.Is(OpUpdateOne) {
  13299. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13300. }
  13301. if m.id == nil || m.oldValue == nil {
  13302. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13303. }
  13304. oldValue, err := m.oldValue(ctx)
  13305. if err != nil {
  13306. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13307. }
  13308. return oldValue.UpdatedAt, nil
  13309. }
  13310. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13311. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  13312. m.updated_at = nil
  13313. }
  13314. // SetStatus sets the "status" field.
  13315. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  13316. m.status = &u
  13317. m.addstatus = nil
  13318. }
  13319. // Status returns the value of the "status" field in the mutation.
  13320. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  13321. v := m.status
  13322. if v == nil {
  13323. return
  13324. }
  13325. return *v, true
  13326. }
  13327. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  13328. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13330. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13331. if !m.op.Is(OpUpdateOne) {
  13332. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13333. }
  13334. if m.id == nil || m.oldValue == nil {
  13335. return v, errors.New("OldStatus requires an ID field in the mutation")
  13336. }
  13337. oldValue, err := m.oldValue(ctx)
  13338. if err != nil {
  13339. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13340. }
  13341. return oldValue.Status, nil
  13342. }
  13343. // AddStatus adds u to the "status" field.
  13344. func (m *MessageRecordsMutation) AddStatus(u int8) {
  13345. if m.addstatus != nil {
  13346. *m.addstatus += u
  13347. } else {
  13348. m.addstatus = &u
  13349. }
  13350. }
  13351. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13352. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  13353. v := m.addstatus
  13354. if v == nil {
  13355. return
  13356. }
  13357. return *v, true
  13358. }
  13359. // ClearStatus clears the value of the "status" field.
  13360. func (m *MessageRecordsMutation) ClearStatus() {
  13361. m.status = nil
  13362. m.addstatus = nil
  13363. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  13364. }
  13365. // StatusCleared returns if the "status" field was cleared in this mutation.
  13366. func (m *MessageRecordsMutation) StatusCleared() bool {
  13367. _, ok := m.clearedFields[messagerecords.FieldStatus]
  13368. return ok
  13369. }
  13370. // ResetStatus resets all changes to the "status" field.
  13371. func (m *MessageRecordsMutation) ResetStatus() {
  13372. m.status = nil
  13373. m.addstatus = nil
  13374. delete(m.clearedFields, messagerecords.FieldStatus)
  13375. }
  13376. // SetBotWxid sets the "bot_wxid" field.
  13377. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  13378. m.bot_wxid = &s
  13379. }
  13380. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  13381. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  13382. v := m.bot_wxid
  13383. if v == nil {
  13384. return
  13385. }
  13386. return *v, true
  13387. }
  13388. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  13389. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13391. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  13392. if !m.op.Is(OpUpdateOne) {
  13393. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  13394. }
  13395. if m.id == nil || m.oldValue == nil {
  13396. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  13397. }
  13398. oldValue, err := m.oldValue(ctx)
  13399. if err != nil {
  13400. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  13401. }
  13402. return oldValue.BotWxid, nil
  13403. }
  13404. // ResetBotWxid resets all changes to the "bot_wxid" field.
  13405. func (m *MessageRecordsMutation) ResetBotWxid() {
  13406. m.bot_wxid = nil
  13407. }
  13408. // SetContactID sets the "contact_id" field.
  13409. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  13410. m.message_contact = &u
  13411. }
  13412. // ContactID returns the value of the "contact_id" field in the mutation.
  13413. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  13414. v := m.message_contact
  13415. if v == nil {
  13416. return
  13417. }
  13418. return *v, true
  13419. }
  13420. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  13421. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13423. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13424. if !m.op.Is(OpUpdateOne) {
  13425. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13426. }
  13427. if m.id == nil || m.oldValue == nil {
  13428. return v, errors.New("OldContactID requires an ID field in the mutation")
  13429. }
  13430. oldValue, err := m.oldValue(ctx)
  13431. if err != nil {
  13432. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13433. }
  13434. return oldValue.ContactID, nil
  13435. }
  13436. // ClearContactID clears the value of the "contact_id" field.
  13437. func (m *MessageRecordsMutation) ClearContactID() {
  13438. m.message_contact = nil
  13439. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  13440. }
  13441. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  13442. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  13443. _, ok := m.clearedFields[messagerecords.FieldContactID]
  13444. return ok
  13445. }
  13446. // ResetContactID resets all changes to the "contact_id" field.
  13447. func (m *MessageRecordsMutation) ResetContactID() {
  13448. m.message_contact = nil
  13449. delete(m.clearedFields, messagerecords.FieldContactID)
  13450. }
  13451. // SetContactType sets the "contact_type" field.
  13452. func (m *MessageRecordsMutation) SetContactType(i int) {
  13453. m.contact_type = &i
  13454. m.addcontact_type = nil
  13455. }
  13456. // ContactType returns the value of the "contact_type" field in the mutation.
  13457. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  13458. v := m.contact_type
  13459. if v == nil {
  13460. return
  13461. }
  13462. return *v, true
  13463. }
  13464. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  13465. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13467. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  13468. if !m.op.Is(OpUpdateOne) {
  13469. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  13470. }
  13471. if m.id == nil || m.oldValue == nil {
  13472. return v, errors.New("OldContactType requires an ID field in the mutation")
  13473. }
  13474. oldValue, err := m.oldValue(ctx)
  13475. if err != nil {
  13476. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  13477. }
  13478. return oldValue.ContactType, nil
  13479. }
  13480. // AddContactType adds i to the "contact_type" field.
  13481. func (m *MessageRecordsMutation) AddContactType(i int) {
  13482. if m.addcontact_type != nil {
  13483. *m.addcontact_type += i
  13484. } else {
  13485. m.addcontact_type = &i
  13486. }
  13487. }
  13488. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  13489. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  13490. v := m.addcontact_type
  13491. if v == nil {
  13492. return
  13493. }
  13494. return *v, true
  13495. }
  13496. // ResetContactType resets all changes to the "contact_type" field.
  13497. func (m *MessageRecordsMutation) ResetContactType() {
  13498. m.contact_type = nil
  13499. m.addcontact_type = nil
  13500. }
  13501. // SetContactWxid sets the "contact_wxid" field.
  13502. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  13503. m.contact_wxid = &s
  13504. }
  13505. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  13506. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  13507. v := m.contact_wxid
  13508. if v == nil {
  13509. return
  13510. }
  13511. return *v, true
  13512. }
  13513. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  13514. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13516. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  13517. if !m.op.Is(OpUpdateOne) {
  13518. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  13519. }
  13520. if m.id == nil || m.oldValue == nil {
  13521. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  13522. }
  13523. oldValue, err := m.oldValue(ctx)
  13524. if err != nil {
  13525. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  13526. }
  13527. return oldValue.ContactWxid, nil
  13528. }
  13529. // ResetContactWxid resets all changes to the "contact_wxid" field.
  13530. func (m *MessageRecordsMutation) ResetContactWxid() {
  13531. m.contact_wxid = nil
  13532. }
  13533. // SetContentType sets the "content_type" field.
  13534. func (m *MessageRecordsMutation) SetContentType(i int) {
  13535. m.content_type = &i
  13536. m.addcontent_type = nil
  13537. }
  13538. // ContentType returns the value of the "content_type" field in the mutation.
  13539. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  13540. v := m.content_type
  13541. if v == nil {
  13542. return
  13543. }
  13544. return *v, true
  13545. }
  13546. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  13547. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13549. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  13550. if !m.op.Is(OpUpdateOne) {
  13551. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  13552. }
  13553. if m.id == nil || m.oldValue == nil {
  13554. return v, errors.New("OldContentType requires an ID field in the mutation")
  13555. }
  13556. oldValue, err := m.oldValue(ctx)
  13557. if err != nil {
  13558. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  13559. }
  13560. return oldValue.ContentType, nil
  13561. }
  13562. // AddContentType adds i to the "content_type" field.
  13563. func (m *MessageRecordsMutation) AddContentType(i int) {
  13564. if m.addcontent_type != nil {
  13565. *m.addcontent_type += i
  13566. } else {
  13567. m.addcontent_type = &i
  13568. }
  13569. }
  13570. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  13571. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  13572. v := m.addcontent_type
  13573. if v == nil {
  13574. return
  13575. }
  13576. return *v, true
  13577. }
  13578. // ResetContentType resets all changes to the "content_type" field.
  13579. func (m *MessageRecordsMutation) ResetContentType() {
  13580. m.content_type = nil
  13581. m.addcontent_type = nil
  13582. }
  13583. // SetContent sets the "content" field.
  13584. func (m *MessageRecordsMutation) SetContent(s string) {
  13585. m.content = &s
  13586. }
  13587. // Content returns the value of the "content" field in the mutation.
  13588. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  13589. v := m.content
  13590. if v == nil {
  13591. return
  13592. }
  13593. return *v, true
  13594. }
  13595. // OldContent returns the old "content" field's value of the MessageRecords entity.
  13596. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13598. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  13599. if !m.op.Is(OpUpdateOne) {
  13600. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13601. }
  13602. if m.id == nil || m.oldValue == nil {
  13603. return v, errors.New("OldContent requires an ID field in the mutation")
  13604. }
  13605. oldValue, err := m.oldValue(ctx)
  13606. if err != nil {
  13607. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13608. }
  13609. return oldValue.Content, nil
  13610. }
  13611. // ResetContent resets all changes to the "content" field.
  13612. func (m *MessageRecordsMutation) ResetContent() {
  13613. m.content = nil
  13614. }
  13615. // SetMeta sets the "meta" field.
  13616. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  13617. m.meta = &ct
  13618. }
  13619. // Meta returns the value of the "meta" field in the mutation.
  13620. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  13621. v := m.meta
  13622. if v == nil {
  13623. return
  13624. }
  13625. return *v, true
  13626. }
  13627. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  13628. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13630. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  13631. if !m.op.Is(OpUpdateOne) {
  13632. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  13633. }
  13634. if m.id == nil || m.oldValue == nil {
  13635. return v, errors.New("OldMeta requires an ID field in the mutation")
  13636. }
  13637. oldValue, err := m.oldValue(ctx)
  13638. if err != nil {
  13639. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  13640. }
  13641. return oldValue.Meta, nil
  13642. }
  13643. // ClearMeta clears the value of the "meta" field.
  13644. func (m *MessageRecordsMutation) ClearMeta() {
  13645. m.meta = nil
  13646. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  13647. }
  13648. // MetaCleared returns if the "meta" field was cleared in this mutation.
  13649. func (m *MessageRecordsMutation) MetaCleared() bool {
  13650. _, ok := m.clearedFields[messagerecords.FieldMeta]
  13651. return ok
  13652. }
  13653. // ResetMeta resets all changes to the "meta" field.
  13654. func (m *MessageRecordsMutation) ResetMeta() {
  13655. m.meta = nil
  13656. delete(m.clearedFields, messagerecords.FieldMeta)
  13657. }
  13658. // SetErrorDetail sets the "error_detail" field.
  13659. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  13660. m.error_detail = &s
  13661. }
  13662. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  13663. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  13664. v := m.error_detail
  13665. if v == nil {
  13666. return
  13667. }
  13668. return *v, true
  13669. }
  13670. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  13671. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13673. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  13674. if !m.op.Is(OpUpdateOne) {
  13675. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  13676. }
  13677. if m.id == nil || m.oldValue == nil {
  13678. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  13679. }
  13680. oldValue, err := m.oldValue(ctx)
  13681. if err != nil {
  13682. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  13683. }
  13684. return oldValue.ErrorDetail, nil
  13685. }
  13686. // ResetErrorDetail resets all changes to the "error_detail" field.
  13687. func (m *MessageRecordsMutation) ResetErrorDetail() {
  13688. m.error_detail = nil
  13689. }
  13690. // SetSendTime sets the "send_time" field.
  13691. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  13692. m.send_time = &t
  13693. }
  13694. // SendTime returns the value of the "send_time" field in the mutation.
  13695. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  13696. v := m.send_time
  13697. if v == nil {
  13698. return
  13699. }
  13700. return *v, true
  13701. }
  13702. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  13703. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13705. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  13706. if !m.op.Is(OpUpdateOne) {
  13707. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  13708. }
  13709. if m.id == nil || m.oldValue == nil {
  13710. return v, errors.New("OldSendTime requires an ID field in the mutation")
  13711. }
  13712. oldValue, err := m.oldValue(ctx)
  13713. if err != nil {
  13714. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  13715. }
  13716. return oldValue.SendTime, nil
  13717. }
  13718. // ClearSendTime clears the value of the "send_time" field.
  13719. func (m *MessageRecordsMutation) ClearSendTime() {
  13720. m.send_time = nil
  13721. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  13722. }
  13723. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  13724. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  13725. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  13726. return ok
  13727. }
  13728. // ResetSendTime resets all changes to the "send_time" field.
  13729. func (m *MessageRecordsMutation) ResetSendTime() {
  13730. m.send_time = nil
  13731. delete(m.clearedFields, messagerecords.FieldSendTime)
  13732. }
  13733. // SetSourceType sets the "source_type" field.
  13734. func (m *MessageRecordsMutation) SetSourceType(i int) {
  13735. m.source_type = &i
  13736. m.addsource_type = nil
  13737. }
  13738. // SourceType returns the value of the "source_type" field in the mutation.
  13739. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  13740. v := m.source_type
  13741. if v == nil {
  13742. return
  13743. }
  13744. return *v, true
  13745. }
  13746. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  13747. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13749. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  13750. if !m.op.Is(OpUpdateOne) {
  13751. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  13752. }
  13753. if m.id == nil || m.oldValue == nil {
  13754. return v, errors.New("OldSourceType requires an ID field in the mutation")
  13755. }
  13756. oldValue, err := m.oldValue(ctx)
  13757. if err != nil {
  13758. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  13759. }
  13760. return oldValue.SourceType, nil
  13761. }
  13762. // AddSourceType adds i to the "source_type" field.
  13763. func (m *MessageRecordsMutation) AddSourceType(i int) {
  13764. if m.addsource_type != nil {
  13765. *m.addsource_type += i
  13766. } else {
  13767. m.addsource_type = &i
  13768. }
  13769. }
  13770. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  13771. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  13772. v := m.addsource_type
  13773. if v == nil {
  13774. return
  13775. }
  13776. return *v, true
  13777. }
  13778. // ResetSourceType resets all changes to the "source_type" field.
  13779. func (m *MessageRecordsMutation) ResetSourceType() {
  13780. m.source_type = nil
  13781. m.addsource_type = nil
  13782. }
  13783. // SetSourceID sets the "source_id" field.
  13784. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  13785. m.sop_stage = &u
  13786. }
  13787. // SourceID returns the value of the "source_id" field in the mutation.
  13788. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  13789. v := m.sop_stage
  13790. if v == nil {
  13791. return
  13792. }
  13793. return *v, true
  13794. }
  13795. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  13796. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13798. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  13799. if !m.op.Is(OpUpdateOne) {
  13800. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  13801. }
  13802. if m.id == nil || m.oldValue == nil {
  13803. return v, errors.New("OldSourceID requires an ID field in the mutation")
  13804. }
  13805. oldValue, err := m.oldValue(ctx)
  13806. if err != nil {
  13807. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  13808. }
  13809. return oldValue.SourceID, nil
  13810. }
  13811. // ClearSourceID clears the value of the "source_id" field.
  13812. func (m *MessageRecordsMutation) ClearSourceID() {
  13813. m.sop_stage = nil
  13814. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13815. }
  13816. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  13817. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  13818. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  13819. return ok
  13820. }
  13821. // ResetSourceID resets all changes to the "source_id" field.
  13822. func (m *MessageRecordsMutation) ResetSourceID() {
  13823. m.sop_stage = nil
  13824. delete(m.clearedFields, messagerecords.FieldSourceID)
  13825. }
  13826. // SetSubSourceID sets the "sub_source_id" field.
  13827. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  13828. m.sop_node = &u
  13829. }
  13830. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  13831. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  13832. v := m.sop_node
  13833. if v == nil {
  13834. return
  13835. }
  13836. return *v, true
  13837. }
  13838. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  13839. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13841. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  13842. if !m.op.Is(OpUpdateOne) {
  13843. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  13844. }
  13845. if m.id == nil || m.oldValue == nil {
  13846. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  13847. }
  13848. oldValue, err := m.oldValue(ctx)
  13849. if err != nil {
  13850. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  13851. }
  13852. return oldValue.SubSourceID, nil
  13853. }
  13854. // ClearSubSourceID clears the value of the "sub_source_id" field.
  13855. func (m *MessageRecordsMutation) ClearSubSourceID() {
  13856. m.sop_node = nil
  13857. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13858. }
  13859. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  13860. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  13861. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  13862. return ok
  13863. }
  13864. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  13865. func (m *MessageRecordsMutation) ResetSubSourceID() {
  13866. m.sop_node = nil
  13867. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  13868. }
  13869. // SetOrganizationID sets the "organization_id" field.
  13870. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  13871. m.organization_id = &u
  13872. m.addorganization_id = nil
  13873. }
  13874. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13875. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  13876. v := m.organization_id
  13877. if v == nil {
  13878. return
  13879. }
  13880. return *v, true
  13881. }
  13882. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  13883. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13885. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13886. if !m.op.Is(OpUpdateOne) {
  13887. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13888. }
  13889. if m.id == nil || m.oldValue == nil {
  13890. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13891. }
  13892. oldValue, err := m.oldValue(ctx)
  13893. if err != nil {
  13894. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13895. }
  13896. return oldValue.OrganizationID, nil
  13897. }
  13898. // AddOrganizationID adds u to the "organization_id" field.
  13899. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  13900. if m.addorganization_id != nil {
  13901. *m.addorganization_id += u
  13902. } else {
  13903. m.addorganization_id = &u
  13904. }
  13905. }
  13906. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13907. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  13908. v := m.addorganization_id
  13909. if v == nil {
  13910. return
  13911. }
  13912. return *v, true
  13913. }
  13914. // ClearOrganizationID clears the value of the "organization_id" field.
  13915. func (m *MessageRecordsMutation) ClearOrganizationID() {
  13916. m.organization_id = nil
  13917. m.addorganization_id = nil
  13918. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  13919. }
  13920. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13921. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  13922. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  13923. return ok
  13924. }
  13925. // ResetOrganizationID resets all changes to the "organization_id" field.
  13926. func (m *MessageRecordsMutation) ResetOrganizationID() {
  13927. m.organization_id = nil
  13928. m.addorganization_id = nil
  13929. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  13930. }
  13931. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13932. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  13933. m.sop_stage = &id
  13934. }
  13935. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  13936. func (m *MessageRecordsMutation) ClearSopStage() {
  13937. m.clearedsop_stage = true
  13938. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13939. }
  13940. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  13941. func (m *MessageRecordsMutation) SopStageCleared() bool {
  13942. return m.SourceIDCleared() || m.clearedsop_stage
  13943. }
  13944. // SopStageID returns the "sop_stage" edge ID in the mutation.
  13945. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  13946. if m.sop_stage != nil {
  13947. return *m.sop_stage, true
  13948. }
  13949. return
  13950. }
  13951. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  13952. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13953. // SopStageID instead. It exists only for internal usage by the builders.
  13954. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  13955. if id := m.sop_stage; id != nil {
  13956. ids = append(ids, *id)
  13957. }
  13958. return
  13959. }
  13960. // ResetSopStage resets all changes to the "sop_stage" edge.
  13961. func (m *MessageRecordsMutation) ResetSopStage() {
  13962. m.sop_stage = nil
  13963. m.clearedsop_stage = false
  13964. }
  13965. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  13966. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  13967. m.sop_node = &id
  13968. }
  13969. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  13970. func (m *MessageRecordsMutation) ClearSopNode() {
  13971. m.clearedsop_node = true
  13972. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13973. }
  13974. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  13975. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  13976. return m.SubSourceIDCleared() || m.clearedsop_node
  13977. }
  13978. // SopNodeID returns the "sop_node" edge ID in the mutation.
  13979. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  13980. if m.sop_node != nil {
  13981. return *m.sop_node, true
  13982. }
  13983. return
  13984. }
  13985. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  13986. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13987. // SopNodeID instead. It exists only for internal usage by the builders.
  13988. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  13989. if id := m.sop_node; id != nil {
  13990. ids = append(ids, *id)
  13991. }
  13992. return
  13993. }
  13994. // ResetSopNode resets all changes to the "sop_node" edge.
  13995. func (m *MessageRecordsMutation) ResetSopNode() {
  13996. m.sop_node = nil
  13997. m.clearedsop_node = false
  13998. }
  13999. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  14000. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  14001. m.message_contact = &id
  14002. }
  14003. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  14004. func (m *MessageRecordsMutation) ClearMessageContact() {
  14005. m.clearedmessage_contact = true
  14006. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14007. }
  14008. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  14009. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  14010. return m.ContactIDCleared() || m.clearedmessage_contact
  14011. }
  14012. // MessageContactID returns the "message_contact" edge ID in the mutation.
  14013. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  14014. if m.message_contact != nil {
  14015. return *m.message_contact, true
  14016. }
  14017. return
  14018. }
  14019. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  14020. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14021. // MessageContactID instead. It exists only for internal usage by the builders.
  14022. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  14023. if id := m.message_contact; id != nil {
  14024. ids = append(ids, *id)
  14025. }
  14026. return
  14027. }
  14028. // ResetMessageContact resets all changes to the "message_contact" edge.
  14029. func (m *MessageRecordsMutation) ResetMessageContact() {
  14030. m.message_contact = nil
  14031. m.clearedmessage_contact = false
  14032. }
  14033. // Where appends a list predicates to the MessageRecordsMutation builder.
  14034. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  14035. m.predicates = append(m.predicates, ps...)
  14036. }
  14037. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  14038. // users can use type-assertion to append predicates that do not depend on any generated package.
  14039. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  14040. p := make([]predicate.MessageRecords, len(ps))
  14041. for i := range ps {
  14042. p[i] = ps[i]
  14043. }
  14044. m.Where(p...)
  14045. }
  14046. // Op returns the operation name.
  14047. func (m *MessageRecordsMutation) Op() Op {
  14048. return m.op
  14049. }
  14050. // SetOp allows setting the mutation operation.
  14051. func (m *MessageRecordsMutation) SetOp(op Op) {
  14052. m.op = op
  14053. }
  14054. // Type returns the node type of this mutation (MessageRecords).
  14055. func (m *MessageRecordsMutation) Type() string {
  14056. return m.typ
  14057. }
  14058. // Fields returns all fields that were changed during this mutation. Note that in
  14059. // order to get all numeric fields that were incremented/decremented, call
  14060. // AddedFields().
  14061. func (m *MessageRecordsMutation) Fields() []string {
  14062. fields := make([]string, 0, 16)
  14063. if m.created_at != nil {
  14064. fields = append(fields, messagerecords.FieldCreatedAt)
  14065. }
  14066. if m.updated_at != nil {
  14067. fields = append(fields, messagerecords.FieldUpdatedAt)
  14068. }
  14069. if m.status != nil {
  14070. fields = append(fields, messagerecords.FieldStatus)
  14071. }
  14072. if m.bot_wxid != nil {
  14073. fields = append(fields, messagerecords.FieldBotWxid)
  14074. }
  14075. if m.message_contact != nil {
  14076. fields = append(fields, messagerecords.FieldContactID)
  14077. }
  14078. if m.contact_type != nil {
  14079. fields = append(fields, messagerecords.FieldContactType)
  14080. }
  14081. if m.contact_wxid != nil {
  14082. fields = append(fields, messagerecords.FieldContactWxid)
  14083. }
  14084. if m.content_type != nil {
  14085. fields = append(fields, messagerecords.FieldContentType)
  14086. }
  14087. if m.content != nil {
  14088. fields = append(fields, messagerecords.FieldContent)
  14089. }
  14090. if m.meta != nil {
  14091. fields = append(fields, messagerecords.FieldMeta)
  14092. }
  14093. if m.error_detail != nil {
  14094. fields = append(fields, messagerecords.FieldErrorDetail)
  14095. }
  14096. if m.send_time != nil {
  14097. fields = append(fields, messagerecords.FieldSendTime)
  14098. }
  14099. if m.source_type != nil {
  14100. fields = append(fields, messagerecords.FieldSourceType)
  14101. }
  14102. if m.sop_stage != nil {
  14103. fields = append(fields, messagerecords.FieldSourceID)
  14104. }
  14105. if m.sop_node != nil {
  14106. fields = append(fields, messagerecords.FieldSubSourceID)
  14107. }
  14108. if m.organization_id != nil {
  14109. fields = append(fields, messagerecords.FieldOrganizationID)
  14110. }
  14111. return fields
  14112. }
  14113. // Field returns the value of a field with the given name. The second boolean
  14114. // return value indicates that this field was not set, or was not defined in the
  14115. // schema.
  14116. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  14117. switch name {
  14118. case messagerecords.FieldCreatedAt:
  14119. return m.CreatedAt()
  14120. case messagerecords.FieldUpdatedAt:
  14121. return m.UpdatedAt()
  14122. case messagerecords.FieldStatus:
  14123. return m.Status()
  14124. case messagerecords.FieldBotWxid:
  14125. return m.BotWxid()
  14126. case messagerecords.FieldContactID:
  14127. return m.ContactID()
  14128. case messagerecords.FieldContactType:
  14129. return m.ContactType()
  14130. case messagerecords.FieldContactWxid:
  14131. return m.ContactWxid()
  14132. case messagerecords.FieldContentType:
  14133. return m.ContentType()
  14134. case messagerecords.FieldContent:
  14135. return m.Content()
  14136. case messagerecords.FieldMeta:
  14137. return m.Meta()
  14138. case messagerecords.FieldErrorDetail:
  14139. return m.ErrorDetail()
  14140. case messagerecords.FieldSendTime:
  14141. return m.SendTime()
  14142. case messagerecords.FieldSourceType:
  14143. return m.SourceType()
  14144. case messagerecords.FieldSourceID:
  14145. return m.SourceID()
  14146. case messagerecords.FieldSubSourceID:
  14147. return m.SubSourceID()
  14148. case messagerecords.FieldOrganizationID:
  14149. return m.OrganizationID()
  14150. }
  14151. return nil, false
  14152. }
  14153. // OldField returns the old value of the field from the database. An error is
  14154. // returned if the mutation operation is not UpdateOne, or the query to the
  14155. // database failed.
  14156. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14157. switch name {
  14158. case messagerecords.FieldCreatedAt:
  14159. return m.OldCreatedAt(ctx)
  14160. case messagerecords.FieldUpdatedAt:
  14161. return m.OldUpdatedAt(ctx)
  14162. case messagerecords.FieldStatus:
  14163. return m.OldStatus(ctx)
  14164. case messagerecords.FieldBotWxid:
  14165. return m.OldBotWxid(ctx)
  14166. case messagerecords.FieldContactID:
  14167. return m.OldContactID(ctx)
  14168. case messagerecords.FieldContactType:
  14169. return m.OldContactType(ctx)
  14170. case messagerecords.FieldContactWxid:
  14171. return m.OldContactWxid(ctx)
  14172. case messagerecords.FieldContentType:
  14173. return m.OldContentType(ctx)
  14174. case messagerecords.FieldContent:
  14175. return m.OldContent(ctx)
  14176. case messagerecords.FieldMeta:
  14177. return m.OldMeta(ctx)
  14178. case messagerecords.FieldErrorDetail:
  14179. return m.OldErrorDetail(ctx)
  14180. case messagerecords.FieldSendTime:
  14181. return m.OldSendTime(ctx)
  14182. case messagerecords.FieldSourceType:
  14183. return m.OldSourceType(ctx)
  14184. case messagerecords.FieldSourceID:
  14185. return m.OldSourceID(ctx)
  14186. case messagerecords.FieldSubSourceID:
  14187. return m.OldSubSourceID(ctx)
  14188. case messagerecords.FieldOrganizationID:
  14189. return m.OldOrganizationID(ctx)
  14190. }
  14191. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  14192. }
  14193. // SetField sets the value of a field with the given name. It returns an error if
  14194. // the field is not defined in the schema, or if the type mismatched the field
  14195. // type.
  14196. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  14197. switch name {
  14198. case messagerecords.FieldCreatedAt:
  14199. v, ok := value.(time.Time)
  14200. if !ok {
  14201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14202. }
  14203. m.SetCreatedAt(v)
  14204. return nil
  14205. case messagerecords.FieldUpdatedAt:
  14206. v, ok := value.(time.Time)
  14207. if !ok {
  14208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14209. }
  14210. m.SetUpdatedAt(v)
  14211. return nil
  14212. case messagerecords.FieldStatus:
  14213. v, ok := value.(uint8)
  14214. if !ok {
  14215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14216. }
  14217. m.SetStatus(v)
  14218. return nil
  14219. case messagerecords.FieldBotWxid:
  14220. v, ok := value.(string)
  14221. if !ok {
  14222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14223. }
  14224. m.SetBotWxid(v)
  14225. return nil
  14226. case messagerecords.FieldContactID:
  14227. v, ok := value.(uint64)
  14228. if !ok {
  14229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14230. }
  14231. m.SetContactID(v)
  14232. return nil
  14233. case messagerecords.FieldContactType:
  14234. v, ok := value.(int)
  14235. if !ok {
  14236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14237. }
  14238. m.SetContactType(v)
  14239. return nil
  14240. case messagerecords.FieldContactWxid:
  14241. v, ok := value.(string)
  14242. if !ok {
  14243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14244. }
  14245. m.SetContactWxid(v)
  14246. return nil
  14247. case messagerecords.FieldContentType:
  14248. v, ok := value.(int)
  14249. if !ok {
  14250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14251. }
  14252. m.SetContentType(v)
  14253. return nil
  14254. case messagerecords.FieldContent:
  14255. v, ok := value.(string)
  14256. if !ok {
  14257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14258. }
  14259. m.SetContent(v)
  14260. return nil
  14261. case messagerecords.FieldMeta:
  14262. v, ok := value.(custom_types.Meta)
  14263. if !ok {
  14264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14265. }
  14266. m.SetMeta(v)
  14267. return nil
  14268. case messagerecords.FieldErrorDetail:
  14269. v, ok := value.(string)
  14270. if !ok {
  14271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14272. }
  14273. m.SetErrorDetail(v)
  14274. return nil
  14275. case messagerecords.FieldSendTime:
  14276. v, ok := value.(time.Time)
  14277. if !ok {
  14278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14279. }
  14280. m.SetSendTime(v)
  14281. return nil
  14282. case messagerecords.FieldSourceType:
  14283. v, ok := value.(int)
  14284. if !ok {
  14285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14286. }
  14287. m.SetSourceType(v)
  14288. return nil
  14289. case messagerecords.FieldSourceID:
  14290. v, ok := value.(uint64)
  14291. if !ok {
  14292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14293. }
  14294. m.SetSourceID(v)
  14295. return nil
  14296. case messagerecords.FieldSubSourceID:
  14297. v, ok := value.(uint64)
  14298. if !ok {
  14299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14300. }
  14301. m.SetSubSourceID(v)
  14302. return nil
  14303. case messagerecords.FieldOrganizationID:
  14304. v, ok := value.(uint64)
  14305. if !ok {
  14306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14307. }
  14308. m.SetOrganizationID(v)
  14309. return nil
  14310. }
  14311. return fmt.Errorf("unknown MessageRecords field %s", name)
  14312. }
  14313. // AddedFields returns all numeric fields that were incremented/decremented during
  14314. // this mutation.
  14315. func (m *MessageRecordsMutation) AddedFields() []string {
  14316. var fields []string
  14317. if m.addstatus != nil {
  14318. fields = append(fields, messagerecords.FieldStatus)
  14319. }
  14320. if m.addcontact_type != nil {
  14321. fields = append(fields, messagerecords.FieldContactType)
  14322. }
  14323. if m.addcontent_type != nil {
  14324. fields = append(fields, messagerecords.FieldContentType)
  14325. }
  14326. if m.addsource_type != nil {
  14327. fields = append(fields, messagerecords.FieldSourceType)
  14328. }
  14329. if m.addorganization_id != nil {
  14330. fields = append(fields, messagerecords.FieldOrganizationID)
  14331. }
  14332. return fields
  14333. }
  14334. // AddedField returns the numeric value that was incremented/decremented on a field
  14335. // with the given name. The second boolean return value indicates that this field
  14336. // was not set, or was not defined in the schema.
  14337. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  14338. switch name {
  14339. case messagerecords.FieldStatus:
  14340. return m.AddedStatus()
  14341. case messagerecords.FieldContactType:
  14342. return m.AddedContactType()
  14343. case messagerecords.FieldContentType:
  14344. return m.AddedContentType()
  14345. case messagerecords.FieldSourceType:
  14346. return m.AddedSourceType()
  14347. case messagerecords.FieldOrganizationID:
  14348. return m.AddedOrganizationID()
  14349. }
  14350. return nil, false
  14351. }
  14352. // AddField adds the value to the field with the given name. It returns an error if
  14353. // the field is not defined in the schema, or if the type mismatched the field
  14354. // type.
  14355. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  14356. switch name {
  14357. case messagerecords.FieldStatus:
  14358. v, ok := value.(int8)
  14359. if !ok {
  14360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14361. }
  14362. m.AddStatus(v)
  14363. return nil
  14364. case messagerecords.FieldContactType:
  14365. v, ok := value.(int)
  14366. if !ok {
  14367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14368. }
  14369. m.AddContactType(v)
  14370. return nil
  14371. case messagerecords.FieldContentType:
  14372. v, ok := value.(int)
  14373. if !ok {
  14374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14375. }
  14376. m.AddContentType(v)
  14377. return nil
  14378. case messagerecords.FieldSourceType:
  14379. v, ok := value.(int)
  14380. if !ok {
  14381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14382. }
  14383. m.AddSourceType(v)
  14384. return nil
  14385. case messagerecords.FieldOrganizationID:
  14386. v, ok := value.(int64)
  14387. if !ok {
  14388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14389. }
  14390. m.AddOrganizationID(v)
  14391. return nil
  14392. }
  14393. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  14394. }
  14395. // ClearedFields returns all nullable fields that were cleared during this
  14396. // mutation.
  14397. func (m *MessageRecordsMutation) ClearedFields() []string {
  14398. var fields []string
  14399. if m.FieldCleared(messagerecords.FieldStatus) {
  14400. fields = append(fields, messagerecords.FieldStatus)
  14401. }
  14402. if m.FieldCleared(messagerecords.FieldContactID) {
  14403. fields = append(fields, messagerecords.FieldContactID)
  14404. }
  14405. if m.FieldCleared(messagerecords.FieldMeta) {
  14406. fields = append(fields, messagerecords.FieldMeta)
  14407. }
  14408. if m.FieldCleared(messagerecords.FieldSendTime) {
  14409. fields = append(fields, messagerecords.FieldSendTime)
  14410. }
  14411. if m.FieldCleared(messagerecords.FieldSourceID) {
  14412. fields = append(fields, messagerecords.FieldSourceID)
  14413. }
  14414. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  14415. fields = append(fields, messagerecords.FieldSubSourceID)
  14416. }
  14417. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  14418. fields = append(fields, messagerecords.FieldOrganizationID)
  14419. }
  14420. return fields
  14421. }
  14422. // FieldCleared returns a boolean indicating if a field with the given name was
  14423. // cleared in this mutation.
  14424. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  14425. _, ok := m.clearedFields[name]
  14426. return ok
  14427. }
  14428. // ClearField clears the value of the field with the given name. It returns an
  14429. // error if the field is not defined in the schema.
  14430. func (m *MessageRecordsMutation) ClearField(name string) error {
  14431. switch name {
  14432. case messagerecords.FieldStatus:
  14433. m.ClearStatus()
  14434. return nil
  14435. case messagerecords.FieldContactID:
  14436. m.ClearContactID()
  14437. return nil
  14438. case messagerecords.FieldMeta:
  14439. m.ClearMeta()
  14440. return nil
  14441. case messagerecords.FieldSendTime:
  14442. m.ClearSendTime()
  14443. return nil
  14444. case messagerecords.FieldSourceID:
  14445. m.ClearSourceID()
  14446. return nil
  14447. case messagerecords.FieldSubSourceID:
  14448. m.ClearSubSourceID()
  14449. return nil
  14450. case messagerecords.FieldOrganizationID:
  14451. m.ClearOrganizationID()
  14452. return nil
  14453. }
  14454. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  14455. }
  14456. // ResetField resets all changes in the mutation for the field with the given name.
  14457. // It returns an error if the field is not defined in the schema.
  14458. func (m *MessageRecordsMutation) ResetField(name string) error {
  14459. switch name {
  14460. case messagerecords.FieldCreatedAt:
  14461. m.ResetCreatedAt()
  14462. return nil
  14463. case messagerecords.FieldUpdatedAt:
  14464. m.ResetUpdatedAt()
  14465. return nil
  14466. case messagerecords.FieldStatus:
  14467. m.ResetStatus()
  14468. return nil
  14469. case messagerecords.FieldBotWxid:
  14470. m.ResetBotWxid()
  14471. return nil
  14472. case messagerecords.FieldContactID:
  14473. m.ResetContactID()
  14474. return nil
  14475. case messagerecords.FieldContactType:
  14476. m.ResetContactType()
  14477. return nil
  14478. case messagerecords.FieldContactWxid:
  14479. m.ResetContactWxid()
  14480. return nil
  14481. case messagerecords.FieldContentType:
  14482. m.ResetContentType()
  14483. return nil
  14484. case messagerecords.FieldContent:
  14485. m.ResetContent()
  14486. return nil
  14487. case messagerecords.FieldMeta:
  14488. m.ResetMeta()
  14489. return nil
  14490. case messagerecords.FieldErrorDetail:
  14491. m.ResetErrorDetail()
  14492. return nil
  14493. case messagerecords.FieldSendTime:
  14494. m.ResetSendTime()
  14495. return nil
  14496. case messagerecords.FieldSourceType:
  14497. m.ResetSourceType()
  14498. return nil
  14499. case messagerecords.FieldSourceID:
  14500. m.ResetSourceID()
  14501. return nil
  14502. case messagerecords.FieldSubSourceID:
  14503. m.ResetSubSourceID()
  14504. return nil
  14505. case messagerecords.FieldOrganizationID:
  14506. m.ResetOrganizationID()
  14507. return nil
  14508. }
  14509. return fmt.Errorf("unknown MessageRecords field %s", name)
  14510. }
  14511. // AddedEdges returns all edge names that were set/added in this mutation.
  14512. func (m *MessageRecordsMutation) AddedEdges() []string {
  14513. edges := make([]string, 0, 3)
  14514. if m.sop_stage != nil {
  14515. edges = append(edges, messagerecords.EdgeSopStage)
  14516. }
  14517. if m.sop_node != nil {
  14518. edges = append(edges, messagerecords.EdgeSopNode)
  14519. }
  14520. if m.message_contact != nil {
  14521. edges = append(edges, messagerecords.EdgeMessageContact)
  14522. }
  14523. return edges
  14524. }
  14525. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14526. // name in this mutation.
  14527. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  14528. switch name {
  14529. case messagerecords.EdgeSopStage:
  14530. if id := m.sop_stage; id != nil {
  14531. return []ent.Value{*id}
  14532. }
  14533. case messagerecords.EdgeSopNode:
  14534. if id := m.sop_node; id != nil {
  14535. return []ent.Value{*id}
  14536. }
  14537. case messagerecords.EdgeMessageContact:
  14538. if id := m.message_contact; id != nil {
  14539. return []ent.Value{*id}
  14540. }
  14541. }
  14542. return nil
  14543. }
  14544. // RemovedEdges returns all edge names that were removed in this mutation.
  14545. func (m *MessageRecordsMutation) RemovedEdges() []string {
  14546. edges := make([]string, 0, 3)
  14547. return edges
  14548. }
  14549. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14550. // the given name in this mutation.
  14551. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  14552. return nil
  14553. }
  14554. // ClearedEdges returns all edge names that were cleared in this mutation.
  14555. func (m *MessageRecordsMutation) ClearedEdges() []string {
  14556. edges := make([]string, 0, 3)
  14557. if m.clearedsop_stage {
  14558. edges = append(edges, messagerecords.EdgeSopStage)
  14559. }
  14560. if m.clearedsop_node {
  14561. edges = append(edges, messagerecords.EdgeSopNode)
  14562. }
  14563. if m.clearedmessage_contact {
  14564. edges = append(edges, messagerecords.EdgeMessageContact)
  14565. }
  14566. return edges
  14567. }
  14568. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14569. // was cleared in this mutation.
  14570. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  14571. switch name {
  14572. case messagerecords.EdgeSopStage:
  14573. return m.clearedsop_stage
  14574. case messagerecords.EdgeSopNode:
  14575. return m.clearedsop_node
  14576. case messagerecords.EdgeMessageContact:
  14577. return m.clearedmessage_contact
  14578. }
  14579. return false
  14580. }
  14581. // ClearEdge clears the value of the edge with the given name. It returns an error
  14582. // if that edge is not defined in the schema.
  14583. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  14584. switch name {
  14585. case messagerecords.EdgeSopStage:
  14586. m.ClearSopStage()
  14587. return nil
  14588. case messagerecords.EdgeSopNode:
  14589. m.ClearSopNode()
  14590. return nil
  14591. case messagerecords.EdgeMessageContact:
  14592. m.ClearMessageContact()
  14593. return nil
  14594. }
  14595. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  14596. }
  14597. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14598. // It returns an error if the edge is not defined in the schema.
  14599. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  14600. switch name {
  14601. case messagerecords.EdgeSopStage:
  14602. m.ResetSopStage()
  14603. return nil
  14604. case messagerecords.EdgeSopNode:
  14605. m.ResetSopNode()
  14606. return nil
  14607. case messagerecords.EdgeMessageContact:
  14608. m.ResetMessageContact()
  14609. return nil
  14610. }
  14611. return fmt.Errorf("unknown MessageRecords edge %s", name)
  14612. }
  14613. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  14614. type MsgMutation struct {
  14615. config
  14616. op Op
  14617. typ string
  14618. id *uint64
  14619. created_at *time.Time
  14620. updated_at *time.Time
  14621. deleted_at *time.Time
  14622. status *uint8
  14623. addstatus *int8
  14624. fromwxid *string
  14625. toid *string
  14626. msgtype *int32
  14627. addmsgtype *int32
  14628. msg *string
  14629. batch_no *string
  14630. clearedFields map[string]struct{}
  14631. done bool
  14632. oldValue func(context.Context) (*Msg, error)
  14633. predicates []predicate.Msg
  14634. }
  14635. var _ ent.Mutation = (*MsgMutation)(nil)
  14636. // msgOption allows management of the mutation configuration using functional options.
  14637. type msgOption func(*MsgMutation)
  14638. // newMsgMutation creates new mutation for the Msg entity.
  14639. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  14640. m := &MsgMutation{
  14641. config: c,
  14642. op: op,
  14643. typ: TypeMsg,
  14644. clearedFields: make(map[string]struct{}),
  14645. }
  14646. for _, opt := range opts {
  14647. opt(m)
  14648. }
  14649. return m
  14650. }
  14651. // withMsgID sets the ID field of the mutation.
  14652. func withMsgID(id uint64) msgOption {
  14653. return func(m *MsgMutation) {
  14654. var (
  14655. err error
  14656. once sync.Once
  14657. value *Msg
  14658. )
  14659. m.oldValue = func(ctx context.Context) (*Msg, error) {
  14660. once.Do(func() {
  14661. if m.done {
  14662. err = errors.New("querying old values post mutation is not allowed")
  14663. } else {
  14664. value, err = m.Client().Msg.Get(ctx, id)
  14665. }
  14666. })
  14667. return value, err
  14668. }
  14669. m.id = &id
  14670. }
  14671. }
  14672. // withMsg sets the old Msg of the mutation.
  14673. func withMsg(node *Msg) msgOption {
  14674. return func(m *MsgMutation) {
  14675. m.oldValue = func(context.Context) (*Msg, error) {
  14676. return node, nil
  14677. }
  14678. m.id = &node.ID
  14679. }
  14680. }
  14681. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14682. // executed in a transaction (ent.Tx), a transactional client is returned.
  14683. func (m MsgMutation) Client() *Client {
  14684. client := &Client{config: m.config}
  14685. client.init()
  14686. return client
  14687. }
  14688. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14689. // it returns an error otherwise.
  14690. func (m MsgMutation) Tx() (*Tx, error) {
  14691. if _, ok := m.driver.(*txDriver); !ok {
  14692. return nil, errors.New("ent: mutation is not running in a transaction")
  14693. }
  14694. tx := &Tx{config: m.config}
  14695. tx.init()
  14696. return tx, nil
  14697. }
  14698. // SetID sets the value of the id field. Note that this
  14699. // operation is only accepted on creation of Msg entities.
  14700. func (m *MsgMutation) SetID(id uint64) {
  14701. m.id = &id
  14702. }
  14703. // ID returns the ID value in the mutation. Note that the ID is only available
  14704. // if it was provided to the builder or after it was returned from the database.
  14705. func (m *MsgMutation) ID() (id uint64, exists bool) {
  14706. if m.id == nil {
  14707. return
  14708. }
  14709. return *m.id, true
  14710. }
  14711. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14712. // That means, if the mutation is applied within a transaction with an isolation level such
  14713. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14714. // or updated by the mutation.
  14715. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  14716. switch {
  14717. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14718. id, exists := m.ID()
  14719. if exists {
  14720. return []uint64{id}, nil
  14721. }
  14722. fallthrough
  14723. case m.op.Is(OpUpdate | OpDelete):
  14724. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  14725. default:
  14726. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14727. }
  14728. }
  14729. // SetCreatedAt sets the "created_at" field.
  14730. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  14731. m.created_at = &t
  14732. }
  14733. // CreatedAt returns the value of the "created_at" field in the mutation.
  14734. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  14735. v := m.created_at
  14736. if v == nil {
  14737. return
  14738. }
  14739. return *v, true
  14740. }
  14741. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  14742. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14744. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14745. if !m.op.Is(OpUpdateOne) {
  14746. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14747. }
  14748. if m.id == nil || m.oldValue == nil {
  14749. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14750. }
  14751. oldValue, err := m.oldValue(ctx)
  14752. if err != nil {
  14753. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14754. }
  14755. return oldValue.CreatedAt, nil
  14756. }
  14757. // ResetCreatedAt resets all changes to the "created_at" field.
  14758. func (m *MsgMutation) ResetCreatedAt() {
  14759. m.created_at = nil
  14760. }
  14761. // SetUpdatedAt sets the "updated_at" field.
  14762. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  14763. m.updated_at = &t
  14764. }
  14765. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14766. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  14767. v := m.updated_at
  14768. if v == nil {
  14769. return
  14770. }
  14771. return *v, true
  14772. }
  14773. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  14774. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14776. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14777. if !m.op.Is(OpUpdateOne) {
  14778. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14779. }
  14780. if m.id == nil || m.oldValue == nil {
  14781. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14782. }
  14783. oldValue, err := m.oldValue(ctx)
  14784. if err != nil {
  14785. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14786. }
  14787. return oldValue.UpdatedAt, nil
  14788. }
  14789. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14790. func (m *MsgMutation) ResetUpdatedAt() {
  14791. m.updated_at = nil
  14792. }
  14793. // SetDeletedAt sets the "deleted_at" field.
  14794. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  14795. m.deleted_at = &t
  14796. }
  14797. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14798. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  14799. v := m.deleted_at
  14800. if v == nil {
  14801. return
  14802. }
  14803. return *v, true
  14804. }
  14805. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  14806. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14808. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14809. if !m.op.Is(OpUpdateOne) {
  14810. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14811. }
  14812. if m.id == nil || m.oldValue == nil {
  14813. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14814. }
  14815. oldValue, err := m.oldValue(ctx)
  14816. if err != nil {
  14817. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14818. }
  14819. return oldValue.DeletedAt, nil
  14820. }
  14821. // ClearDeletedAt clears the value of the "deleted_at" field.
  14822. func (m *MsgMutation) ClearDeletedAt() {
  14823. m.deleted_at = nil
  14824. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  14825. }
  14826. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14827. func (m *MsgMutation) DeletedAtCleared() bool {
  14828. _, ok := m.clearedFields[msg.FieldDeletedAt]
  14829. return ok
  14830. }
  14831. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14832. func (m *MsgMutation) ResetDeletedAt() {
  14833. m.deleted_at = nil
  14834. delete(m.clearedFields, msg.FieldDeletedAt)
  14835. }
  14836. // SetStatus sets the "status" field.
  14837. func (m *MsgMutation) SetStatus(u uint8) {
  14838. m.status = &u
  14839. m.addstatus = nil
  14840. }
  14841. // Status returns the value of the "status" field in the mutation.
  14842. func (m *MsgMutation) Status() (r uint8, exists bool) {
  14843. v := m.status
  14844. if v == nil {
  14845. return
  14846. }
  14847. return *v, true
  14848. }
  14849. // OldStatus returns the old "status" field's value of the Msg entity.
  14850. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14852. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14853. if !m.op.Is(OpUpdateOne) {
  14854. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14855. }
  14856. if m.id == nil || m.oldValue == nil {
  14857. return v, errors.New("OldStatus requires an ID field in the mutation")
  14858. }
  14859. oldValue, err := m.oldValue(ctx)
  14860. if err != nil {
  14861. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14862. }
  14863. return oldValue.Status, nil
  14864. }
  14865. // AddStatus adds u to the "status" field.
  14866. func (m *MsgMutation) AddStatus(u int8) {
  14867. if m.addstatus != nil {
  14868. *m.addstatus += u
  14869. } else {
  14870. m.addstatus = &u
  14871. }
  14872. }
  14873. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14874. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  14875. v := m.addstatus
  14876. if v == nil {
  14877. return
  14878. }
  14879. return *v, true
  14880. }
  14881. // ClearStatus clears the value of the "status" field.
  14882. func (m *MsgMutation) ClearStatus() {
  14883. m.status = nil
  14884. m.addstatus = nil
  14885. m.clearedFields[msg.FieldStatus] = struct{}{}
  14886. }
  14887. // StatusCleared returns if the "status" field was cleared in this mutation.
  14888. func (m *MsgMutation) StatusCleared() bool {
  14889. _, ok := m.clearedFields[msg.FieldStatus]
  14890. return ok
  14891. }
  14892. // ResetStatus resets all changes to the "status" field.
  14893. func (m *MsgMutation) ResetStatus() {
  14894. m.status = nil
  14895. m.addstatus = nil
  14896. delete(m.clearedFields, msg.FieldStatus)
  14897. }
  14898. // SetFromwxid sets the "fromwxid" field.
  14899. func (m *MsgMutation) SetFromwxid(s string) {
  14900. m.fromwxid = &s
  14901. }
  14902. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  14903. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  14904. v := m.fromwxid
  14905. if v == nil {
  14906. return
  14907. }
  14908. return *v, true
  14909. }
  14910. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  14911. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14913. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  14914. if !m.op.Is(OpUpdateOne) {
  14915. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  14916. }
  14917. if m.id == nil || m.oldValue == nil {
  14918. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  14919. }
  14920. oldValue, err := m.oldValue(ctx)
  14921. if err != nil {
  14922. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  14923. }
  14924. return oldValue.Fromwxid, nil
  14925. }
  14926. // ClearFromwxid clears the value of the "fromwxid" field.
  14927. func (m *MsgMutation) ClearFromwxid() {
  14928. m.fromwxid = nil
  14929. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  14930. }
  14931. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  14932. func (m *MsgMutation) FromwxidCleared() bool {
  14933. _, ok := m.clearedFields[msg.FieldFromwxid]
  14934. return ok
  14935. }
  14936. // ResetFromwxid resets all changes to the "fromwxid" field.
  14937. func (m *MsgMutation) ResetFromwxid() {
  14938. m.fromwxid = nil
  14939. delete(m.clearedFields, msg.FieldFromwxid)
  14940. }
  14941. // SetToid sets the "toid" field.
  14942. func (m *MsgMutation) SetToid(s string) {
  14943. m.toid = &s
  14944. }
  14945. // Toid returns the value of the "toid" field in the mutation.
  14946. func (m *MsgMutation) Toid() (r string, exists bool) {
  14947. v := m.toid
  14948. if v == nil {
  14949. return
  14950. }
  14951. return *v, true
  14952. }
  14953. // OldToid returns the old "toid" field's value of the Msg entity.
  14954. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14956. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  14957. if !m.op.Is(OpUpdateOne) {
  14958. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  14959. }
  14960. if m.id == nil || m.oldValue == nil {
  14961. return v, errors.New("OldToid requires an ID field in the mutation")
  14962. }
  14963. oldValue, err := m.oldValue(ctx)
  14964. if err != nil {
  14965. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  14966. }
  14967. return oldValue.Toid, nil
  14968. }
  14969. // ClearToid clears the value of the "toid" field.
  14970. func (m *MsgMutation) ClearToid() {
  14971. m.toid = nil
  14972. m.clearedFields[msg.FieldToid] = struct{}{}
  14973. }
  14974. // ToidCleared returns if the "toid" field was cleared in this mutation.
  14975. func (m *MsgMutation) ToidCleared() bool {
  14976. _, ok := m.clearedFields[msg.FieldToid]
  14977. return ok
  14978. }
  14979. // ResetToid resets all changes to the "toid" field.
  14980. func (m *MsgMutation) ResetToid() {
  14981. m.toid = nil
  14982. delete(m.clearedFields, msg.FieldToid)
  14983. }
  14984. // SetMsgtype sets the "msgtype" field.
  14985. func (m *MsgMutation) SetMsgtype(i int32) {
  14986. m.msgtype = &i
  14987. m.addmsgtype = nil
  14988. }
  14989. // Msgtype returns the value of the "msgtype" field in the mutation.
  14990. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  14991. v := m.msgtype
  14992. if v == nil {
  14993. return
  14994. }
  14995. return *v, true
  14996. }
  14997. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  14998. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15000. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  15001. if !m.op.Is(OpUpdateOne) {
  15002. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  15003. }
  15004. if m.id == nil || m.oldValue == nil {
  15005. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  15006. }
  15007. oldValue, err := m.oldValue(ctx)
  15008. if err != nil {
  15009. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  15010. }
  15011. return oldValue.Msgtype, nil
  15012. }
  15013. // AddMsgtype adds i to the "msgtype" field.
  15014. func (m *MsgMutation) AddMsgtype(i int32) {
  15015. if m.addmsgtype != nil {
  15016. *m.addmsgtype += i
  15017. } else {
  15018. m.addmsgtype = &i
  15019. }
  15020. }
  15021. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  15022. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  15023. v := m.addmsgtype
  15024. if v == nil {
  15025. return
  15026. }
  15027. return *v, true
  15028. }
  15029. // ClearMsgtype clears the value of the "msgtype" field.
  15030. func (m *MsgMutation) ClearMsgtype() {
  15031. m.msgtype = nil
  15032. m.addmsgtype = nil
  15033. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  15034. }
  15035. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  15036. func (m *MsgMutation) MsgtypeCleared() bool {
  15037. _, ok := m.clearedFields[msg.FieldMsgtype]
  15038. return ok
  15039. }
  15040. // ResetMsgtype resets all changes to the "msgtype" field.
  15041. func (m *MsgMutation) ResetMsgtype() {
  15042. m.msgtype = nil
  15043. m.addmsgtype = nil
  15044. delete(m.clearedFields, msg.FieldMsgtype)
  15045. }
  15046. // SetMsg sets the "msg" field.
  15047. func (m *MsgMutation) SetMsg(s string) {
  15048. m.msg = &s
  15049. }
  15050. // Msg returns the value of the "msg" field in the mutation.
  15051. func (m *MsgMutation) Msg() (r string, exists bool) {
  15052. v := m.msg
  15053. if v == nil {
  15054. return
  15055. }
  15056. return *v, true
  15057. }
  15058. // OldMsg returns the old "msg" field's value of the Msg entity.
  15059. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15061. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  15062. if !m.op.Is(OpUpdateOne) {
  15063. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  15064. }
  15065. if m.id == nil || m.oldValue == nil {
  15066. return v, errors.New("OldMsg requires an ID field in the mutation")
  15067. }
  15068. oldValue, err := m.oldValue(ctx)
  15069. if err != nil {
  15070. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  15071. }
  15072. return oldValue.Msg, nil
  15073. }
  15074. // ClearMsg clears the value of the "msg" field.
  15075. func (m *MsgMutation) ClearMsg() {
  15076. m.msg = nil
  15077. m.clearedFields[msg.FieldMsg] = struct{}{}
  15078. }
  15079. // MsgCleared returns if the "msg" field was cleared in this mutation.
  15080. func (m *MsgMutation) MsgCleared() bool {
  15081. _, ok := m.clearedFields[msg.FieldMsg]
  15082. return ok
  15083. }
  15084. // ResetMsg resets all changes to the "msg" field.
  15085. func (m *MsgMutation) ResetMsg() {
  15086. m.msg = nil
  15087. delete(m.clearedFields, msg.FieldMsg)
  15088. }
  15089. // SetBatchNo sets the "batch_no" field.
  15090. func (m *MsgMutation) SetBatchNo(s string) {
  15091. m.batch_no = &s
  15092. }
  15093. // BatchNo returns the value of the "batch_no" field in the mutation.
  15094. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  15095. v := m.batch_no
  15096. if v == nil {
  15097. return
  15098. }
  15099. return *v, true
  15100. }
  15101. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  15102. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15104. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  15105. if !m.op.Is(OpUpdateOne) {
  15106. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  15107. }
  15108. if m.id == nil || m.oldValue == nil {
  15109. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  15110. }
  15111. oldValue, err := m.oldValue(ctx)
  15112. if err != nil {
  15113. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  15114. }
  15115. return oldValue.BatchNo, nil
  15116. }
  15117. // ClearBatchNo clears the value of the "batch_no" field.
  15118. func (m *MsgMutation) ClearBatchNo() {
  15119. m.batch_no = nil
  15120. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  15121. }
  15122. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  15123. func (m *MsgMutation) BatchNoCleared() bool {
  15124. _, ok := m.clearedFields[msg.FieldBatchNo]
  15125. return ok
  15126. }
  15127. // ResetBatchNo resets all changes to the "batch_no" field.
  15128. func (m *MsgMutation) ResetBatchNo() {
  15129. m.batch_no = nil
  15130. delete(m.clearedFields, msg.FieldBatchNo)
  15131. }
  15132. // Where appends a list predicates to the MsgMutation builder.
  15133. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  15134. m.predicates = append(m.predicates, ps...)
  15135. }
  15136. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  15137. // users can use type-assertion to append predicates that do not depend on any generated package.
  15138. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  15139. p := make([]predicate.Msg, len(ps))
  15140. for i := range ps {
  15141. p[i] = ps[i]
  15142. }
  15143. m.Where(p...)
  15144. }
  15145. // Op returns the operation name.
  15146. func (m *MsgMutation) Op() Op {
  15147. return m.op
  15148. }
  15149. // SetOp allows setting the mutation operation.
  15150. func (m *MsgMutation) SetOp(op Op) {
  15151. m.op = op
  15152. }
  15153. // Type returns the node type of this mutation (Msg).
  15154. func (m *MsgMutation) Type() string {
  15155. return m.typ
  15156. }
  15157. // Fields returns all fields that were changed during this mutation. Note that in
  15158. // order to get all numeric fields that were incremented/decremented, call
  15159. // AddedFields().
  15160. func (m *MsgMutation) Fields() []string {
  15161. fields := make([]string, 0, 9)
  15162. if m.created_at != nil {
  15163. fields = append(fields, msg.FieldCreatedAt)
  15164. }
  15165. if m.updated_at != nil {
  15166. fields = append(fields, msg.FieldUpdatedAt)
  15167. }
  15168. if m.deleted_at != nil {
  15169. fields = append(fields, msg.FieldDeletedAt)
  15170. }
  15171. if m.status != nil {
  15172. fields = append(fields, msg.FieldStatus)
  15173. }
  15174. if m.fromwxid != nil {
  15175. fields = append(fields, msg.FieldFromwxid)
  15176. }
  15177. if m.toid != nil {
  15178. fields = append(fields, msg.FieldToid)
  15179. }
  15180. if m.msgtype != nil {
  15181. fields = append(fields, msg.FieldMsgtype)
  15182. }
  15183. if m.msg != nil {
  15184. fields = append(fields, msg.FieldMsg)
  15185. }
  15186. if m.batch_no != nil {
  15187. fields = append(fields, msg.FieldBatchNo)
  15188. }
  15189. return fields
  15190. }
  15191. // Field returns the value of a field with the given name. The second boolean
  15192. // return value indicates that this field was not set, or was not defined in the
  15193. // schema.
  15194. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  15195. switch name {
  15196. case msg.FieldCreatedAt:
  15197. return m.CreatedAt()
  15198. case msg.FieldUpdatedAt:
  15199. return m.UpdatedAt()
  15200. case msg.FieldDeletedAt:
  15201. return m.DeletedAt()
  15202. case msg.FieldStatus:
  15203. return m.Status()
  15204. case msg.FieldFromwxid:
  15205. return m.Fromwxid()
  15206. case msg.FieldToid:
  15207. return m.Toid()
  15208. case msg.FieldMsgtype:
  15209. return m.Msgtype()
  15210. case msg.FieldMsg:
  15211. return m.Msg()
  15212. case msg.FieldBatchNo:
  15213. return m.BatchNo()
  15214. }
  15215. return nil, false
  15216. }
  15217. // OldField returns the old value of the field from the database. An error is
  15218. // returned if the mutation operation is not UpdateOne, or the query to the
  15219. // database failed.
  15220. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15221. switch name {
  15222. case msg.FieldCreatedAt:
  15223. return m.OldCreatedAt(ctx)
  15224. case msg.FieldUpdatedAt:
  15225. return m.OldUpdatedAt(ctx)
  15226. case msg.FieldDeletedAt:
  15227. return m.OldDeletedAt(ctx)
  15228. case msg.FieldStatus:
  15229. return m.OldStatus(ctx)
  15230. case msg.FieldFromwxid:
  15231. return m.OldFromwxid(ctx)
  15232. case msg.FieldToid:
  15233. return m.OldToid(ctx)
  15234. case msg.FieldMsgtype:
  15235. return m.OldMsgtype(ctx)
  15236. case msg.FieldMsg:
  15237. return m.OldMsg(ctx)
  15238. case msg.FieldBatchNo:
  15239. return m.OldBatchNo(ctx)
  15240. }
  15241. return nil, fmt.Errorf("unknown Msg field %s", name)
  15242. }
  15243. // SetField sets the value of a field with the given name. It returns an error if
  15244. // the field is not defined in the schema, or if the type mismatched the field
  15245. // type.
  15246. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  15247. switch name {
  15248. case msg.FieldCreatedAt:
  15249. v, ok := value.(time.Time)
  15250. if !ok {
  15251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15252. }
  15253. m.SetCreatedAt(v)
  15254. return nil
  15255. case msg.FieldUpdatedAt:
  15256. v, ok := value.(time.Time)
  15257. if !ok {
  15258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15259. }
  15260. m.SetUpdatedAt(v)
  15261. return nil
  15262. case msg.FieldDeletedAt:
  15263. v, ok := value.(time.Time)
  15264. if !ok {
  15265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15266. }
  15267. m.SetDeletedAt(v)
  15268. return nil
  15269. case msg.FieldStatus:
  15270. v, ok := value.(uint8)
  15271. if !ok {
  15272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15273. }
  15274. m.SetStatus(v)
  15275. return nil
  15276. case msg.FieldFromwxid:
  15277. v, ok := value.(string)
  15278. if !ok {
  15279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15280. }
  15281. m.SetFromwxid(v)
  15282. return nil
  15283. case msg.FieldToid:
  15284. v, ok := value.(string)
  15285. if !ok {
  15286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15287. }
  15288. m.SetToid(v)
  15289. return nil
  15290. case msg.FieldMsgtype:
  15291. v, ok := value.(int32)
  15292. if !ok {
  15293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15294. }
  15295. m.SetMsgtype(v)
  15296. return nil
  15297. case msg.FieldMsg:
  15298. v, ok := value.(string)
  15299. if !ok {
  15300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15301. }
  15302. m.SetMsg(v)
  15303. return nil
  15304. case msg.FieldBatchNo:
  15305. v, ok := value.(string)
  15306. if !ok {
  15307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15308. }
  15309. m.SetBatchNo(v)
  15310. return nil
  15311. }
  15312. return fmt.Errorf("unknown Msg field %s", name)
  15313. }
  15314. // AddedFields returns all numeric fields that were incremented/decremented during
  15315. // this mutation.
  15316. func (m *MsgMutation) AddedFields() []string {
  15317. var fields []string
  15318. if m.addstatus != nil {
  15319. fields = append(fields, msg.FieldStatus)
  15320. }
  15321. if m.addmsgtype != nil {
  15322. fields = append(fields, msg.FieldMsgtype)
  15323. }
  15324. return fields
  15325. }
  15326. // AddedField returns the numeric value that was incremented/decremented on a field
  15327. // with the given name. The second boolean return value indicates that this field
  15328. // was not set, or was not defined in the schema.
  15329. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  15330. switch name {
  15331. case msg.FieldStatus:
  15332. return m.AddedStatus()
  15333. case msg.FieldMsgtype:
  15334. return m.AddedMsgtype()
  15335. }
  15336. return nil, false
  15337. }
  15338. // AddField adds the value to the field with the given name. It returns an error if
  15339. // the field is not defined in the schema, or if the type mismatched the field
  15340. // type.
  15341. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  15342. switch name {
  15343. case msg.FieldStatus:
  15344. v, ok := value.(int8)
  15345. if !ok {
  15346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15347. }
  15348. m.AddStatus(v)
  15349. return nil
  15350. case msg.FieldMsgtype:
  15351. v, ok := value.(int32)
  15352. if !ok {
  15353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15354. }
  15355. m.AddMsgtype(v)
  15356. return nil
  15357. }
  15358. return fmt.Errorf("unknown Msg numeric field %s", name)
  15359. }
  15360. // ClearedFields returns all nullable fields that were cleared during this
  15361. // mutation.
  15362. func (m *MsgMutation) ClearedFields() []string {
  15363. var fields []string
  15364. if m.FieldCleared(msg.FieldDeletedAt) {
  15365. fields = append(fields, msg.FieldDeletedAt)
  15366. }
  15367. if m.FieldCleared(msg.FieldStatus) {
  15368. fields = append(fields, msg.FieldStatus)
  15369. }
  15370. if m.FieldCleared(msg.FieldFromwxid) {
  15371. fields = append(fields, msg.FieldFromwxid)
  15372. }
  15373. if m.FieldCleared(msg.FieldToid) {
  15374. fields = append(fields, msg.FieldToid)
  15375. }
  15376. if m.FieldCleared(msg.FieldMsgtype) {
  15377. fields = append(fields, msg.FieldMsgtype)
  15378. }
  15379. if m.FieldCleared(msg.FieldMsg) {
  15380. fields = append(fields, msg.FieldMsg)
  15381. }
  15382. if m.FieldCleared(msg.FieldBatchNo) {
  15383. fields = append(fields, msg.FieldBatchNo)
  15384. }
  15385. return fields
  15386. }
  15387. // FieldCleared returns a boolean indicating if a field with the given name was
  15388. // cleared in this mutation.
  15389. func (m *MsgMutation) FieldCleared(name string) bool {
  15390. _, ok := m.clearedFields[name]
  15391. return ok
  15392. }
  15393. // ClearField clears the value of the field with the given name. It returns an
  15394. // error if the field is not defined in the schema.
  15395. func (m *MsgMutation) ClearField(name string) error {
  15396. switch name {
  15397. case msg.FieldDeletedAt:
  15398. m.ClearDeletedAt()
  15399. return nil
  15400. case msg.FieldStatus:
  15401. m.ClearStatus()
  15402. return nil
  15403. case msg.FieldFromwxid:
  15404. m.ClearFromwxid()
  15405. return nil
  15406. case msg.FieldToid:
  15407. m.ClearToid()
  15408. return nil
  15409. case msg.FieldMsgtype:
  15410. m.ClearMsgtype()
  15411. return nil
  15412. case msg.FieldMsg:
  15413. m.ClearMsg()
  15414. return nil
  15415. case msg.FieldBatchNo:
  15416. m.ClearBatchNo()
  15417. return nil
  15418. }
  15419. return fmt.Errorf("unknown Msg nullable field %s", name)
  15420. }
  15421. // ResetField resets all changes in the mutation for the field with the given name.
  15422. // It returns an error if the field is not defined in the schema.
  15423. func (m *MsgMutation) ResetField(name string) error {
  15424. switch name {
  15425. case msg.FieldCreatedAt:
  15426. m.ResetCreatedAt()
  15427. return nil
  15428. case msg.FieldUpdatedAt:
  15429. m.ResetUpdatedAt()
  15430. return nil
  15431. case msg.FieldDeletedAt:
  15432. m.ResetDeletedAt()
  15433. return nil
  15434. case msg.FieldStatus:
  15435. m.ResetStatus()
  15436. return nil
  15437. case msg.FieldFromwxid:
  15438. m.ResetFromwxid()
  15439. return nil
  15440. case msg.FieldToid:
  15441. m.ResetToid()
  15442. return nil
  15443. case msg.FieldMsgtype:
  15444. m.ResetMsgtype()
  15445. return nil
  15446. case msg.FieldMsg:
  15447. m.ResetMsg()
  15448. return nil
  15449. case msg.FieldBatchNo:
  15450. m.ResetBatchNo()
  15451. return nil
  15452. }
  15453. return fmt.Errorf("unknown Msg field %s", name)
  15454. }
  15455. // AddedEdges returns all edge names that were set/added in this mutation.
  15456. func (m *MsgMutation) AddedEdges() []string {
  15457. edges := make([]string, 0, 0)
  15458. return edges
  15459. }
  15460. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15461. // name in this mutation.
  15462. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  15463. return nil
  15464. }
  15465. // RemovedEdges returns all edge names that were removed in this mutation.
  15466. func (m *MsgMutation) RemovedEdges() []string {
  15467. edges := make([]string, 0, 0)
  15468. return edges
  15469. }
  15470. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15471. // the given name in this mutation.
  15472. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  15473. return nil
  15474. }
  15475. // ClearedEdges returns all edge names that were cleared in this mutation.
  15476. func (m *MsgMutation) ClearedEdges() []string {
  15477. edges := make([]string, 0, 0)
  15478. return edges
  15479. }
  15480. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15481. // was cleared in this mutation.
  15482. func (m *MsgMutation) EdgeCleared(name string) bool {
  15483. return false
  15484. }
  15485. // ClearEdge clears the value of the edge with the given name. It returns an error
  15486. // if that edge is not defined in the schema.
  15487. func (m *MsgMutation) ClearEdge(name string) error {
  15488. return fmt.Errorf("unknown Msg unique edge %s", name)
  15489. }
  15490. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15491. // It returns an error if the edge is not defined in the schema.
  15492. func (m *MsgMutation) ResetEdge(name string) error {
  15493. return fmt.Errorf("unknown Msg edge %s", name)
  15494. }
  15495. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  15496. type ServerMutation struct {
  15497. config
  15498. op Op
  15499. typ string
  15500. id *uint64
  15501. created_at *time.Time
  15502. updated_at *time.Time
  15503. status *uint8
  15504. addstatus *int8
  15505. deleted_at *time.Time
  15506. name *string
  15507. public_ip *string
  15508. private_ip *string
  15509. admin_port *string
  15510. clearedFields map[string]struct{}
  15511. wxs map[uint64]struct{}
  15512. removedwxs map[uint64]struct{}
  15513. clearedwxs bool
  15514. done bool
  15515. oldValue func(context.Context) (*Server, error)
  15516. predicates []predicate.Server
  15517. }
  15518. var _ ent.Mutation = (*ServerMutation)(nil)
  15519. // serverOption allows management of the mutation configuration using functional options.
  15520. type serverOption func(*ServerMutation)
  15521. // newServerMutation creates new mutation for the Server entity.
  15522. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  15523. m := &ServerMutation{
  15524. config: c,
  15525. op: op,
  15526. typ: TypeServer,
  15527. clearedFields: make(map[string]struct{}),
  15528. }
  15529. for _, opt := range opts {
  15530. opt(m)
  15531. }
  15532. return m
  15533. }
  15534. // withServerID sets the ID field of the mutation.
  15535. func withServerID(id uint64) serverOption {
  15536. return func(m *ServerMutation) {
  15537. var (
  15538. err error
  15539. once sync.Once
  15540. value *Server
  15541. )
  15542. m.oldValue = func(ctx context.Context) (*Server, error) {
  15543. once.Do(func() {
  15544. if m.done {
  15545. err = errors.New("querying old values post mutation is not allowed")
  15546. } else {
  15547. value, err = m.Client().Server.Get(ctx, id)
  15548. }
  15549. })
  15550. return value, err
  15551. }
  15552. m.id = &id
  15553. }
  15554. }
  15555. // withServer sets the old Server of the mutation.
  15556. func withServer(node *Server) serverOption {
  15557. return func(m *ServerMutation) {
  15558. m.oldValue = func(context.Context) (*Server, error) {
  15559. return node, nil
  15560. }
  15561. m.id = &node.ID
  15562. }
  15563. }
  15564. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15565. // executed in a transaction (ent.Tx), a transactional client is returned.
  15566. func (m ServerMutation) Client() *Client {
  15567. client := &Client{config: m.config}
  15568. client.init()
  15569. return client
  15570. }
  15571. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15572. // it returns an error otherwise.
  15573. func (m ServerMutation) Tx() (*Tx, error) {
  15574. if _, ok := m.driver.(*txDriver); !ok {
  15575. return nil, errors.New("ent: mutation is not running in a transaction")
  15576. }
  15577. tx := &Tx{config: m.config}
  15578. tx.init()
  15579. return tx, nil
  15580. }
  15581. // SetID sets the value of the id field. Note that this
  15582. // operation is only accepted on creation of Server entities.
  15583. func (m *ServerMutation) SetID(id uint64) {
  15584. m.id = &id
  15585. }
  15586. // ID returns the ID value in the mutation. Note that the ID is only available
  15587. // if it was provided to the builder or after it was returned from the database.
  15588. func (m *ServerMutation) ID() (id uint64, exists bool) {
  15589. if m.id == nil {
  15590. return
  15591. }
  15592. return *m.id, true
  15593. }
  15594. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15595. // That means, if the mutation is applied within a transaction with an isolation level such
  15596. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15597. // or updated by the mutation.
  15598. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  15599. switch {
  15600. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15601. id, exists := m.ID()
  15602. if exists {
  15603. return []uint64{id}, nil
  15604. }
  15605. fallthrough
  15606. case m.op.Is(OpUpdate | OpDelete):
  15607. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  15608. default:
  15609. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15610. }
  15611. }
  15612. // SetCreatedAt sets the "created_at" field.
  15613. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  15614. m.created_at = &t
  15615. }
  15616. // CreatedAt returns the value of the "created_at" field in the mutation.
  15617. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  15618. v := m.created_at
  15619. if v == nil {
  15620. return
  15621. }
  15622. return *v, true
  15623. }
  15624. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  15625. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15627. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15628. if !m.op.Is(OpUpdateOne) {
  15629. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15630. }
  15631. if m.id == nil || m.oldValue == nil {
  15632. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15633. }
  15634. oldValue, err := m.oldValue(ctx)
  15635. if err != nil {
  15636. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15637. }
  15638. return oldValue.CreatedAt, nil
  15639. }
  15640. // ResetCreatedAt resets all changes to the "created_at" field.
  15641. func (m *ServerMutation) ResetCreatedAt() {
  15642. m.created_at = nil
  15643. }
  15644. // SetUpdatedAt sets the "updated_at" field.
  15645. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  15646. m.updated_at = &t
  15647. }
  15648. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15649. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  15650. v := m.updated_at
  15651. if v == nil {
  15652. return
  15653. }
  15654. return *v, true
  15655. }
  15656. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  15657. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15659. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15660. if !m.op.Is(OpUpdateOne) {
  15661. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15662. }
  15663. if m.id == nil || m.oldValue == nil {
  15664. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15665. }
  15666. oldValue, err := m.oldValue(ctx)
  15667. if err != nil {
  15668. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15669. }
  15670. return oldValue.UpdatedAt, nil
  15671. }
  15672. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15673. func (m *ServerMutation) ResetUpdatedAt() {
  15674. m.updated_at = nil
  15675. }
  15676. // SetStatus sets the "status" field.
  15677. func (m *ServerMutation) SetStatus(u uint8) {
  15678. m.status = &u
  15679. m.addstatus = nil
  15680. }
  15681. // Status returns the value of the "status" field in the mutation.
  15682. func (m *ServerMutation) Status() (r uint8, exists bool) {
  15683. v := m.status
  15684. if v == nil {
  15685. return
  15686. }
  15687. return *v, true
  15688. }
  15689. // OldStatus returns the old "status" field's value of the Server entity.
  15690. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15692. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15693. if !m.op.Is(OpUpdateOne) {
  15694. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15695. }
  15696. if m.id == nil || m.oldValue == nil {
  15697. return v, errors.New("OldStatus requires an ID field in the mutation")
  15698. }
  15699. oldValue, err := m.oldValue(ctx)
  15700. if err != nil {
  15701. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15702. }
  15703. return oldValue.Status, nil
  15704. }
  15705. // AddStatus adds u to the "status" field.
  15706. func (m *ServerMutation) AddStatus(u int8) {
  15707. if m.addstatus != nil {
  15708. *m.addstatus += u
  15709. } else {
  15710. m.addstatus = &u
  15711. }
  15712. }
  15713. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15714. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  15715. v := m.addstatus
  15716. if v == nil {
  15717. return
  15718. }
  15719. return *v, true
  15720. }
  15721. // ClearStatus clears the value of the "status" field.
  15722. func (m *ServerMutation) ClearStatus() {
  15723. m.status = nil
  15724. m.addstatus = nil
  15725. m.clearedFields[server.FieldStatus] = struct{}{}
  15726. }
  15727. // StatusCleared returns if the "status" field was cleared in this mutation.
  15728. func (m *ServerMutation) StatusCleared() bool {
  15729. _, ok := m.clearedFields[server.FieldStatus]
  15730. return ok
  15731. }
  15732. // ResetStatus resets all changes to the "status" field.
  15733. func (m *ServerMutation) ResetStatus() {
  15734. m.status = nil
  15735. m.addstatus = nil
  15736. delete(m.clearedFields, server.FieldStatus)
  15737. }
  15738. // SetDeletedAt sets the "deleted_at" field.
  15739. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  15740. m.deleted_at = &t
  15741. }
  15742. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15743. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  15744. v := m.deleted_at
  15745. if v == nil {
  15746. return
  15747. }
  15748. return *v, true
  15749. }
  15750. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  15751. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15753. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15754. if !m.op.Is(OpUpdateOne) {
  15755. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15756. }
  15757. if m.id == nil || m.oldValue == nil {
  15758. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15759. }
  15760. oldValue, err := m.oldValue(ctx)
  15761. if err != nil {
  15762. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15763. }
  15764. return oldValue.DeletedAt, nil
  15765. }
  15766. // ClearDeletedAt clears the value of the "deleted_at" field.
  15767. func (m *ServerMutation) ClearDeletedAt() {
  15768. m.deleted_at = nil
  15769. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  15770. }
  15771. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15772. func (m *ServerMutation) DeletedAtCleared() bool {
  15773. _, ok := m.clearedFields[server.FieldDeletedAt]
  15774. return ok
  15775. }
  15776. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15777. func (m *ServerMutation) ResetDeletedAt() {
  15778. m.deleted_at = nil
  15779. delete(m.clearedFields, server.FieldDeletedAt)
  15780. }
  15781. // SetName sets the "name" field.
  15782. func (m *ServerMutation) SetName(s string) {
  15783. m.name = &s
  15784. }
  15785. // Name returns the value of the "name" field in the mutation.
  15786. func (m *ServerMutation) Name() (r string, exists bool) {
  15787. v := m.name
  15788. if v == nil {
  15789. return
  15790. }
  15791. return *v, true
  15792. }
  15793. // OldName returns the old "name" field's value of the Server entity.
  15794. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15796. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  15797. if !m.op.Is(OpUpdateOne) {
  15798. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15799. }
  15800. if m.id == nil || m.oldValue == nil {
  15801. return v, errors.New("OldName requires an ID field in the mutation")
  15802. }
  15803. oldValue, err := m.oldValue(ctx)
  15804. if err != nil {
  15805. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15806. }
  15807. return oldValue.Name, nil
  15808. }
  15809. // ResetName resets all changes to the "name" field.
  15810. func (m *ServerMutation) ResetName() {
  15811. m.name = nil
  15812. }
  15813. // SetPublicIP sets the "public_ip" field.
  15814. func (m *ServerMutation) SetPublicIP(s string) {
  15815. m.public_ip = &s
  15816. }
  15817. // PublicIP returns the value of the "public_ip" field in the mutation.
  15818. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  15819. v := m.public_ip
  15820. if v == nil {
  15821. return
  15822. }
  15823. return *v, true
  15824. }
  15825. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  15826. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15828. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  15829. if !m.op.Is(OpUpdateOne) {
  15830. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  15831. }
  15832. if m.id == nil || m.oldValue == nil {
  15833. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  15834. }
  15835. oldValue, err := m.oldValue(ctx)
  15836. if err != nil {
  15837. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  15838. }
  15839. return oldValue.PublicIP, nil
  15840. }
  15841. // ResetPublicIP resets all changes to the "public_ip" field.
  15842. func (m *ServerMutation) ResetPublicIP() {
  15843. m.public_ip = nil
  15844. }
  15845. // SetPrivateIP sets the "private_ip" field.
  15846. func (m *ServerMutation) SetPrivateIP(s string) {
  15847. m.private_ip = &s
  15848. }
  15849. // PrivateIP returns the value of the "private_ip" field in the mutation.
  15850. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  15851. v := m.private_ip
  15852. if v == nil {
  15853. return
  15854. }
  15855. return *v, true
  15856. }
  15857. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  15858. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15860. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  15861. if !m.op.Is(OpUpdateOne) {
  15862. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  15863. }
  15864. if m.id == nil || m.oldValue == nil {
  15865. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  15866. }
  15867. oldValue, err := m.oldValue(ctx)
  15868. if err != nil {
  15869. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  15870. }
  15871. return oldValue.PrivateIP, nil
  15872. }
  15873. // ResetPrivateIP resets all changes to the "private_ip" field.
  15874. func (m *ServerMutation) ResetPrivateIP() {
  15875. m.private_ip = nil
  15876. }
  15877. // SetAdminPort sets the "admin_port" field.
  15878. func (m *ServerMutation) SetAdminPort(s string) {
  15879. m.admin_port = &s
  15880. }
  15881. // AdminPort returns the value of the "admin_port" field in the mutation.
  15882. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  15883. v := m.admin_port
  15884. if v == nil {
  15885. return
  15886. }
  15887. return *v, true
  15888. }
  15889. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  15890. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15892. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  15893. if !m.op.Is(OpUpdateOne) {
  15894. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  15895. }
  15896. if m.id == nil || m.oldValue == nil {
  15897. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  15898. }
  15899. oldValue, err := m.oldValue(ctx)
  15900. if err != nil {
  15901. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  15902. }
  15903. return oldValue.AdminPort, nil
  15904. }
  15905. // ResetAdminPort resets all changes to the "admin_port" field.
  15906. func (m *ServerMutation) ResetAdminPort() {
  15907. m.admin_port = nil
  15908. }
  15909. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  15910. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  15911. if m.wxs == nil {
  15912. m.wxs = make(map[uint64]struct{})
  15913. }
  15914. for i := range ids {
  15915. m.wxs[ids[i]] = struct{}{}
  15916. }
  15917. }
  15918. // ClearWxs clears the "wxs" edge to the Wx entity.
  15919. func (m *ServerMutation) ClearWxs() {
  15920. m.clearedwxs = true
  15921. }
  15922. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  15923. func (m *ServerMutation) WxsCleared() bool {
  15924. return m.clearedwxs
  15925. }
  15926. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  15927. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  15928. if m.removedwxs == nil {
  15929. m.removedwxs = make(map[uint64]struct{})
  15930. }
  15931. for i := range ids {
  15932. delete(m.wxs, ids[i])
  15933. m.removedwxs[ids[i]] = struct{}{}
  15934. }
  15935. }
  15936. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  15937. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  15938. for id := range m.removedwxs {
  15939. ids = append(ids, id)
  15940. }
  15941. return
  15942. }
  15943. // WxsIDs returns the "wxs" edge IDs in the mutation.
  15944. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  15945. for id := range m.wxs {
  15946. ids = append(ids, id)
  15947. }
  15948. return
  15949. }
  15950. // ResetWxs resets all changes to the "wxs" edge.
  15951. func (m *ServerMutation) ResetWxs() {
  15952. m.wxs = nil
  15953. m.clearedwxs = false
  15954. m.removedwxs = nil
  15955. }
  15956. // Where appends a list predicates to the ServerMutation builder.
  15957. func (m *ServerMutation) Where(ps ...predicate.Server) {
  15958. m.predicates = append(m.predicates, ps...)
  15959. }
  15960. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  15961. // users can use type-assertion to append predicates that do not depend on any generated package.
  15962. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  15963. p := make([]predicate.Server, len(ps))
  15964. for i := range ps {
  15965. p[i] = ps[i]
  15966. }
  15967. m.Where(p...)
  15968. }
  15969. // Op returns the operation name.
  15970. func (m *ServerMutation) Op() Op {
  15971. return m.op
  15972. }
  15973. // SetOp allows setting the mutation operation.
  15974. func (m *ServerMutation) SetOp(op Op) {
  15975. m.op = op
  15976. }
  15977. // Type returns the node type of this mutation (Server).
  15978. func (m *ServerMutation) Type() string {
  15979. return m.typ
  15980. }
  15981. // Fields returns all fields that were changed during this mutation. Note that in
  15982. // order to get all numeric fields that were incremented/decremented, call
  15983. // AddedFields().
  15984. func (m *ServerMutation) Fields() []string {
  15985. fields := make([]string, 0, 8)
  15986. if m.created_at != nil {
  15987. fields = append(fields, server.FieldCreatedAt)
  15988. }
  15989. if m.updated_at != nil {
  15990. fields = append(fields, server.FieldUpdatedAt)
  15991. }
  15992. if m.status != nil {
  15993. fields = append(fields, server.FieldStatus)
  15994. }
  15995. if m.deleted_at != nil {
  15996. fields = append(fields, server.FieldDeletedAt)
  15997. }
  15998. if m.name != nil {
  15999. fields = append(fields, server.FieldName)
  16000. }
  16001. if m.public_ip != nil {
  16002. fields = append(fields, server.FieldPublicIP)
  16003. }
  16004. if m.private_ip != nil {
  16005. fields = append(fields, server.FieldPrivateIP)
  16006. }
  16007. if m.admin_port != nil {
  16008. fields = append(fields, server.FieldAdminPort)
  16009. }
  16010. return fields
  16011. }
  16012. // Field returns the value of a field with the given name. The second boolean
  16013. // return value indicates that this field was not set, or was not defined in the
  16014. // schema.
  16015. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  16016. switch name {
  16017. case server.FieldCreatedAt:
  16018. return m.CreatedAt()
  16019. case server.FieldUpdatedAt:
  16020. return m.UpdatedAt()
  16021. case server.FieldStatus:
  16022. return m.Status()
  16023. case server.FieldDeletedAt:
  16024. return m.DeletedAt()
  16025. case server.FieldName:
  16026. return m.Name()
  16027. case server.FieldPublicIP:
  16028. return m.PublicIP()
  16029. case server.FieldPrivateIP:
  16030. return m.PrivateIP()
  16031. case server.FieldAdminPort:
  16032. return m.AdminPort()
  16033. }
  16034. return nil, false
  16035. }
  16036. // OldField returns the old value of the field from the database. An error is
  16037. // returned if the mutation operation is not UpdateOne, or the query to the
  16038. // database failed.
  16039. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16040. switch name {
  16041. case server.FieldCreatedAt:
  16042. return m.OldCreatedAt(ctx)
  16043. case server.FieldUpdatedAt:
  16044. return m.OldUpdatedAt(ctx)
  16045. case server.FieldStatus:
  16046. return m.OldStatus(ctx)
  16047. case server.FieldDeletedAt:
  16048. return m.OldDeletedAt(ctx)
  16049. case server.FieldName:
  16050. return m.OldName(ctx)
  16051. case server.FieldPublicIP:
  16052. return m.OldPublicIP(ctx)
  16053. case server.FieldPrivateIP:
  16054. return m.OldPrivateIP(ctx)
  16055. case server.FieldAdminPort:
  16056. return m.OldAdminPort(ctx)
  16057. }
  16058. return nil, fmt.Errorf("unknown Server field %s", name)
  16059. }
  16060. // SetField sets the value of a field with the given name. It returns an error if
  16061. // the field is not defined in the schema, or if the type mismatched the field
  16062. // type.
  16063. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  16064. switch name {
  16065. case server.FieldCreatedAt:
  16066. v, ok := value.(time.Time)
  16067. if !ok {
  16068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16069. }
  16070. m.SetCreatedAt(v)
  16071. return nil
  16072. case server.FieldUpdatedAt:
  16073. v, ok := value.(time.Time)
  16074. if !ok {
  16075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16076. }
  16077. m.SetUpdatedAt(v)
  16078. return nil
  16079. case server.FieldStatus:
  16080. v, ok := value.(uint8)
  16081. if !ok {
  16082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16083. }
  16084. m.SetStatus(v)
  16085. return nil
  16086. case server.FieldDeletedAt:
  16087. v, ok := value.(time.Time)
  16088. if !ok {
  16089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16090. }
  16091. m.SetDeletedAt(v)
  16092. return nil
  16093. case server.FieldName:
  16094. v, ok := value.(string)
  16095. if !ok {
  16096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16097. }
  16098. m.SetName(v)
  16099. return nil
  16100. case server.FieldPublicIP:
  16101. v, ok := value.(string)
  16102. if !ok {
  16103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16104. }
  16105. m.SetPublicIP(v)
  16106. return nil
  16107. case server.FieldPrivateIP:
  16108. v, ok := value.(string)
  16109. if !ok {
  16110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16111. }
  16112. m.SetPrivateIP(v)
  16113. return nil
  16114. case server.FieldAdminPort:
  16115. v, ok := value.(string)
  16116. if !ok {
  16117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16118. }
  16119. m.SetAdminPort(v)
  16120. return nil
  16121. }
  16122. return fmt.Errorf("unknown Server field %s", name)
  16123. }
  16124. // AddedFields returns all numeric fields that were incremented/decremented during
  16125. // this mutation.
  16126. func (m *ServerMutation) AddedFields() []string {
  16127. var fields []string
  16128. if m.addstatus != nil {
  16129. fields = append(fields, server.FieldStatus)
  16130. }
  16131. return fields
  16132. }
  16133. // AddedField returns the numeric value that was incremented/decremented on a field
  16134. // with the given name. The second boolean return value indicates that this field
  16135. // was not set, or was not defined in the schema.
  16136. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  16137. switch name {
  16138. case server.FieldStatus:
  16139. return m.AddedStatus()
  16140. }
  16141. return nil, false
  16142. }
  16143. // AddField adds the value to the field with the given name. It returns an error if
  16144. // the field is not defined in the schema, or if the type mismatched the field
  16145. // type.
  16146. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  16147. switch name {
  16148. case server.FieldStatus:
  16149. v, ok := value.(int8)
  16150. if !ok {
  16151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16152. }
  16153. m.AddStatus(v)
  16154. return nil
  16155. }
  16156. return fmt.Errorf("unknown Server numeric field %s", name)
  16157. }
  16158. // ClearedFields returns all nullable fields that were cleared during this
  16159. // mutation.
  16160. func (m *ServerMutation) ClearedFields() []string {
  16161. var fields []string
  16162. if m.FieldCleared(server.FieldStatus) {
  16163. fields = append(fields, server.FieldStatus)
  16164. }
  16165. if m.FieldCleared(server.FieldDeletedAt) {
  16166. fields = append(fields, server.FieldDeletedAt)
  16167. }
  16168. return fields
  16169. }
  16170. // FieldCleared returns a boolean indicating if a field with the given name was
  16171. // cleared in this mutation.
  16172. func (m *ServerMutation) FieldCleared(name string) bool {
  16173. _, ok := m.clearedFields[name]
  16174. return ok
  16175. }
  16176. // ClearField clears the value of the field with the given name. It returns an
  16177. // error if the field is not defined in the schema.
  16178. func (m *ServerMutation) ClearField(name string) error {
  16179. switch name {
  16180. case server.FieldStatus:
  16181. m.ClearStatus()
  16182. return nil
  16183. case server.FieldDeletedAt:
  16184. m.ClearDeletedAt()
  16185. return nil
  16186. }
  16187. return fmt.Errorf("unknown Server nullable field %s", name)
  16188. }
  16189. // ResetField resets all changes in the mutation for the field with the given name.
  16190. // It returns an error if the field is not defined in the schema.
  16191. func (m *ServerMutation) ResetField(name string) error {
  16192. switch name {
  16193. case server.FieldCreatedAt:
  16194. m.ResetCreatedAt()
  16195. return nil
  16196. case server.FieldUpdatedAt:
  16197. m.ResetUpdatedAt()
  16198. return nil
  16199. case server.FieldStatus:
  16200. m.ResetStatus()
  16201. return nil
  16202. case server.FieldDeletedAt:
  16203. m.ResetDeletedAt()
  16204. return nil
  16205. case server.FieldName:
  16206. m.ResetName()
  16207. return nil
  16208. case server.FieldPublicIP:
  16209. m.ResetPublicIP()
  16210. return nil
  16211. case server.FieldPrivateIP:
  16212. m.ResetPrivateIP()
  16213. return nil
  16214. case server.FieldAdminPort:
  16215. m.ResetAdminPort()
  16216. return nil
  16217. }
  16218. return fmt.Errorf("unknown Server field %s", name)
  16219. }
  16220. // AddedEdges returns all edge names that were set/added in this mutation.
  16221. func (m *ServerMutation) AddedEdges() []string {
  16222. edges := make([]string, 0, 1)
  16223. if m.wxs != nil {
  16224. edges = append(edges, server.EdgeWxs)
  16225. }
  16226. return edges
  16227. }
  16228. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16229. // name in this mutation.
  16230. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  16231. switch name {
  16232. case server.EdgeWxs:
  16233. ids := make([]ent.Value, 0, len(m.wxs))
  16234. for id := range m.wxs {
  16235. ids = append(ids, id)
  16236. }
  16237. return ids
  16238. }
  16239. return nil
  16240. }
  16241. // RemovedEdges returns all edge names that were removed in this mutation.
  16242. func (m *ServerMutation) RemovedEdges() []string {
  16243. edges := make([]string, 0, 1)
  16244. if m.removedwxs != nil {
  16245. edges = append(edges, server.EdgeWxs)
  16246. }
  16247. return edges
  16248. }
  16249. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16250. // the given name in this mutation.
  16251. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  16252. switch name {
  16253. case server.EdgeWxs:
  16254. ids := make([]ent.Value, 0, len(m.removedwxs))
  16255. for id := range m.removedwxs {
  16256. ids = append(ids, id)
  16257. }
  16258. return ids
  16259. }
  16260. return nil
  16261. }
  16262. // ClearedEdges returns all edge names that were cleared in this mutation.
  16263. func (m *ServerMutation) ClearedEdges() []string {
  16264. edges := make([]string, 0, 1)
  16265. if m.clearedwxs {
  16266. edges = append(edges, server.EdgeWxs)
  16267. }
  16268. return edges
  16269. }
  16270. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16271. // was cleared in this mutation.
  16272. func (m *ServerMutation) EdgeCleared(name string) bool {
  16273. switch name {
  16274. case server.EdgeWxs:
  16275. return m.clearedwxs
  16276. }
  16277. return false
  16278. }
  16279. // ClearEdge clears the value of the edge with the given name. It returns an error
  16280. // if that edge is not defined in the schema.
  16281. func (m *ServerMutation) ClearEdge(name string) error {
  16282. switch name {
  16283. }
  16284. return fmt.Errorf("unknown Server unique edge %s", name)
  16285. }
  16286. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16287. // It returns an error if the edge is not defined in the schema.
  16288. func (m *ServerMutation) ResetEdge(name string) error {
  16289. switch name {
  16290. case server.EdgeWxs:
  16291. m.ResetWxs()
  16292. return nil
  16293. }
  16294. return fmt.Errorf("unknown Server edge %s", name)
  16295. }
  16296. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  16297. type SopNodeMutation struct {
  16298. config
  16299. op Op
  16300. typ string
  16301. id *uint64
  16302. created_at *time.Time
  16303. updated_at *time.Time
  16304. status *uint8
  16305. addstatus *int8
  16306. deleted_at *time.Time
  16307. parent_id *uint64
  16308. addparent_id *int64
  16309. name *string
  16310. condition_type *int
  16311. addcondition_type *int
  16312. condition_list *[]string
  16313. appendcondition_list []string
  16314. no_reply_condition *uint64
  16315. addno_reply_condition *int64
  16316. no_reply_unit *string
  16317. action_message *[]custom_types.Action
  16318. appendaction_message []custom_types.Action
  16319. action_label_add *[]uint64
  16320. appendaction_label_add []uint64
  16321. action_label_del *[]uint64
  16322. appendaction_label_del []uint64
  16323. action_forward **custom_types.ActionForward
  16324. clearedFields map[string]struct{}
  16325. sop_stage *uint64
  16326. clearedsop_stage bool
  16327. node_messages map[uint64]struct{}
  16328. removednode_messages map[uint64]struct{}
  16329. clearednode_messages bool
  16330. done bool
  16331. oldValue func(context.Context) (*SopNode, error)
  16332. predicates []predicate.SopNode
  16333. }
  16334. var _ ent.Mutation = (*SopNodeMutation)(nil)
  16335. // sopnodeOption allows management of the mutation configuration using functional options.
  16336. type sopnodeOption func(*SopNodeMutation)
  16337. // newSopNodeMutation creates new mutation for the SopNode entity.
  16338. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  16339. m := &SopNodeMutation{
  16340. config: c,
  16341. op: op,
  16342. typ: TypeSopNode,
  16343. clearedFields: make(map[string]struct{}),
  16344. }
  16345. for _, opt := range opts {
  16346. opt(m)
  16347. }
  16348. return m
  16349. }
  16350. // withSopNodeID sets the ID field of the mutation.
  16351. func withSopNodeID(id uint64) sopnodeOption {
  16352. return func(m *SopNodeMutation) {
  16353. var (
  16354. err error
  16355. once sync.Once
  16356. value *SopNode
  16357. )
  16358. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  16359. once.Do(func() {
  16360. if m.done {
  16361. err = errors.New("querying old values post mutation is not allowed")
  16362. } else {
  16363. value, err = m.Client().SopNode.Get(ctx, id)
  16364. }
  16365. })
  16366. return value, err
  16367. }
  16368. m.id = &id
  16369. }
  16370. }
  16371. // withSopNode sets the old SopNode of the mutation.
  16372. func withSopNode(node *SopNode) sopnodeOption {
  16373. return func(m *SopNodeMutation) {
  16374. m.oldValue = func(context.Context) (*SopNode, error) {
  16375. return node, nil
  16376. }
  16377. m.id = &node.ID
  16378. }
  16379. }
  16380. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16381. // executed in a transaction (ent.Tx), a transactional client is returned.
  16382. func (m SopNodeMutation) Client() *Client {
  16383. client := &Client{config: m.config}
  16384. client.init()
  16385. return client
  16386. }
  16387. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16388. // it returns an error otherwise.
  16389. func (m SopNodeMutation) Tx() (*Tx, error) {
  16390. if _, ok := m.driver.(*txDriver); !ok {
  16391. return nil, errors.New("ent: mutation is not running in a transaction")
  16392. }
  16393. tx := &Tx{config: m.config}
  16394. tx.init()
  16395. return tx, nil
  16396. }
  16397. // SetID sets the value of the id field. Note that this
  16398. // operation is only accepted on creation of SopNode entities.
  16399. func (m *SopNodeMutation) SetID(id uint64) {
  16400. m.id = &id
  16401. }
  16402. // ID returns the ID value in the mutation. Note that the ID is only available
  16403. // if it was provided to the builder or after it was returned from the database.
  16404. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  16405. if m.id == nil {
  16406. return
  16407. }
  16408. return *m.id, true
  16409. }
  16410. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16411. // That means, if the mutation is applied within a transaction with an isolation level such
  16412. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16413. // or updated by the mutation.
  16414. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16415. switch {
  16416. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16417. id, exists := m.ID()
  16418. if exists {
  16419. return []uint64{id}, nil
  16420. }
  16421. fallthrough
  16422. case m.op.Is(OpUpdate | OpDelete):
  16423. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  16424. default:
  16425. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16426. }
  16427. }
  16428. // SetCreatedAt sets the "created_at" field.
  16429. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  16430. m.created_at = &t
  16431. }
  16432. // CreatedAt returns the value of the "created_at" field in the mutation.
  16433. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  16434. v := m.created_at
  16435. if v == nil {
  16436. return
  16437. }
  16438. return *v, true
  16439. }
  16440. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  16441. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16443. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16444. if !m.op.Is(OpUpdateOne) {
  16445. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16446. }
  16447. if m.id == nil || m.oldValue == nil {
  16448. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16449. }
  16450. oldValue, err := m.oldValue(ctx)
  16451. if err != nil {
  16452. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16453. }
  16454. return oldValue.CreatedAt, nil
  16455. }
  16456. // ResetCreatedAt resets all changes to the "created_at" field.
  16457. func (m *SopNodeMutation) ResetCreatedAt() {
  16458. m.created_at = nil
  16459. }
  16460. // SetUpdatedAt sets the "updated_at" field.
  16461. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  16462. m.updated_at = &t
  16463. }
  16464. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16465. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  16466. v := m.updated_at
  16467. if v == nil {
  16468. return
  16469. }
  16470. return *v, true
  16471. }
  16472. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  16473. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16475. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16476. if !m.op.Is(OpUpdateOne) {
  16477. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16478. }
  16479. if m.id == nil || m.oldValue == nil {
  16480. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16481. }
  16482. oldValue, err := m.oldValue(ctx)
  16483. if err != nil {
  16484. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16485. }
  16486. return oldValue.UpdatedAt, nil
  16487. }
  16488. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16489. func (m *SopNodeMutation) ResetUpdatedAt() {
  16490. m.updated_at = nil
  16491. }
  16492. // SetStatus sets the "status" field.
  16493. func (m *SopNodeMutation) SetStatus(u uint8) {
  16494. m.status = &u
  16495. m.addstatus = nil
  16496. }
  16497. // Status returns the value of the "status" field in the mutation.
  16498. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  16499. v := m.status
  16500. if v == nil {
  16501. return
  16502. }
  16503. return *v, true
  16504. }
  16505. // OldStatus returns the old "status" field's value of the SopNode entity.
  16506. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16508. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16509. if !m.op.Is(OpUpdateOne) {
  16510. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16511. }
  16512. if m.id == nil || m.oldValue == nil {
  16513. return v, errors.New("OldStatus requires an ID field in the mutation")
  16514. }
  16515. oldValue, err := m.oldValue(ctx)
  16516. if err != nil {
  16517. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16518. }
  16519. return oldValue.Status, nil
  16520. }
  16521. // AddStatus adds u to the "status" field.
  16522. func (m *SopNodeMutation) AddStatus(u int8) {
  16523. if m.addstatus != nil {
  16524. *m.addstatus += u
  16525. } else {
  16526. m.addstatus = &u
  16527. }
  16528. }
  16529. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16530. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  16531. v := m.addstatus
  16532. if v == nil {
  16533. return
  16534. }
  16535. return *v, true
  16536. }
  16537. // ClearStatus clears the value of the "status" field.
  16538. func (m *SopNodeMutation) ClearStatus() {
  16539. m.status = nil
  16540. m.addstatus = nil
  16541. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  16542. }
  16543. // StatusCleared returns if the "status" field was cleared in this mutation.
  16544. func (m *SopNodeMutation) StatusCleared() bool {
  16545. _, ok := m.clearedFields[sopnode.FieldStatus]
  16546. return ok
  16547. }
  16548. // ResetStatus resets all changes to the "status" field.
  16549. func (m *SopNodeMutation) ResetStatus() {
  16550. m.status = nil
  16551. m.addstatus = nil
  16552. delete(m.clearedFields, sopnode.FieldStatus)
  16553. }
  16554. // SetDeletedAt sets the "deleted_at" field.
  16555. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  16556. m.deleted_at = &t
  16557. }
  16558. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16559. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  16560. v := m.deleted_at
  16561. if v == nil {
  16562. return
  16563. }
  16564. return *v, true
  16565. }
  16566. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  16567. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16569. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16570. if !m.op.Is(OpUpdateOne) {
  16571. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16572. }
  16573. if m.id == nil || m.oldValue == nil {
  16574. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16575. }
  16576. oldValue, err := m.oldValue(ctx)
  16577. if err != nil {
  16578. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16579. }
  16580. return oldValue.DeletedAt, nil
  16581. }
  16582. // ClearDeletedAt clears the value of the "deleted_at" field.
  16583. func (m *SopNodeMutation) ClearDeletedAt() {
  16584. m.deleted_at = nil
  16585. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  16586. }
  16587. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16588. func (m *SopNodeMutation) DeletedAtCleared() bool {
  16589. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  16590. return ok
  16591. }
  16592. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16593. func (m *SopNodeMutation) ResetDeletedAt() {
  16594. m.deleted_at = nil
  16595. delete(m.clearedFields, sopnode.FieldDeletedAt)
  16596. }
  16597. // SetStageID sets the "stage_id" field.
  16598. func (m *SopNodeMutation) SetStageID(u uint64) {
  16599. m.sop_stage = &u
  16600. }
  16601. // StageID returns the value of the "stage_id" field in the mutation.
  16602. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  16603. v := m.sop_stage
  16604. if v == nil {
  16605. return
  16606. }
  16607. return *v, true
  16608. }
  16609. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  16610. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16612. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  16613. if !m.op.Is(OpUpdateOne) {
  16614. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  16615. }
  16616. if m.id == nil || m.oldValue == nil {
  16617. return v, errors.New("OldStageID requires an ID field in the mutation")
  16618. }
  16619. oldValue, err := m.oldValue(ctx)
  16620. if err != nil {
  16621. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  16622. }
  16623. return oldValue.StageID, nil
  16624. }
  16625. // ResetStageID resets all changes to the "stage_id" field.
  16626. func (m *SopNodeMutation) ResetStageID() {
  16627. m.sop_stage = nil
  16628. }
  16629. // SetParentID sets the "parent_id" field.
  16630. func (m *SopNodeMutation) SetParentID(u uint64) {
  16631. m.parent_id = &u
  16632. m.addparent_id = nil
  16633. }
  16634. // ParentID returns the value of the "parent_id" field in the mutation.
  16635. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  16636. v := m.parent_id
  16637. if v == nil {
  16638. return
  16639. }
  16640. return *v, true
  16641. }
  16642. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  16643. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16645. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  16646. if !m.op.Is(OpUpdateOne) {
  16647. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  16648. }
  16649. if m.id == nil || m.oldValue == nil {
  16650. return v, errors.New("OldParentID requires an ID field in the mutation")
  16651. }
  16652. oldValue, err := m.oldValue(ctx)
  16653. if err != nil {
  16654. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  16655. }
  16656. return oldValue.ParentID, nil
  16657. }
  16658. // AddParentID adds u to the "parent_id" field.
  16659. func (m *SopNodeMutation) AddParentID(u int64) {
  16660. if m.addparent_id != nil {
  16661. *m.addparent_id += u
  16662. } else {
  16663. m.addparent_id = &u
  16664. }
  16665. }
  16666. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  16667. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  16668. v := m.addparent_id
  16669. if v == nil {
  16670. return
  16671. }
  16672. return *v, true
  16673. }
  16674. // ResetParentID resets all changes to the "parent_id" field.
  16675. func (m *SopNodeMutation) ResetParentID() {
  16676. m.parent_id = nil
  16677. m.addparent_id = nil
  16678. }
  16679. // SetName sets the "name" field.
  16680. func (m *SopNodeMutation) SetName(s string) {
  16681. m.name = &s
  16682. }
  16683. // Name returns the value of the "name" field in the mutation.
  16684. func (m *SopNodeMutation) Name() (r string, exists bool) {
  16685. v := m.name
  16686. if v == nil {
  16687. return
  16688. }
  16689. return *v, true
  16690. }
  16691. // OldName returns the old "name" field's value of the SopNode entity.
  16692. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16694. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  16695. if !m.op.Is(OpUpdateOne) {
  16696. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16697. }
  16698. if m.id == nil || m.oldValue == nil {
  16699. return v, errors.New("OldName requires an ID field in the mutation")
  16700. }
  16701. oldValue, err := m.oldValue(ctx)
  16702. if err != nil {
  16703. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16704. }
  16705. return oldValue.Name, nil
  16706. }
  16707. // ResetName resets all changes to the "name" field.
  16708. func (m *SopNodeMutation) ResetName() {
  16709. m.name = nil
  16710. }
  16711. // SetConditionType sets the "condition_type" field.
  16712. func (m *SopNodeMutation) SetConditionType(i int) {
  16713. m.condition_type = &i
  16714. m.addcondition_type = nil
  16715. }
  16716. // ConditionType returns the value of the "condition_type" field in the mutation.
  16717. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  16718. v := m.condition_type
  16719. if v == nil {
  16720. return
  16721. }
  16722. return *v, true
  16723. }
  16724. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  16725. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16727. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  16728. if !m.op.Is(OpUpdateOne) {
  16729. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  16730. }
  16731. if m.id == nil || m.oldValue == nil {
  16732. return v, errors.New("OldConditionType requires an ID field in the mutation")
  16733. }
  16734. oldValue, err := m.oldValue(ctx)
  16735. if err != nil {
  16736. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  16737. }
  16738. return oldValue.ConditionType, nil
  16739. }
  16740. // AddConditionType adds i to the "condition_type" field.
  16741. func (m *SopNodeMutation) AddConditionType(i int) {
  16742. if m.addcondition_type != nil {
  16743. *m.addcondition_type += i
  16744. } else {
  16745. m.addcondition_type = &i
  16746. }
  16747. }
  16748. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  16749. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  16750. v := m.addcondition_type
  16751. if v == nil {
  16752. return
  16753. }
  16754. return *v, true
  16755. }
  16756. // ResetConditionType resets all changes to the "condition_type" field.
  16757. func (m *SopNodeMutation) ResetConditionType() {
  16758. m.condition_type = nil
  16759. m.addcondition_type = nil
  16760. }
  16761. // SetConditionList sets the "condition_list" field.
  16762. func (m *SopNodeMutation) SetConditionList(s []string) {
  16763. m.condition_list = &s
  16764. m.appendcondition_list = nil
  16765. }
  16766. // ConditionList returns the value of the "condition_list" field in the mutation.
  16767. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  16768. v := m.condition_list
  16769. if v == nil {
  16770. return
  16771. }
  16772. return *v, true
  16773. }
  16774. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  16775. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16777. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  16778. if !m.op.Is(OpUpdateOne) {
  16779. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  16780. }
  16781. if m.id == nil || m.oldValue == nil {
  16782. return v, errors.New("OldConditionList requires an ID field in the mutation")
  16783. }
  16784. oldValue, err := m.oldValue(ctx)
  16785. if err != nil {
  16786. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  16787. }
  16788. return oldValue.ConditionList, nil
  16789. }
  16790. // AppendConditionList adds s to the "condition_list" field.
  16791. func (m *SopNodeMutation) AppendConditionList(s []string) {
  16792. m.appendcondition_list = append(m.appendcondition_list, s...)
  16793. }
  16794. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  16795. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  16796. if len(m.appendcondition_list) == 0 {
  16797. return nil, false
  16798. }
  16799. return m.appendcondition_list, true
  16800. }
  16801. // ClearConditionList clears the value of the "condition_list" field.
  16802. func (m *SopNodeMutation) ClearConditionList() {
  16803. m.condition_list = nil
  16804. m.appendcondition_list = nil
  16805. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  16806. }
  16807. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  16808. func (m *SopNodeMutation) ConditionListCleared() bool {
  16809. _, ok := m.clearedFields[sopnode.FieldConditionList]
  16810. return ok
  16811. }
  16812. // ResetConditionList resets all changes to the "condition_list" field.
  16813. func (m *SopNodeMutation) ResetConditionList() {
  16814. m.condition_list = nil
  16815. m.appendcondition_list = nil
  16816. delete(m.clearedFields, sopnode.FieldConditionList)
  16817. }
  16818. // SetNoReplyCondition sets the "no_reply_condition" field.
  16819. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  16820. m.no_reply_condition = &u
  16821. m.addno_reply_condition = nil
  16822. }
  16823. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  16824. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  16825. v := m.no_reply_condition
  16826. if v == nil {
  16827. return
  16828. }
  16829. return *v, true
  16830. }
  16831. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  16832. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16834. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  16835. if !m.op.Is(OpUpdateOne) {
  16836. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  16837. }
  16838. if m.id == nil || m.oldValue == nil {
  16839. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  16840. }
  16841. oldValue, err := m.oldValue(ctx)
  16842. if err != nil {
  16843. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  16844. }
  16845. return oldValue.NoReplyCondition, nil
  16846. }
  16847. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  16848. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  16849. if m.addno_reply_condition != nil {
  16850. *m.addno_reply_condition += u
  16851. } else {
  16852. m.addno_reply_condition = &u
  16853. }
  16854. }
  16855. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  16856. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  16857. v := m.addno_reply_condition
  16858. if v == nil {
  16859. return
  16860. }
  16861. return *v, true
  16862. }
  16863. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  16864. func (m *SopNodeMutation) ResetNoReplyCondition() {
  16865. m.no_reply_condition = nil
  16866. m.addno_reply_condition = nil
  16867. }
  16868. // SetNoReplyUnit sets the "no_reply_unit" field.
  16869. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  16870. m.no_reply_unit = &s
  16871. }
  16872. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  16873. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  16874. v := m.no_reply_unit
  16875. if v == nil {
  16876. return
  16877. }
  16878. return *v, true
  16879. }
  16880. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  16881. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16883. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  16884. if !m.op.Is(OpUpdateOne) {
  16885. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  16886. }
  16887. if m.id == nil || m.oldValue == nil {
  16888. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  16889. }
  16890. oldValue, err := m.oldValue(ctx)
  16891. if err != nil {
  16892. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  16893. }
  16894. return oldValue.NoReplyUnit, nil
  16895. }
  16896. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  16897. func (m *SopNodeMutation) ResetNoReplyUnit() {
  16898. m.no_reply_unit = nil
  16899. }
  16900. // SetActionMessage sets the "action_message" field.
  16901. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  16902. m.action_message = &ct
  16903. m.appendaction_message = nil
  16904. }
  16905. // ActionMessage returns the value of the "action_message" field in the mutation.
  16906. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  16907. v := m.action_message
  16908. if v == nil {
  16909. return
  16910. }
  16911. return *v, true
  16912. }
  16913. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  16914. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16916. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  16917. if !m.op.Is(OpUpdateOne) {
  16918. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  16919. }
  16920. if m.id == nil || m.oldValue == nil {
  16921. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  16922. }
  16923. oldValue, err := m.oldValue(ctx)
  16924. if err != nil {
  16925. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  16926. }
  16927. return oldValue.ActionMessage, nil
  16928. }
  16929. // AppendActionMessage adds ct to the "action_message" field.
  16930. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  16931. m.appendaction_message = append(m.appendaction_message, ct...)
  16932. }
  16933. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  16934. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  16935. if len(m.appendaction_message) == 0 {
  16936. return nil, false
  16937. }
  16938. return m.appendaction_message, true
  16939. }
  16940. // ClearActionMessage clears the value of the "action_message" field.
  16941. func (m *SopNodeMutation) ClearActionMessage() {
  16942. m.action_message = nil
  16943. m.appendaction_message = nil
  16944. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  16945. }
  16946. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  16947. func (m *SopNodeMutation) ActionMessageCleared() bool {
  16948. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  16949. return ok
  16950. }
  16951. // ResetActionMessage resets all changes to the "action_message" field.
  16952. func (m *SopNodeMutation) ResetActionMessage() {
  16953. m.action_message = nil
  16954. m.appendaction_message = nil
  16955. delete(m.clearedFields, sopnode.FieldActionMessage)
  16956. }
  16957. // SetActionLabelAdd sets the "action_label_add" field.
  16958. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  16959. m.action_label_add = &u
  16960. m.appendaction_label_add = nil
  16961. }
  16962. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  16963. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  16964. v := m.action_label_add
  16965. if v == nil {
  16966. return
  16967. }
  16968. return *v, true
  16969. }
  16970. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  16971. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16973. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  16974. if !m.op.Is(OpUpdateOne) {
  16975. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  16976. }
  16977. if m.id == nil || m.oldValue == nil {
  16978. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  16979. }
  16980. oldValue, err := m.oldValue(ctx)
  16981. if err != nil {
  16982. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  16983. }
  16984. return oldValue.ActionLabelAdd, nil
  16985. }
  16986. // AppendActionLabelAdd adds u to the "action_label_add" field.
  16987. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  16988. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  16989. }
  16990. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  16991. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  16992. if len(m.appendaction_label_add) == 0 {
  16993. return nil, false
  16994. }
  16995. return m.appendaction_label_add, true
  16996. }
  16997. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  16998. func (m *SopNodeMutation) ClearActionLabelAdd() {
  16999. m.action_label_add = nil
  17000. m.appendaction_label_add = nil
  17001. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  17002. }
  17003. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17004. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  17005. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  17006. return ok
  17007. }
  17008. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17009. func (m *SopNodeMutation) ResetActionLabelAdd() {
  17010. m.action_label_add = nil
  17011. m.appendaction_label_add = nil
  17012. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  17013. }
  17014. // SetActionLabelDel sets the "action_label_del" field.
  17015. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  17016. m.action_label_del = &u
  17017. m.appendaction_label_del = nil
  17018. }
  17019. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17020. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  17021. v := m.action_label_del
  17022. if v == nil {
  17023. return
  17024. }
  17025. return *v, true
  17026. }
  17027. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  17028. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17030. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17031. if !m.op.Is(OpUpdateOne) {
  17032. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17033. }
  17034. if m.id == nil || m.oldValue == nil {
  17035. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17036. }
  17037. oldValue, err := m.oldValue(ctx)
  17038. if err != nil {
  17039. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17040. }
  17041. return oldValue.ActionLabelDel, nil
  17042. }
  17043. // AppendActionLabelDel adds u to the "action_label_del" field.
  17044. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  17045. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17046. }
  17047. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17048. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17049. if len(m.appendaction_label_del) == 0 {
  17050. return nil, false
  17051. }
  17052. return m.appendaction_label_del, true
  17053. }
  17054. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17055. func (m *SopNodeMutation) ClearActionLabelDel() {
  17056. m.action_label_del = nil
  17057. m.appendaction_label_del = nil
  17058. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  17059. }
  17060. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17061. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  17062. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  17063. return ok
  17064. }
  17065. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17066. func (m *SopNodeMutation) ResetActionLabelDel() {
  17067. m.action_label_del = nil
  17068. m.appendaction_label_del = nil
  17069. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  17070. }
  17071. // SetActionForward sets the "action_forward" field.
  17072. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17073. m.action_forward = &ctf
  17074. }
  17075. // ActionForward returns the value of the "action_forward" field in the mutation.
  17076. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17077. v := m.action_forward
  17078. if v == nil {
  17079. return
  17080. }
  17081. return *v, true
  17082. }
  17083. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  17084. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17086. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17087. if !m.op.Is(OpUpdateOne) {
  17088. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17089. }
  17090. if m.id == nil || m.oldValue == nil {
  17091. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17092. }
  17093. oldValue, err := m.oldValue(ctx)
  17094. if err != nil {
  17095. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17096. }
  17097. return oldValue.ActionForward, nil
  17098. }
  17099. // ClearActionForward clears the value of the "action_forward" field.
  17100. func (m *SopNodeMutation) ClearActionForward() {
  17101. m.action_forward = nil
  17102. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  17103. }
  17104. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17105. func (m *SopNodeMutation) ActionForwardCleared() bool {
  17106. _, ok := m.clearedFields[sopnode.FieldActionForward]
  17107. return ok
  17108. }
  17109. // ResetActionForward resets all changes to the "action_forward" field.
  17110. func (m *SopNodeMutation) ResetActionForward() {
  17111. m.action_forward = nil
  17112. delete(m.clearedFields, sopnode.FieldActionForward)
  17113. }
  17114. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17115. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  17116. m.sop_stage = &id
  17117. }
  17118. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17119. func (m *SopNodeMutation) ClearSopStage() {
  17120. m.clearedsop_stage = true
  17121. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  17122. }
  17123. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17124. func (m *SopNodeMutation) SopStageCleared() bool {
  17125. return m.clearedsop_stage
  17126. }
  17127. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17128. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  17129. if m.sop_stage != nil {
  17130. return *m.sop_stage, true
  17131. }
  17132. return
  17133. }
  17134. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17135. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17136. // SopStageID instead. It exists only for internal usage by the builders.
  17137. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  17138. if id := m.sop_stage; id != nil {
  17139. ids = append(ids, *id)
  17140. }
  17141. return
  17142. }
  17143. // ResetSopStage resets all changes to the "sop_stage" edge.
  17144. func (m *SopNodeMutation) ResetSopStage() {
  17145. m.sop_stage = nil
  17146. m.clearedsop_stage = false
  17147. }
  17148. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  17149. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  17150. if m.node_messages == nil {
  17151. m.node_messages = make(map[uint64]struct{})
  17152. }
  17153. for i := range ids {
  17154. m.node_messages[ids[i]] = struct{}{}
  17155. }
  17156. }
  17157. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  17158. func (m *SopNodeMutation) ClearNodeMessages() {
  17159. m.clearednode_messages = true
  17160. }
  17161. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  17162. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  17163. return m.clearednode_messages
  17164. }
  17165. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  17166. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  17167. if m.removednode_messages == nil {
  17168. m.removednode_messages = make(map[uint64]struct{})
  17169. }
  17170. for i := range ids {
  17171. delete(m.node_messages, ids[i])
  17172. m.removednode_messages[ids[i]] = struct{}{}
  17173. }
  17174. }
  17175. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  17176. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  17177. for id := range m.removednode_messages {
  17178. ids = append(ids, id)
  17179. }
  17180. return
  17181. }
  17182. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  17183. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  17184. for id := range m.node_messages {
  17185. ids = append(ids, id)
  17186. }
  17187. return
  17188. }
  17189. // ResetNodeMessages resets all changes to the "node_messages" edge.
  17190. func (m *SopNodeMutation) ResetNodeMessages() {
  17191. m.node_messages = nil
  17192. m.clearednode_messages = false
  17193. m.removednode_messages = nil
  17194. }
  17195. // Where appends a list predicates to the SopNodeMutation builder.
  17196. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  17197. m.predicates = append(m.predicates, ps...)
  17198. }
  17199. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  17200. // users can use type-assertion to append predicates that do not depend on any generated package.
  17201. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  17202. p := make([]predicate.SopNode, len(ps))
  17203. for i := range ps {
  17204. p[i] = ps[i]
  17205. }
  17206. m.Where(p...)
  17207. }
  17208. // Op returns the operation name.
  17209. func (m *SopNodeMutation) Op() Op {
  17210. return m.op
  17211. }
  17212. // SetOp allows setting the mutation operation.
  17213. func (m *SopNodeMutation) SetOp(op Op) {
  17214. m.op = op
  17215. }
  17216. // Type returns the node type of this mutation (SopNode).
  17217. func (m *SopNodeMutation) Type() string {
  17218. return m.typ
  17219. }
  17220. // Fields returns all fields that were changed during this mutation. Note that in
  17221. // order to get all numeric fields that were incremented/decremented, call
  17222. // AddedFields().
  17223. func (m *SopNodeMutation) Fields() []string {
  17224. fields := make([]string, 0, 15)
  17225. if m.created_at != nil {
  17226. fields = append(fields, sopnode.FieldCreatedAt)
  17227. }
  17228. if m.updated_at != nil {
  17229. fields = append(fields, sopnode.FieldUpdatedAt)
  17230. }
  17231. if m.status != nil {
  17232. fields = append(fields, sopnode.FieldStatus)
  17233. }
  17234. if m.deleted_at != nil {
  17235. fields = append(fields, sopnode.FieldDeletedAt)
  17236. }
  17237. if m.sop_stage != nil {
  17238. fields = append(fields, sopnode.FieldStageID)
  17239. }
  17240. if m.parent_id != nil {
  17241. fields = append(fields, sopnode.FieldParentID)
  17242. }
  17243. if m.name != nil {
  17244. fields = append(fields, sopnode.FieldName)
  17245. }
  17246. if m.condition_type != nil {
  17247. fields = append(fields, sopnode.FieldConditionType)
  17248. }
  17249. if m.condition_list != nil {
  17250. fields = append(fields, sopnode.FieldConditionList)
  17251. }
  17252. if m.no_reply_condition != nil {
  17253. fields = append(fields, sopnode.FieldNoReplyCondition)
  17254. }
  17255. if m.no_reply_unit != nil {
  17256. fields = append(fields, sopnode.FieldNoReplyUnit)
  17257. }
  17258. if m.action_message != nil {
  17259. fields = append(fields, sopnode.FieldActionMessage)
  17260. }
  17261. if m.action_label_add != nil {
  17262. fields = append(fields, sopnode.FieldActionLabelAdd)
  17263. }
  17264. if m.action_label_del != nil {
  17265. fields = append(fields, sopnode.FieldActionLabelDel)
  17266. }
  17267. if m.action_forward != nil {
  17268. fields = append(fields, sopnode.FieldActionForward)
  17269. }
  17270. return fields
  17271. }
  17272. // Field returns the value of a field with the given name. The second boolean
  17273. // return value indicates that this field was not set, or was not defined in the
  17274. // schema.
  17275. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  17276. switch name {
  17277. case sopnode.FieldCreatedAt:
  17278. return m.CreatedAt()
  17279. case sopnode.FieldUpdatedAt:
  17280. return m.UpdatedAt()
  17281. case sopnode.FieldStatus:
  17282. return m.Status()
  17283. case sopnode.FieldDeletedAt:
  17284. return m.DeletedAt()
  17285. case sopnode.FieldStageID:
  17286. return m.StageID()
  17287. case sopnode.FieldParentID:
  17288. return m.ParentID()
  17289. case sopnode.FieldName:
  17290. return m.Name()
  17291. case sopnode.FieldConditionType:
  17292. return m.ConditionType()
  17293. case sopnode.FieldConditionList:
  17294. return m.ConditionList()
  17295. case sopnode.FieldNoReplyCondition:
  17296. return m.NoReplyCondition()
  17297. case sopnode.FieldNoReplyUnit:
  17298. return m.NoReplyUnit()
  17299. case sopnode.FieldActionMessage:
  17300. return m.ActionMessage()
  17301. case sopnode.FieldActionLabelAdd:
  17302. return m.ActionLabelAdd()
  17303. case sopnode.FieldActionLabelDel:
  17304. return m.ActionLabelDel()
  17305. case sopnode.FieldActionForward:
  17306. return m.ActionForward()
  17307. }
  17308. return nil, false
  17309. }
  17310. // OldField returns the old value of the field from the database. An error is
  17311. // returned if the mutation operation is not UpdateOne, or the query to the
  17312. // database failed.
  17313. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17314. switch name {
  17315. case sopnode.FieldCreatedAt:
  17316. return m.OldCreatedAt(ctx)
  17317. case sopnode.FieldUpdatedAt:
  17318. return m.OldUpdatedAt(ctx)
  17319. case sopnode.FieldStatus:
  17320. return m.OldStatus(ctx)
  17321. case sopnode.FieldDeletedAt:
  17322. return m.OldDeletedAt(ctx)
  17323. case sopnode.FieldStageID:
  17324. return m.OldStageID(ctx)
  17325. case sopnode.FieldParentID:
  17326. return m.OldParentID(ctx)
  17327. case sopnode.FieldName:
  17328. return m.OldName(ctx)
  17329. case sopnode.FieldConditionType:
  17330. return m.OldConditionType(ctx)
  17331. case sopnode.FieldConditionList:
  17332. return m.OldConditionList(ctx)
  17333. case sopnode.FieldNoReplyCondition:
  17334. return m.OldNoReplyCondition(ctx)
  17335. case sopnode.FieldNoReplyUnit:
  17336. return m.OldNoReplyUnit(ctx)
  17337. case sopnode.FieldActionMessage:
  17338. return m.OldActionMessage(ctx)
  17339. case sopnode.FieldActionLabelAdd:
  17340. return m.OldActionLabelAdd(ctx)
  17341. case sopnode.FieldActionLabelDel:
  17342. return m.OldActionLabelDel(ctx)
  17343. case sopnode.FieldActionForward:
  17344. return m.OldActionForward(ctx)
  17345. }
  17346. return nil, fmt.Errorf("unknown SopNode field %s", name)
  17347. }
  17348. // SetField sets the value of a field with the given name. It returns an error if
  17349. // the field is not defined in the schema, or if the type mismatched the field
  17350. // type.
  17351. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  17352. switch name {
  17353. case sopnode.FieldCreatedAt:
  17354. v, ok := value.(time.Time)
  17355. if !ok {
  17356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17357. }
  17358. m.SetCreatedAt(v)
  17359. return nil
  17360. case sopnode.FieldUpdatedAt:
  17361. v, ok := value.(time.Time)
  17362. if !ok {
  17363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17364. }
  17365. m.SetUpdatedAt(v)
  17366. return nil
  17367. case sopnode.FieldStatus:
  17368. v, ok := value.(uint8)
  17369. if !ok {
  17370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17371. }
  17372. m.SetStatus(v)
  17373. return nil
  17374. case sopnode.FieldDeletedAt:
  17375. v, ok := value.(time.Time)
  17376. if !ok {
  17377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17378. }
  17379. m.SetDeletedAt(v)
  17380. return nil
  17381. case sopnode.FieldStageID:
  17382. v, ok := value.(uint64)
  17383. if !ok {
  17384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17385. }
  17386. m.SetStageID(v)
  17387. return nil
  17388. case sopnode.FieldParentID:
  17389. v, ok := value.(uint64)
  17390. if !ok {
  17391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17392. }
  17393. m.SetParentID(v)
  17394. return nil
  17395. case sopnode.FieldName:
  17396. v, ok := value.(string)
  17397. if !ok {
  17398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17399. }
  17400. m.SetName(v)
  17401. return nil
  17402. case sopnode.FieldConditionType:
  17403. v, ok := value.(int)
  17404. if !ok {
  17405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17406. }
  17407. m.SetConditionType(v)
  17408. return nil
  17409. case sopnode.FieldConditionList:
  17410. v, ok := value.([]string)
  17411. if !ok {
  17412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17413. }
  17414. m.SetConditionList(v)
  17415. return nil
  17416. case sopnode.FieldNoReplyCondition:
  17417. v, ok := value.(uint64)
  17418. if !ok {
  17419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17420. }
  17421. m.SetNoReplyCondition(v)
  17422. return nil
  17423. case sopnode.FieldNoReplyUnit:
  17424. v, ok := value.(string)
  17425. if !ok {
  17426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17427. }
  17428. m.SetNoReplyUnit(v)
  17429. return nil
  17430. case sopnode.FieldActionMessage:
  17431. v, ok := value.([]custom_types.Action)
  17432. if !ok {
  17433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17434. }
  17435. m.SetActionMessage(v)
  17436. return nil
  17437. case sopnode.FieldActionLabelAdd:
  17438. v, ok := value.([]uint64)
  17439. if !ok {
  17440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17441. }
  17442. m.SetActionLabelAdd(v)
  17443. return nil
  17444. case sopnode.FieldActionLabelDel:
  17445. v, ok := value.([]uint64)
  17446. if !ok {
  17447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17448. }
  17449. m.SetActionLabelDel(v)
  17450. return nil
  17451. case sopnode.FieldActionForward:
  17452. v, ok := value.(*custom_types.ActionForward)
  17453. if !ok {
  17454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17455. }
  17456. m.SetActionForward(v)
  17457. return nil
  17458. }
  17459. return fmt.Errorf("unknown SopNode field %s", name)
  17460. }
  17461. // AddedFields returns all numeric fields that were incremented/decremented during
  17462. // this mutation.
  17463. func (m *SopNodeMutation) AddedFields() []string {
  17464. var fields []string
  17465. if m.addstatus != nil {
  17466. fields = append(fields, sopnode.FieldStatus)
  17467. }
  17468. if m.addparent_id != nil {
  17469. fields = append(fields, sopnode.FieldParentID)
  17470. }
  17471. if m.addcondition_type != nil {
  17472. fields = append(fields, sopnode.FieldConditionType)
  17473. }
  17474. if m.addno_reply_condition != nil {
  17475. fields = append(fields, sopnode.FieldNoReplyCondition)
  17476. }
  17477. return fields
  17478. }
  17479. // AddedField returns the numeric value that was incremented/decremented on a field
  17480. // with the given name. The second boolean return value indicates that this field
  17481. // was not set, or was not defined in the schema.
  17482. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  17483. switch name {
  17484. case sopnode.FieldStatus:
  17485. return m.AddedStatus()
  17486. case sopnode.FieldParentID:
  17487. return m.AddedParentID()
  17488. case sopnode.FieldConditionType:
  17489. return m.AddedConditionType()
  17490. case sopnode.FieldNoReplyCondition:
  17491. return m.AddedNoReplyCondition()
  17492. }
  17493. return nil, false
  17494. }
  17495. // AddField adds the value to the field with the given name. It returns an error if
  17496. // the field is not defined in the schema, or if the type mismatched the field
  17497. // type.
  17498. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  17499. switch name {
  17500. case sopnode.FieldStatus:
  17501. v, ok := value.(int8)
  17502. if !ok {
  17503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17504. }
  17505. m.AddStatus(v)
  17506. return nil
  17507. case sopnode.FieldParentID:
  17508. v, ok := value.(int64)
  17509. if !ok {
  17510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17511. }
  17512. m.AddParentID(v)
  17513. return nil
  17514. case sopnode.FieldConditionType:
  17515. v, ok := value.(int)
  17516. if !ok {
  17517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17518. }
  17519. m.AddConditionType(v)
  17520. return nil
  17521. case sopnode.FieldNoReplyCondition:
  17522. v, ok := value.(int64)
  17523. if !ok {
  17524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17525. }
  17526. m.AddNoReplyCondition(v)
  17527. return nil
  17528. }
  17529. return fmt.Errorf("unknown SopNode numeric field %s", name)
  17530. }
  17531. // ClearedFields returns all nullable fields that were cleared during this
  17532. // mutation.
  17533. func (m *SopNodeMutation) ClearedFields() []string {
  17534. var fields []string
  17535. if m.FieldCleared(sopnode.FieldStatus) {
  17536. fields = append(fields, sopnode.FieldStatus)
  17537. }
  17538. if m.FieldCleared(sopnode.FieldDeletedAt) {
  17539. fields = append(fields, sopnode.FieldDeletedAt)
  17540. }
  17541. if m.FieldCleared(sopnode.FieldConditionList) {
  17542. fields = append(fields, sopnode.FieldConditionList)
  17543. }
  17544. if m.FieldCleared(sopnode.FieldActionMessage) {
  17545. fields = append(fields, sopnode.FieldActionMessage)
  17546. }
  17547. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  17548. fields = append(fields, sopnode.FieldActionLabelAdd)
  17549. }
  17550. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  17551. fields = append(fields, sopnode.FieldActionLabelDel)
  17552. }
  17553. if m.FieldCleared(sopnode.FieldActionForward) {
  17554. fields = append(fields, sopnode.FieldActionForward)
  17555. }
  17556. return fields
  17557. }
  17558. // FieldCleared returns a boolean indicating if a field with the given name was
  17559. // cleared in this mutation.
  17560. func (m *SopNodeMutation) FieldCleared(name string) bool {
  17561. _, ok := m.clearedFields[name]
  17562. return ok
  17563. }
  17564. // ClearField clears the value of the field with the given name. It returns an
  17565. // error if the field is not defined in the schema.
  17566. func (m *SopNodeMutation) ClearField(name string) error {
  17567. switch name {
  17568. case sopnode.FieldStatus:
  17569. m.ClearStatus()
  17570. return nil
  17571. case sopnode.FieldDeletedAt:
  17572. m.ClearDeletedAt()
  17573. return nil
  17574. case sopnode.FieldConditionList:
  17575. m.ClearConditionList()
  17576. return nil
  17577. case sopnode.FieldActionMessage:
  17578. m.ClearActionMessage()
  17579. return nil
  17580. case sopnode.FieldActionLabelAdd:
  17581. m.ClearActionLabelAdd()
  17582. return nil
  17583. case sopnode.FieldActionLabelDel:
  17584. m.ClearActionLabelDel()
  17585. return nil
  17586. case sopnode.FieldActionForward:
  17587. m.ClearActionForward()
  17588. return nil
  17589. }
  17590. return fmt.Errorf("unknown SopNode nullable field %s", name)
  17591. }
  17592. // ResetField resets all changes in the mutation for the field with the given name.
  17593. // It returns an error if the field is not defined in the schema.
  17594. func (m *SopNodeMutation) ResetField(name string) error {
  17595. switch name {
  17596. case sopnode.FieldCreatedAt:
  17597. m.ResetCreatedAt()
  17598. return nil
  17599. case sopnode.FieldUpdatedAt:
  17600. m.ResetUpdatedAt()
  17601. return nil
  17602. case sopnode.FieldStatus:
  17603. m.ResetStatus()
  17604. return nil
  17605. case sopnode.FieldDeletedAt:
  17606. m.ResetDeletedAt()
  17607. return nil
  17608. case sopnode.FieldStageID:
  17609. m.ResetStageID()
  17610. return nil
  17611. case sopnode.FieldParentID:
  17612. m.ResetParentID()
  17613. return nil
  17614. case sopnode.FieldName:
  17615. m.ResetName()
  17616. return nil
  17617. case sopnode.FieldConditionType:
  17618. m.ResetConditionType()
  17619. return nil
  17620. case sopnode.FieldConditionList:
  17621. m.ResetConditionList()
  17622. return nil
  17623. case sopnode.FieldNoReplyCondition:
  17624. m.ResetNoReplyCondition()
  17625. return nil
  17626. case sopnode.FieldNoReplyUnit:
  17627. m.ResetNoReplyUnit()
  17628. return nil
  17629. case sopnode.FieldActionMessage:
  17630. m.ResetActionMessage()
  17631. return nil
  17632. case sopnode.FieldActionLabelAdd:
  17633. m.ResetActionLabelAdd()
  17634. return nil
  17635. case sopnode.FieldActionLabelDel:
  17636. m.ResetActionLabelDel()
  17637. return nil
  17638. case sopnode.FieldActionForward:
  17639. m.ResetActionForward()
  17640. return nil
  17641. }
  17642. return fmt.Errorf("unknown SopNode field %s", name)
  17643. }
  17644. // AddedEdges returns all edge names that were set/added in this mutation.
  17645. func (m *SopNodeMutation) AddedEdges() []string {
  17646. edges := make([]string, 0, 2)
  17647. if m.sop_stage != nil {
  17648. edges = append(edges, sopnode.EdgeSopStage)
  17649. }
  17650. if m.node_messages != nil {
  17651. edges = append(edges, sopnode.EdgeNodeMessages)
  17652. }
  17653. return edges
  17654. }
  17655. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17656. // name in this mutation.
  17657. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  17658. switch name {
  17659. case sopnode.EdgeSopStage:
  17660. if id := m.sop_stage; id != nil {
  17661. return []ent.Value{*id}
  17662. }
  17663. case sopnode.EdgeNodeMessages:
  17664. ids := make([]ent.Value, 0, len(m.node_messages))
  17665. for id := range m.node_messages {
  17666. ids = append(ids, id)
  17667. }
  17668. return ids
  17669. }
  17670. return nil
  17671. }
  17672. // RemovedEdges returns all edge names that were removed in this mutation.
  17673. func (m *SopNodeMutation) RemovedEdges() []string {
  17674. edges := make([]string, 0, 2)
  17675. if m.removednode_messages != nil {
  17676. edges = append(edges, sopnode.EdgeNodeMessages)
  17677. }
  17678. return edges
  17679. }
  17680. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17681. // the given name in this mutation.
  17682. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  17683. switch name {
  17684. case sopnode.EdgeNodeMessages:
  17685. ids := make([]ent.Value, 0, len(m.removednode_messages))
  17686. for id := range m.removednode_messages {
  17687. ids = append(ids, id)
  17688. }
  17689. return ids
  17690. }
  17691. return nil
  17692. }
  17693. // ClearedEdges returns all edge names that were cleared in this mutation.
  17694. func (m *SopNodeMutation) ClearedEdges() []string {
  17695. edges := make([]string, 0, 2)
  17696. if m.clearedsop_stage {
  17697. edges = append(edges, sopnode.EdgeSopStage)
  17698. }
  17699. if m.clearednode_messages {
  17700. edges = append(edges, sopnode.EdgeNodeMessages)
  17701. }
  17702. return edges
  17703. }
  17704. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17705. // was cleared in this mutation.
  17706. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  17707. switch name {
  17708. case sopnode.EdgeSopStage:
  17709. return m.clearedsop_stage
  17710. case sopnode.EdgeNodeMessages:
  17711. return m.clearednode_messages
  17712. }
  17713. return false
  17714. }
  17715. // ClearEdge clears the value of the edge with the given name. It returns an error
  17716. // if that edge is not defined in the schema.
  17717. func (m *SopNodeMutation) ClearEdge(name string) error {
  17718. switch name {
  17719. case sopnode.EdgeSopStage:
  17720. m.ClearSopStage()
  17721. return nil
  17722. }
  17723. return fmt.Errorf("unknown SopNode unique edge %s", name)
  17724. }
  17725. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17726. // It returns an error if the edge is not defined in the schema.
  17727. func (m *SopNodeMutation) ResetEdge(name string) error {
  17728. switch name {
  17729. case sopnode.EdgeSopStage:
  17730. m.ResetSopStage()
  17731. return nil
  17732. case sopnode.EdgeNodeMessages:
  17733. m.ResetNodeMessages()
  17734. return nil
  17735. }
  17736. return fmt.Errorf("unknown SopNode edge %s", name)
  17737. }
  17738. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  17739. type SopStageMutation struct {
  17740. config
  17741. op Op
  17742. typ string
  17743. id *uint64
  17744. created_at *time.Time
  17745. updated_at *time.Time
  17746. status *uint8
  17747. addstatus *int8
  17748. deleted_at *time.Time
  17749. name *string
  17750. condition_type *int
  17751. addcondition_type *int
  17752. condition_operator *int
  17753. addcondition_operator *int
  17754. condition_list *[]custom_types.Condition
  17755. appendcondition_list []custom_types.Condition
  17756. action_message *[]custom_types.Action
  17757. appendaction_message []custom_types.Action
  17758. action_label_add *[]uint64
  17759. appendaction_label_add []uint64
  17760. action_label_del *[]uint64
  17761. appendaction_label_del []uint64
  17762. action_forward **custom_types.ActionForward
  17763. index_sort *int
  17764. addindex_sort *int
  17765. clearedFields map[string]struct{}
  17766. sop_task *uint64
  17767. clearedsop_task bool
  17768. stage_nodes map[uint64]struct{}
  17769. removedstage_nodes map[uint64]struct{}
  17770. clearedstage_nodes bool
  17771. stage_messages map[uint64]struct{}
  17772. removedstage_messages map[uint64]struct{}
  17773. clearedstage_messages bool
  17774. done bool
  17775. oldValue func(context.Context) (*SopStage, error)
  17776. predicates []predicate.SopStage
  17777. }
  17778. var _ ent.Mutation = (*SopStageMutation)(nil)
  17779. // sopstageOption allows management of the mutation configuration using functional options.
  17780. type sopstageOption func(*SopStageMutation)
  17781. // newSopStageMutation creates new mutation for the SopStage entity.
  17782. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  17783. m := &SopStageMutation{
  17784. config: c,
  17785. op: op,
  17786. typ: TypeSopStage,
  17787. clearedFields: make(map[string]struct{}),
  17788. }
  17789. for _, opt := range opts {
  17790. opt(m)
  17791. }
  17792. return m
  17793. }
  17794. // withSopStageID sets the ID field of the mutation.
  17795. func withSopStageID(id uint64) sopstageOption {
  17796. return func(m *SopStageMutation) {
  17797. var (
  17798. err error
  17799. once sync.Once
  17800. value *SopStage
  17801. )
  17802. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  17803. once.Do(func() {
  17804. if m.done {
  17805. err = errors.New("querying old values post mutation is not allowed")
  17806. } else {
  17807. value, err = m.Client().SopStage.Get(ctx, id)
  17808. }
  17809. })
  17810. return value, err
  17811. }
  17812. m.id = &id
  17813. }
  17814. }
  17815. // withSopStage sets the old SopStage of the mutation.
  17816. func withSopStage(node *SopStage) sopstageOption {
  17817. return func(m *SopStageMutation) {
  17818. m.oldValue = func(context.Context) (*SopStage, error) {
  17819. return node, nil
  17820. }
  17821. m.id = &node.ID
  17822. }
  17823. }
  17824. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17825. // executed in a transaction (ent.Tx), a transactional client is returned.
  17826. func (m SopStageMutation) Client() *Client {
  17827. client := &Client{config: m.config}
  17828. client.init()
  17829. return client
  17830. }
  17831. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17832. // it returns an error otherwise.
  17833. func (m SopStageMutation) Tx() (*Tx, error) {
  17834. if _, ok := m.driver.(*txDriver); !ok {
  17835. return nil, errors.New("ent: mutation is not running in a transaction")
  17836. }
  17837. tx := &Tx{config: m.config}
  17838. tx.init()
  17839. return tx, nil
  17840. }
  17841. // SetID sets the value of the id field. Note that this
  17842. // operation is only accepted on creation of SopStage entities.
  17843. func (m *SopStageMutation) SetID(id uint64) {
  17844. m.id = &id
  17845. }
  17846. // ID returns the ID value in the mutation. Note that the ID is only available
  17847. // if it was provided to the builder or after it was returned from the database.
  17848. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  17849. if m.id == nil {
  17850. return
  17851. }
  17852. return *m.id, true
  17853. }
  17854. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17855. // That means, if the mutation is applied within a transaction with an isolation level such
  17856. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17857. // or updated by the mutation.
  17858. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  17859. switch {
  17860. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17861. id, exists := m.ID()
  17862. if exists {
  17863. return []uint64{id}, nil
  17864. }
  17865. fallthrough
  17866. case m.op.Is(OpUpdate | OpDelete):
  17867. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  17868. default:
  17869. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17870. }
  17871. }
  17872. // SetCreatedAt sets the "created_at" field.
  17873. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  17874. m.created_at = &t
  17875. }
  17876. // CreatedAt returns the value of the "created_at" field in the mutation.
  17877. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  17878. v := m.created_at
  17879. if v == nil {
  17880. return
  17881. }
  17882. return *v, true
  17883. }
  17884. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  17885. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17887. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17888. if !m.op.Is(OpUpdateOne) {
  17889. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17890. }
  17891. if m.id == nil || m.oldValue == nil {
  17892. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17893. }
  17894. oldValue, err := m.oldValue(ctx)
  17895. if err != nil {
  17896. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17897. }
  17898. return oldValue.CreatedAt, nil
  17899. }
  17900. // ResetCreatedAt resets all changes to the "created_at" field.
  17901. func (m *SopStageMutation) ResetCreatedAt() {
  17902. m.created_at = nil
  17903. }
  17904. // SetUpdatedAt sets the "updated_at" field.
  17905. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  17906. m.updated_at = &t
  17907. }
  17908. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17909. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  17910. v := m.updated_at
  17911. if v == nil {
  17912. return
  17913. }
  17914. return *v, true
  17915. }
  17916. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  17917. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17919. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17920. if !m.op.Is(OpUpdateOne) {
  17921. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17922. }
  17923. if m.id == nil || m.oldValue == nil {
  17924. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17925. }
  17926. oldValue, err := m.oldValue(ctx)
  17927. if err != nil {
  17928. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17929. }
  17930. return oldValue.UpdatedAt, nil
  17931. }
  17932. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17933. func (m *SopStageMutation) ResetUpdatedAt() {
  17934. m.updated_at = nil
  17935. }
  17936. // SetStatus sets the "status" field.
  17937. func (m *SopStageMutation) SetStatus(u uint8) {
  17938. m.status = &u
  17939. m.addstatus = nil
  17940. }
  17941. // Status returns the value of the "status" field in the mutation.
  17942. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  17943. v := m.status
  17944. if v == nil {
  17945. return
  17946. }
  17947. return *v, true
  17948. }
  17949. // OldStatus returns the old "status" field's value of the SopStage entity.
  17950. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17952. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17953. if !m.op.Is(OpUpdateOne) {
  17954. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17955. }
  17956. if m.id == nil || m.oldValue == nil {
  17957. return v, errors.New("OldStatus requires an ID field in the mutation")
  17958. }
  17959. oldValue, err := m.oldValue(ctx)
  17960. if err != nil {
  17961. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17962. }
  17963. return oldValue.Status, nil
  17964. }
  17965. // AddStatus adds u to the "status" field.
  17966. func (m *SopStageMutation) AddStatus(u int8) {
  17967. if m.addstatus != nil {
  17968. *m.addstatus += u
  17969. } else {
  17970. m.addstatus = &u
  17971. }
  17972. }
  17973. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17974. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  17975. v := m.addstatus
  17976. if v == nil {
  17977. return
  17978. }
  17979. return *v, true
  17980. }
  17981. // ClearStatus clears the value of the "status" field.
  17982. func (m *SopStageMutation) ClearStatus() {
  17983. m.status = nil
  17984. m.addstatus = nil
  17985. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  17986. }
  17987. // StatusCleared returns if the "status" field was cleared in this mutation.
  17988. func (m *SopStageMutation) StatusCleared() bool {
  17989. _, ok := m.clearedFields[sopstage.FieldStatus]
  17990. return ok
  17991. }
  17992. // ResetStatus resets all changes to the "status" field.
  17993. func (m *SopStageMutation) ResetStatus() {
  17994. m.status = nil
  17995. m.addstatus = nil
  17996. delete(m.clearedFields, sopstage.FieldStatus)
  17997. }
  17998. // SetDeletedAt sets the "deleted_at" field.
  17999. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  18000. m.deleted_at = &t
  18001. }
  18002. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18003. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  18004. v := m.deleted_at
  18005. if v == nil {
  18006. return
  18007. }
  18008. return *v, true
  18009. }
  18010. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  18011. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18013. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18014. if !m.op.Is(OpUpdateOne) {
  18015. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18016. }
  18017. if m.id == nil || m.oldValue == nil {
  18018. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18019. }
  18020. oldValue, err := m.oldValue(ctx)
  18021. if err != nil {
  18022. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18023. }
  18024. return oldValue.DeletedAt, nil
  18025. }
  18026. // ClearDeletedAt clears the value of the "deleted_at" field.
  18027. func (m *SopStageMutation) ClearDeletedAt() {
  18028. m.deleted_at = nil
  18029. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  18030. }
  18031. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18032. func (m *SopStageMutation) DeletedAtCleared() bool {
  18033. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  18034. return ok
  18035. }
  18036. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18037. func (m *SopStageMutation) ResetDeletedAt() {
  18038. m.deleted_at = nil
  18039. delete(m.clearedFields, sopstage.FieldDeletedAt)
  18040. }
  18041. // SetTaskID sets the "task_id" field.
  18042. func (m *SopStageMutation) SetTaskID(u uint64) {
  18043. m.sop_task = &u
  18044. }
  18045. // TaskID returns the value of the "task_id" field in the mutation.
  18046. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  18047. v := m.sop_task
  18048. if v == nil {
  18049. return
  18050. }
  18051. return *v, true
  18052. }
  18053. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  18054. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18056. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  18057. if !m.op.Is(OpUpdateOne) {
  18058. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  18059. }
  18060. if m.id == nil || m.oldValue == nil {
  18061. return v, errors.New("OldTaskID requires an ID field in the mutation")
  18062. }
  18063. oldValue, err := m.oldValue(ctx)
  18064. if err != nil {
  18065. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  18066. }
  18067. return oldValue.TaskID, nil
  18068. }
  18069. // ResetTaskID resets all changes to the "task_id" field.
  18070. func (m *SopStageMutation) ResetTaskID() {
  18071. m.sop_task = nil
  18072. }
  18073. // SetName sets the "name" field.
  18074. func (m *SopStageMutation) SetName(s string) {
  18075. m.name = &s
  18076. }
  18077. // Name returns the value of the "name" field in the mutation.
  18078. func (m *SopStageMutation) Name() (r string, exists bool) {
  18079. v := m.name
  18080. if v == nil {
  18081. return
  18082. }
  18083. return *v, true
  18084. }
  18085. // OldName returns the old "name" field's value of the SopStage entity.
  18086. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18088. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  18089. if !m.op.Is(OpUpdateOne) {
  18090. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18091. }
  18092. if m.id == nil || m.oldValue == nil {
  18093. return v, errors.New("OldName requires an ID field in the mutation")
  18094. }
  18095. oldValue, err := m.oldValue(ctx)
  18096. if err != nil {
  18097. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18098. }
  18099. return oldValue.Name, nil
  18100. }
  18101. // ResetName resets all changes to the "name" field.
  18102. func (m *SopStageMutation) ResetName() {
  18103. m.name = nil
  18104. }
  18105. // SetConditionType sets the "condition_type" field.
  18106. func (m *SopStageMutation) SetConditionType(i int) {
  18107. m.condition_type = &i
  18108. m.addcondition_type = nil
  18109. }
  18110. // ConditionType returns the value of the "condition_type" field in the mutation.
  18111. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  18112. v := m.condition_type
  18113. if v == nil {
  18114. return
  18115. }
  18116. return *v, true
  18117. }
  18118. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  18119. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18121. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18122. if !m.op.Is(OpUpdateOne) {
  18123. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18124. }
  18125. if m.id == nil || m.oldValue == nil {
  18126. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18127. }
  18128. oldValue, err := m.oldValue(ctx)
  18129. if err != nil {
  18130. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18131. }
  18132. return oldValue.ConditionType, nil
  18133. }
  18134. // AddConditionType adds i to the "condition_type" field.
  18135. func (m *SopStageMutation) AddConditionType(i int) {
  18136. if m.addcondition_type != nil {
  18137. *m.addcondition_type += i
  18138. } else {
  18139. m.addcondition_type = &i
  18140. }
  18141. }
  18142. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18143. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  18144. v := m.addcondition_type
  18145. if v == nil {
  18146. return
  18147. }
  18148. return *v, true
  18149. }
  18150. // ResetConditionType resets all changes to the "condition_type" field.
  18151. func (m *SopStageMutation) ResetConditionType() {
  18152. m.condition_type = nil
  18153. m.addcondition_type = nil
  18154. }
  18155. // SetConditionOperator sets the "condition_operator" field.
  18156. func (m *SopStageMutation) SetConditionOperator(i int) {
  18157. m.condition_operator = &i
  18158. m.addcondition_operator = nil
  18159. }
  18160. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  18161. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  18162. v := m.condition_operator
  18163. if v == nil {
  18164. return
  18165. }
  18166. return *v, true
  18167. }
  18168. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  18169. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18171. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  18172. if !m.op.Is(OpUpdateOne) {
  18173. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  18174. }
  18175. if m.id == nil || m.oldValue == nil {
  18176. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  18177. }
  18178. oldValue, err := m.oldValue(ctx)
  18179. if err != nil {
  18180. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  18181. }
  18182. return oldValue.ConditionOperator, nil
  18183. }
  18184. // AddConditionOperator adds i to the "condition_operator" field.
  18185. func (m *SopStageMutation) AddConditionOperator(i int) {
  18186. if m.addcondition_operator != nil {
  18187. *m.addcondition_operator += i
  18188. } else {
  18189. m.addcondition_operator = &i
  18190. }
  18191. }
  18192. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  18193. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  18194. v := m.addcondition_operator
  18195. if v == nil {
  18196. return
  18197. }
  18198. return *v, true
  18199. }
  18200. // ResetConditionOperator resets all changes to the "condition_operator" field.
  18201. func (m *SopStageMutation) ResetConditionOperator() {
  18202. m.condition_operator = nil
  18203. m.addcondition_operator = nil
  18204. }
  18205. // SetConditionList sets the "condition_list" field.
  18206. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  18207. m.condition_list = &ct
  18208. m.appendcondition_list = nil
  18209. }
  18210. // ConditionList returns the value of the "condition_list" field in the mutation.
  18211. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  18212. v := m.condition_list
  18213. if v == nil {
  18214. return
  18215. }
  18216. return *v, true
  18217. }
  18218. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  18219. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18221. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  18222. if !m.op.Is(OpUpdateOne) {
  18223. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  18224. }
  18225. if m.id == nil || m.oldValue == nil {
  18226. return v, errors.New("OldConditionList requires an ID field in the mutation")
  18227. }
  18228. oldValue, err := m.oldValue(ctx)
  18229. if err != nil {
  18230. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  18231. }
  18232. return oldValue.ConditionList, nil
  18233. }
  18234. // AppendConditionList adds ct to the "condition_list" field.
  18235. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  18236. m.appendcondition_list = append(m.appendcondition_list, ct...)
  18237. }
  18238. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  18239. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  18240. if len(m.appendcondition_list) == 0 {
  18241. return nil, false
  18242. }
  18243. return m.appendcondition_list, true
  18244. }
  18245. // ResetConditionList resets all changes to the "condition_list" field.
  18246. func (m *SopStageMutation) ResetConditionList() {
  18247. m.condition_list = nil
  18248. m.appendcondition_list = nil
  18249. }
  18250. // SetActionMessage sets the "action_message" field.
  18251. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  18252. m.action_message = &ct
  18253. m.appendaction_message = nil
  18254. }
  18255. // ActionMessage returns the value of the "action_message" field in the mutation.
  18256. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  18257. v := m.action_message
  18258. if v == nil {
  18259. return
  18260. }
  18261. return *v, true
  18262. }
  18263. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  18264. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18266. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  18267. if !m.op.Is(OpUpdateOne) {
  18268. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  18269. }
  18270. if m.id == nil || m.oldValue == nil {
  18271. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  18272. }
  18273. oldValue, err := m.oldValue(ctx)
  18274. if err != nil {
  18275. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  18276. }
  18277. return oldValue.ActionMessage, nil
  18278. }
  18279. // AppendActionMessage adds ct to the "action_message" field.
  18280. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  18281. m.appendaction_message = append(m.appendaction_message, ct...)
  18282. }
  18283. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  18284. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  18285. if len(m.appendaction_message) == 0 {
  18286. return nil, false
  18287. }
  18288. return m.appendaction_message, true
  18289. }
  18290. // ClearActionMessage clears the value of the "action_message" field.
  18291. func (m *SopStageMutation) ClearActionMessage() {
  18292. m.action_message = nil
  18293. m.appendaction_message = nil
  18294. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  18295. }
  18296. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  18297. func (m *SopStageMutation) ActionMessageCleared() bool {
  18298. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  18299. return ok
  18300. }
  18301. // ResetActionMessage resets all changes to the "action_message" field.
  18302. func (m *SopStageMutation) ResetActionMessage() {
  18303. m.action_message = nil
  18304. m.appendaction_message = nil
  18305. delete(m.clearedFields, sopstage.FieldActionMessage)
  18306. }
  18307. // SetActionLabelAdd sets the "action_label_add" field.
  18308. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  18309. m.action_label_add = &u
  18310. m.appendaction_label_add = nil
  18311. }
  18312. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18313. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18314. v := m.action_label_add
  18315. if v == nil {
  18316. return
  18317. }
  18318. return *v, true
  18319. }
  18320. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  18321. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18323. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18324. if !m.op.Is(OpUpdateOne) {
  18325. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18326. }
  18327. if m.id == nil || m.oldValue == nil {
  18328. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18329. }
  18330. oldValue, err := m.oldValue(ctx)
  18331. if err != nil {
  18332. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18333. }
  18334. return oldValue.ActionLabelAdd, nil
  18335. }
  18336. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18337. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  18338. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18339. }
  18340. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18341. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18342. if len(m.appendaction_label_add) == 0 {
  18343. return nil, false
  18344. }
  18345. return m.appendaction_label_add, true
  18346. }
  18347. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18348. func (m *SopStageMutation) ClearActionLabelAdd() {
  18349. m.action_label_add = nil
  18350. m.appendaction_label_add = nil
  18351. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  18352. }
  18353. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18354. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  18355. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  18356. return ok
  18357. }
  18358. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18359. func (m *SopStageMutation) ResetActionLabelAdd() {
  18360. m.action_label_add = nil
  18361. m.appendaction_label_add = nil
  18362. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  18363. }
  18364. // SetActionLabelDel sets the "action_label_del" field.
  18365. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  18366. m.action_label_del = &u
  18367. m.appendaction_label_del = nil
  18368. }
  18369. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18370. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  18371. v := m.action_label_del
  18372. if v == nil {
  18373. return
  18374. }
  18375. return *v, true
  18376. }
  18377. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  18378. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18380. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18381. if !m.op.Is(OpUpdateOne) {
  18382. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18383. }
  18384. if m.id == nil || m.oldValue == nil {
  18385. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18386. }
  18387. oldValue, err := m.oldValue(ctx)
  18388. if err != nil {
  18389. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18390. }
  18391. return oldValue.ActionLabelDel, nil
  18392. }
  18393. // AppendActionLabelDel adds u to the "action_label_del" field.
  18394. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  18395. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18396. }
  18397. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18398. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18399. if len(m.appendaction_label_del) == 0 {
  18400. return nil, false
  18401. }
  18402. return m.appendaction_label_del, true
  18403. }
  18404. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18405. func (m *SopStageMutation) ClearActionLabelDel() {
  18406. m.action_label_del = nil
  18407. m.appendaction_label_del = nil
  18408. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  18409. }
  18410. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18411. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  18412. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  18413. return ok
  18414. }
  18415. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18416. func (m *SopStageMutation) ResetActionLabelDel() {
  18417. m.action_label_del = nil
  18418. m.appendaction_label_del = nil
  18419. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  18420. }
  18421. // SetActionForward sets the "action_forward" field.
  18422. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18423. m.action_forward = &ctf
  18424. }
  18425. // ActionForward returns the value of the "action_forward" field in the mutation.
  18426. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18427. v := m.action_forward
  18428. if v == nil {
  18429. return
  18430. }
  18431. return *v, true
  18432. }
  18433. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  18434. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18436. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18437. if !m.op.Is(OpUpdateOne) {
  18438. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18439. }
  18440. if m.id == nil || m.oldValue == nil {
  18441. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18442. }
  18443. oldValue, err := m.oldValue(ctx)
  18444. if err != nil {
  18445. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18446. }
  18447. return oldValue.ActionForward, nil
  18448. }
  18449. // ClearActionForward clears the value of the "action_forward" field.
  18450. func (m *SopStageMutation) ClearActionForward() {
  18451. m.action_forward = nil
  18452. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  18453. }
  18454. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18455. func (m *SopStageMutation) ActionForwardCleared() bool {
  18456. _, ok := m.clearedFields[sopstage.FieldActionForward]
  18457. return ok
  18458. }
  18459. // ResetActionForward resets all changes to the "action_forward" field.
  18460. func (m *SopStageMutation) ResetActionForward() {
  18461. m.action_forward = nil
  18462. delete(m.clearedFields, sopstage.FieldActionForward)
  18463. }
  18464. // SetIndexSort sets the "index_sort" field.
  18465. func (m *SopStageMutation) SetIndexSort(i int) {
  18466. m.index_sort = &i
  18467. m.addindex_sort = nil
  18468. }
  18469. // IndexSort returns the value of the "index_sort" field in the mutation.
  18470. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  18471. v := m.index_sort
  18472. if v == nil {
  18473. return
  18474. }
  18475. return *v, true
  18476. }
  18477. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  18478. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18480. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  18481. if !m.op.Is(OpUpdateOne) {
  18482. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  18483. }
  18484. if m.id == nil || m.oldValue == nil {
  18485. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  18486. }
  18487. oldValue, err := m.oldValue(ctx)
  18488. if err != nil {
  18489. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  18490. }
  18491. return oldValue.IndexSort, nil
  18492. }
  18493. // AddIndexSort adds i to the "index_sort" field.
  18494. func (m *SopStageMutation) AddIndexSort(i int) {
  18495. if m.addindex_sort != nil {
  18496. *m.addindex_sort += i
  18497. } else {
  18498. m.addindex_sort = &i
  18499. }
  18500. }
  18501. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  18502. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  18503. v := m.addindex_sort
  18504. if v == nil {
  18505. return
  18506. }
  18507. return *v, true
  18508. }
  18509. // ClearIndexSort clears the value of the "index_sort" field.
  18510. func (m *SopStageMutation) ClearIndexSort() {
  18511. m.index_sort = nil
  18512. m.addindex_sort = nil
  18513. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  18514. }
  18515. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  18516. func (m *SopStageMutation) IndexSortCleared() bool {
  18517. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  18518. return ok
  18519. }
  18520. // ResetIndexSort resets all changes to the "index_sort" field.
  18521. func (m *SopStageMutation) ResetIndexSort() {
  18522. m.index_sort = nil
  18523. m.addindex_sort = nil
  18524. delete(m.clearedFields, sopstage.FieldIndexSort)
  18525. }
  18526. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  18527. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  18528. m.sop_task = &id
  18529. }
  18530. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  18531. func (m *SopStageMutation) ClearSopTask() {
  18532. m.clearedsop_task = true
  18533. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  18534. }
  18535. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  18536. func (m *SopStageMutation) SopTaskCleared() bool {
  18537. return m.clearedsop_task
  18538. }
  18539. // SopTaskID returns the "sop_task" edge ID in the mutation.
  18540. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  18541. if m.sop_task != nil {
  18542. return *m.sop_task, true
  18543. }
  18544. return
  18545. }
  18546. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  18547. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18548. // SopTaskID instead. It exists only for internal usage by the builders.
  18549. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  18550. if id := m.sop_task; id != nil {
  18551. ids = append(ids, *id)
  18552. }
  18553. return
  18554. }
  18555. // ResetSopTask resets all changes to the "sop_task" edge.
  18556. func (m *SopStageMutation) ResetSopTask() {
  18557. m.sop_task = nil
  18558. m.clearedsop_task = false
  18559. }
  18560. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  18561. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  18562. if m.stage_nodes == nil {
  18563. m.stage_nodes = make(map[uint64]struct{})
  18564. }
  18565. for i := range ids {
  18566. m.stage_nodes[ids[i]] = struct{}{}
  18567. }
  18568. }
  18569. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  18570. func (m *SopStageMutation) ClearStageNodes() {
  18571. m.clearedstage_nodes = true
  18572. }
  18573. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  18574. func (m *SopStageMutation) StageNodesCleared() bool {
  18575. return m.clearedstage_nodes
  18576. }
  18577. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  18578. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  18579. if m.removedstage_nodes == nil {
  18580. m.removedstage_nodes = make(map[uint64]struct{})
  18581. }
  18582. for i := range ids {
  18583. delete(m.stage_nodes, ids[i])
  18584. m.removedstage_nodes[ids[i]] = struct{}{}
  18585. }
  18586. }
  18587. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  18588. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  18589. for id := range m.removedstage_nodes {
  18590. ids = append(ids, id)
  18591. }
  18592. return
  18593. }
  18594. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  18595. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  18596. for id := range m.stage_nodes {
  18597. ids = append(ids, id)
  18598. }
  18599. return
  18600. }
  18601. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  18602. func (m *SopStageMutation) ResetStageNodes() {
  18603. m.stage_nodes = nil
  18604. m.clearedstage_nodes = false
  18605. m.removedstage_nodes = nil
  18606. }
  18607. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  18608. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  18609. if m.stage_messages == nil {
  18610. m.stage_messages = make(map[uint64]struct{})
  18611. }
  18612. for i := range ids {
  18613. m.stage_messages[ids[i]] = struct{}{}
  18614. }
  18615. }
  18616. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  18617. func (m *SopStageMutation) ClearStageMessages() {
  18618. m.clearedstage_messages = true
  18619. }
  18620. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  18621. func (m *SopStageMutation) StageMessagesCleared() bool {
  18622. return m.clearedstage_messages
  18623. }
  18624. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  18625. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  18626. if m.removedstage_messages == nil {
  18627. m.removedstage_messages = make(map[uint64]struct{})
  18628. }
  18629. for i := range ids {
  18630. delete(m.stage_messages, ids[i])
  18631. m.removedstage_messages[ids[i]] = struct{}{}
  18632. }
  18633. }
  18634. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  18635. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  18636. for id := range m.removedstage_messages {
  18637. ids = append(ids, id)
  18638. }
  18639. return
  18640. }
  18641. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  18642. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  18643. for id := range m.stage_messages {
  18644. ids = append(ids, id)
  18645. }
  18646. return
  18647. }
  18648. // ResetStageMessages resets all changes to the "stage_messages" edge.
  18649. func (m *SopStageMutation) ResetStageMessages() {
  18650. m.stage_messages = nil
  18651. m.clearedstage_messages = false
  18652. m.removedstage_messages = nil
  18653. }
  18654. // Where appends a list predicates to the SopStageMutation builder.
  18655. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  18656. m.predicates = append(m.predicates, ps...)
  18657. }
  18658. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  18659. // users can use type-assertion to append predicates that do not depend on any generated package.
  18660. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  18661. p := make([]predicate.SopStage, len(ps))
  18662. for i := range ps {
  18663. p[i] = ps[i]
  18664. }
  18665. m.Where(p...)
  18666. }
  18667. // Op returns the operation name.
  18668. func (m *SopStageMutation) Op() Op {
  18669. return m.op
  18670. }
  18671. // SetOp allows setting the mutation operation.
  18672. func (m *SopStageMutation) SetOp(op Op) {
  18673. m.op = op
  18674. }
  18675. // Type returns the node type of this mutation (SopStage).
  18676. func (m *SopStageMutation) Type() string {
  18677. return m.typ
  18678. }
  18679. // Fields returns all fields that were changed during this mutation. Note that in
  18680. // order to get all numeric fields that were incremented/decremented, call
  18681. // AddedFields().
  18682. func (m *SopStageMutation) Fields() []string {
  18683. fields := make([]string, 0, 14)
  18684. if m.created_at != nil {
  18685. fields = append(fields, sopstage.FieldCreatedAt)
  18686. }
  18687. if m.updated_at != nil {
  18688. fields = append(fields, sopstage.FieldUpdatedAt)
  18689. }
  18690. if m.status != nil {
  18691. fields = append(fields, sopstage.FieldStatus)
  18692. }
  18693. if m.deleted_at != nil {
  18694. fields = append(fields, sopstage.FieldDeletedAt)
  18695. }
  18696. if m.sop_task != nil {
  18697. fields = append(fields, sopstage.FieldTaskID)
  18698. }
  18699. if m.name != nil {
  18700. fields = append(fields, sopstage.FieldName)
  18701. }
  18702. if m.condition_type != nil {
  18703. fields = append(fields, sopstage.FieldConditionType)
  18704. }
  18705. if m.condition_operator != nil {
  18706. fields = append(fields, sopstage.FieldConditionOperator)
  18707. }
  18708. if m.condition_list != nil {
  18709. fields = append(fields, sopstage.FieldConditionList)
  18710. }
  18711. if m.action_message != nil {
  18712. fields = append(fields, sopstage.FieldActionMessage)
  18713. }
  18714. if m.action_label_add != nil {
  18715. fields = append(fields, sopstage.FieldActionLabelAdd)
  18716. }
  18717. if m.action_label_del != nil {
  18718. fields = append(fields, sopstage.FieldActionLabelDel)
  18719. }
  18720. if m.action_forward != nil {
  18721. fields = append(fields, sopstage.FieldActionForward)
  18722. }
  18723. if m.index_sort != nil {
  18724. fields = append(fields, sopstage.FieldIndexSort)
  18725. }
  18726. return fields
  18727. }
  18728. // Field returns the value of a field with the given name. The second boolean
  18729. // return value indicates that this field was not set, or was not defined in the
  18730. // schema.
  18731. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  18732. switch name {
  18733. case sopstage.FieldCreatedAt:
  18734. return m.CreatedAt()
  18735. case sopstage.FieldUpdatedAt:
  18736. return m.UpdatedAt()
  18737. case sopstage.FieldStatus:
  18738. return m.Status()
  18739. case sopstage.FieldDeletedAt:
  18740. return m.DeletedAt()
  18741. case sopstage.FieldTaskID:
  18742. return m.TaskID()
  18743. case sopstage.FieldName:
  18744. return m.Name()
  18745. case sopstage.FieldConditionType:
  18746. return m.ConditionType()
  18747. case sopstage.FieldConditionOperator:
  18748. return m.ConditionOperator()
  18749. case sopstage.FieldConditionList:
  18750. return m.ConditionList()
  18751. case sopstage.FieldActionMessage:
  18752. return m.ActionMessage()
  18753. case sopstage.FieldActionLabelAdd:
  18754. return m.ActionLabelAdd()
  18755. case sopstage.FieldActionLabelDel:
  18756. return m.ActionLabelDel()
  18757. case sopstage.FieldActionForward:
  18758. return m.ActionForward()
  18759. case sopstage.FieldIndexSort:
  18760. return m.IndexSort()
  18761. }
  18762. return nil, false
  18763. }
  18764. // OldField returns the old value of the field from the database. An error is
  18765. // returned if the mutation operation is not UpdateOne, or the query to the
  18766. // database failed.
  18767. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18768. switch name {
  18769. case sopstage.FieldCreatedAt:
  18770. return m.OldCreatedAt(ctx)
  18771. case sopstage.FieldUpdatedAt:
  18772. return m.OldUpdatedAt(ctx)
  18773. case sopstage.FieldStatus:
  18774. return m.OldStatus(ctx)
  18775. case sopstage.FieldDeletedAt:
  18776. return m.OldDeletedAt(ctx)
  18777. case sopstage.FieldTaskID:
  18778. return m.OldTaskID(ctx)
  18779. case sopstage.FieldName:
  18780. return m.OldName(ctx)
  18781. case sopstage.FieldConditionType:
  18782. return m.OldConditionType(ctx)
  18783. case sopstage.FieldConditionOperator:
  18784. return m.OldConditionOperator(ctx)
  18785. case sopstage.FieldConditionList:
  18786. return m.OldConditionList(ctx)
  18787. case sopstage.FieldActionMessage:
  18788. return m.OldActionMessage(ctx)
  18789. case sopstage.FieldActionLabelAdd:
  18790. return m.OldActionLabelAdd(ctx)
  18791. case sopstage.FieldActionLabelDel:
  18792. return m.OldActionLabelDel(ctx)
  18793. case sopstage.FieldActionForward:
  18794. return m.OldActionForward(ctx)
  18795. case sopstage.FieldIndexSort:
  18796. return m.OldIndexSort(ctx)
  18797. }
  18798. return nil, fmt.Errorf("unknown SopStage field %s", name)
  18799. }
  18800. // SetField sets the value of a field with the given name. It returns an error if
  18801. // the field is not defined in the schema, or if the type mismatched the field
  18802. // type.
  18803. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  18804. switch name {
  18805. case sopstage.FieldCreatedAt:
  18806. v, ok := value.(time.Time)
  18807. if !ok {
  18808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18809. }
  18810. m.SetCreatedAt(v)
  18811. return nil
  18812. case sopstage.FieldUpdatedAt:
  18813. v, ok := value.(time.Time)
  18814. if !ok {
  18815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18816. }
  18817. m.SetUpdatedAt(v)
  18818. return nil
  18819. case sopstage.FieldStatus:
  18820. v, ok := value.(uint8)
  18821. if !ok {
  18822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18823. }
  18824. m.SetStatus(v)
  18825. return nil
  18826. case sopstage.FieldDeletedAt:
  18827. v, ok := value.(time.Time)
  18828. if !ok {
  18829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18830. }
  18831. m.SetDeletedAt(v)
  18832. return nil
  18833. case sopstage.FieldTaskID:
  18834. v, ok := value.(uint64)
  18835. if !ok {
  18836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18837. }
  18838. m.SetTaskID(v)
  18839. return nil
  18840. case sopstage.FieldName:
  18841. v, ok := value.(string)
  18842. if !ok {
  18843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18844. }
  18845. m.SetName(v)
  18846. return nil
  18847. case sopstage.FieldConditionType:
  18848. v, ok := value.(int)
  18849. if !ok {
  18850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18851. }
  18852. m.SetConditionType(v)
  18853. return nil
  18854. case sopstage.FieldConditionOperator:
  18855. v, ok := value.(int)
  18856. if !ok {
  18857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18858. }
  18859. m.SetConditionOperator(v)
  18860. return nil
  18861. case sopstage.FieldConditionList:
  18862. v, ok := value.([]custom_types.Condition)
  18863. if !ok {
  18864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18865. }
  18866. m.SetConditionList(v)
  18867. return nil
  18868. case sopstage.FieldActionMessage:
  18869. v, ok := value.([]custom_types.Action)
  18870. if !ok {
  18871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18872. }
  18873. m.SetActionMessage(v)
  18874. return nil
  18875. case sopstage.FieldActionLabelAdd:
  18876. v, ok := value.([]uint64)
  18877. if !ok {
  18878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18879. }
  18880. m.SetActionLabelAdd(v)
  18881. return nil
  18882. case sopstage.FieldActionLabelDel:
  18883. v, ok := value.([]uint64)
  18884. if !ok {
  18885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18886. }
  18887. m.SetActionLabelDel(v)
  18888. return nil
  18889. case sopstage.FieldActionForward:
  18890. v, ok := value.(*custom_types.ActionForward)
  18891. if !ok {
  18892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18893. }
  18894. m.SetActionForward(v)
  18895. return nil
  18896. case sopstage.FieldIndexSort:
  18897. v, ok := value.(int)
  18898. if !ok {
  18899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18900. }
  18901. m.SetIndexSort(v)
  18902. return nil
  18903. }
  18904. return fmt.Errorf("unknown SopStage field %s", name)
  18905. }
  18906. // AddedFields returns all numeric fields that were incremented/decremented during
  18907. // this mutation.
  18908. func (m *SopStageMutation) AddedFields() []string {
  18909. var fields []string
  18910. if m.addstatus != nil {
  18911. fields = append(fields, sopstage.FieldStatus)
  18912. }
  18913. if m.addcondition_type != nil {
  18914. fields = append(fields, sopstage.FieldConditionType)
  18915. }
  18916. if m.addcondition_operator != nil {
  18917. fields = append(fields, sopstage.FieldConditionOperator)
  18918. }
  18919. if m.addindex_sort != nil {
  18920. fields = append(fields, sopstage.FieldIndexSort)
  18921. }
  18922. return fields
  18923. }
  18924. // AddedField returns the numeric value that was incremented/decremented on a field
  18925. // with the given name. The second boolean return value indicates that this field
  18926. // was not set, or was not defined in the schema.
  18927. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  18928. switch name {
  18929. case sopstage.FieldStatus:
  18930. return m.AddedStatus()
  18931. case sopstage.FieldConditionType:
  18932. return m.AddedConditionType()
  18933. case sopstage.FieldConditionOperator:
  18934. return m.AddedConditionOperator()
  18935. case sopstage.FieldIndexSort:
  18936. return m.AddedIndexSort()
  18937. }
  18938. return nil, false
  18939. }
  18940. // AddField adds the value to the field with the given name. It returns an error if
  18941. // the field is not defined in the schema, or if the type mismatched the field
  18942. // type.
  18943. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  18944. switch name {
  18945. case sopstage.FieldStatus:
  18946. v, ok := value.(int8)
  18947. if !ok {
  18948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18949. }
  18950. m.AddStatus(v)
  18951. return nil
  18952. case sopstage.FieldConditionType:
  18953. v, ok := value.(int)
  18954. if !ok {
  18955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18956. }
  18957. m.AddConditionType(v)
  18958. return nil
  18959. case sopstage.FieldConditionOperator:
  18960. v, ok := value.(int)
  18961. if !ok {
  18962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18963. }
  18964. m.AddConditionOperator(v)
  18965. return nil
  18966. case sopstage.FieldIndexSort:
  18967. v, ok := value.(int)
  18968. if !ok {
  18969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18970. }
  18971. m.AddIndexSort(v)
  18972. return nil
  18973. }
  18974. return fmt.Errorf("unknown SopStage numeric field %s", name)
  18975. }
  18976. // ClearedFields returns all nullable fields that were cleared during this
  18977. // mutation.
  18978. func (m *SopStageMutation) ClearedFields() []string {
  18979. var fields []string
  18980. if m.FieldCleared(sopstage.FieldStatus) {
  18981. fields = append(fields, sopstage.FieldStatus)
  18982. }
  18983. if m.FieldCleared(sopstage.FieldDeletedAt) {
  18984. fields = append(fields, sopstage.FieldDeletedAt)
  18985. }
  18986. if m.FieldCleared(sopstage.FieldActionMessage) {
  18987. fields = append(fields, sopstage.FieldActionMessage)
  18988. }
  18989. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  18990. fields = append(fields, sopstage.FieldActionLabelAdd)
  18991. }
  18992. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  18993. fields = append(fields, sopstage.FieldActionLabelDel)
  18994. }
  18995. if m.FieldCleared(sopstage.FieldActionForward) {
  18996. fields = append(fields, sopstage.FieldActionForward)
  18997. }
  18998. if m.FieldCleared(sopstage.FieldIndexSort) {
  18999. fields = append(fields, sopstage.FieldIndexSort)
  19000. }
  19001. return fields
  19002. }
  19003. // FieldCleared returns a boolean indicating if a field with the given name was
  19004. // cleared in this mutation.
  19005. func (m *SopStageMutation) FieldCleared(name string) bool {
  19006. _, ok := m.clearedFields[name]
  19007. return ok
  19008. }
  19009. // ClearField clears the value of the field with the given name. It returns an
  19010. // error if the field is not defined in the schema.
  19011. func (m *SopStageMutation) ClearField(name string) error {
  19012. switch name {
  19013. case sopstage.FieldStatus:
  19014. m.ClearStatus()
  19015. return nil
  19016. case sopstage.FieldDeletedAt:
  19017. m.ClearDeletedAt()
  19018. return nil
  19019. case sopstage.FieldActionMessage:
  19020. m.ClearActionMessage()
  19021. return nil
  19022. case sopstage.FieldActionLabelAdd:
  19023. m.ClearActionLabelAdd()
  19024. return nil
  19025. case sopstage.FieldActionLabelDel:
  19026. m.ClearActionLabelDel()
  19027. return nil
  19028. case sopstage.FieldActionForward:
  19029. m.ClearActionForward()
  19030. return nil
  19031. case sopstage.FieldIndexSort:
  19032. m.ClearIndexSort()
  19033. return nil
  19034. }
  19035. return fmt.Errorf("unknown SopStage nullable field %s", name)
  19036. }
  19037. // ResetField resets all changes in the mutation for the field with the given name.
  19038. // It returns an error if the field is not defined in the schema.
  19039. func (m *SopStageMutation) ResetField(name string) error {
  19040. switch name {
  19041. case sopstage.FieldCreatedAt:
  19042. m.ResetCreatedAt()
  19043. return nil
  19044. case sopstage.FieldUpdatedAt:
  19045. m.ResetUpdatedAt()
  19046. return nil
  19047. case sopstage.FieldStatus:
  19048. m.ResetStatus()
  19049. return nil
  19050. case sopstage.FieldDeletedAt:
  19051. m.ResetDeletedAt()
  19052. return nil
  19053. case sopstage.FieldTaskID:
  19054. m.ResetTaskID()
  19055. return nil
  19056. case sopstage.FieldName:
  19057. m.ResetName()
  19058. return nil
  19059. case sopstage.FieldConditionType:
  19060. m.ResetConditionType()
  19061. return nil
  19062. case sopstage.FieldConditionOperator:
  19063. m.ResetConditionOperator()
  19064. return nil
  19065. case sopstage.FieldConditionList:
  19066. m.ResetConditionList()
  19067. return nil
  19068. case sopstage.FieldActionMessage:
  19069. m.ResetActionMessage()
  19070. return nil
  19071. case sopstage.FieldActionLabelAdd:
  19072. m.ResetActionLabelAdd()
  19073. return nil
  19074. case sopstage.FieldActionLabelDel:
  19075. m.ResetActionLabelDel()
  19076. return nil
  19077. case sopstage.FieldActionForward:
  19078. m.ResetActionForward()
  19079. return nil
  19080. case sopstage.FieldIndexSort:
  19081. m.ResetIndexSort()
  19082. return nil
  19083. }
  19084. return fmt.Errorf("unknown SopStage field %s", name)
  19085. }
  19086. // AddedEdges returns all edge names that were set/added in this mutation.
  19087. func (m *SopStageMutation) AddedEdges() []string {
  19088. edges := make([]string, 0, 3)
  19089. if m.sop_task != nil {
  19090. edges = append(edges, sopstage.EdgeSopTask)
  19091. }
  19092. if m.stage_nodes != nil {
  19093. edges = append(edges, sopstage.EdgeStageNodes)
  19094. }
  19095. if m.stage_messages != nil {
  19096. edges = append(edges, sopstage.EdgeStageMessages)
  19097. }
  19098. return edges
  19099. }
  19100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19101. // name in this mutation.
  19102. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  19103. switch name {
  19104. case sopstage.EdgeSopTask:
  19105. if id := m.sop_task; id != nil {
  19106. return []ent.Value{*id}
  19107. }
  19108. case sopstage.EdgeStageNodes:
  19109. ids := make([]ent.Value, 0, len(m.stage_nodes))
  19110. for id := range m.stage_nodes {
  19111. ids = append(ids, id)
  19112. }
  19113. return ids
  19114. case sopstage.EdgeStageMessages:
  19115. ids := make([]ent.Value, 0, len(m.stage_messages))
  19116. for id := range m.stage_messages {
  19117. ids = append(ids, id)
  19118. }
  19119. return ids
  19120. }
  19121. return nil
  19122. }
  19123. // RemovedEdges returns all edge names that were removed in this mutation.
  19124. func (m *SopStageMutation) RemovedEdges() []string {
  19125. edges := make([]string, 0, 3)
  19126. if m.removedstage_nodes != nil {
  19127. edges = append(edges, sopstage.EdgeStageNodes)
  19128. }
  19129. if m.removedstage_messages != nil {
  19130. edges = append(edges, sopstage.EdgeStageMessages)
  19131. }
  19132. return edges
  19133. }
  19134. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19135. // the given name in this mutation.
  19136. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  19137. switch name {
  19138. case sopstage.EdgeStageNodes:
  19139. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  19140. for id := range m.removedstage_nodes {
  19141. ids = append(ids, id)
  19142. }
  19143. return ids
  19144. case sopstage.EdgeStageMessages:
  19145. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  19146. for id := range m.removedstage_messages {
  19147. ids = append(ids, id)
  19148. }
  19149. return ids
  19150. }
  19151. return nil
  19152. }
  19153. // ClearedEdges returns all edge names that were cleared in this mutation.
  19154. func (m *SopStageMutation) ClearedEdges() []string {
  19155. edges := make([]string, 0, 3)
  19156. if m.clearedsop_task {
  19157. edges = append(edges, sopstage.EdgeSopTask)
  19158. }
  19159. if m.clearedstage_nodes {
  19160. edges = append(edges, sopstage.EdgeStageNodes)
  19161. }
  19162. if m.clearedstage_messages {
  19163. edges = append(edges, sopstage.EdgeStageMessages)
  19164. }
  19165. return edges
  19166. }
  19167. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19168. // was cleared in this mutation.
  19169. func (m *SopStageMutation) EdgeCleared(name string) bool {
  19170. switch name {
  19171. case sopstage.EdgeSopTask:
  19172. return m.clearedsop_task
  19173. case sopstage.EdgeStageNodes:
  19174. return m.clearedstage_nodes
  19175. case sopstage.EdgeStageMessages:
  19176. return m.clearedstage_messages
  19177. }
  19178. return false
  19179. }
  19180. // ClearEdge clears the value of the edge with the given name. It returns an error
  19181. // if that edge is not defined in the schema.
  19182. func (m *SopStageMutation) ClearEdge(name string) error {
  19183. switch name {
  19184. case sopstage.EdgeSopTask:
  19185. m.ClearSopTask()
  19186. return nil
  19187. }
  19188. return fmt.Errorf("unknown SopStage unique edge %s", name)
  19189. }
  19190. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19191. // It returns an error if the edge is not defined in the schema.
  19192. func (m *SopStageMutation) ResetEdge(name string) error {
  19193. switch name {
  19194. case sopstage.EdgeSopTask:
  19195. m.ResetSopTask()
  19196. return nil
  19197. case sopstage.EdgeStageNodes:
  19198. m.ResetStageNodes()
  19199. return nil
  19200. case sopstage.EdgeStageMessages:
  19201. m.ResetStageMessages()
  19202. return nil
  19203. }
  19204. return fmt.Errorf("unknown SopStage edge %s", name)
  19205. }
  19206. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  19207. type SopTaskMutation struct {
  19208. config
  19209. op Op
  19210. typ string
  19211. id *uint64
  19212. created_at *time.Time
  19213. updated_at *time.Time
  19214. status *uint8
  19215. addstatus *int8
  19216. deleted_at *time.Time
  19217. name *string
  19218. bot_wxid_list *[]string
  19219. appendbot_wxid_list []string
  19220. _type *int
  19221. add_type *int
  19222. plan_start_time *time.Time
  19223. plan_end_time *time.Time
  19224. creator_id *string
  19225. organization_id *uint64
  19226. addorganization_id *int64
  19227. token *[]string
  19228. appendtoken []string
  19229. clearedFields map[string]struct{}
  19230. task_stages map[uint64]struct{}
  19231. removedtask_stages map[uint64]struct{}
  19232. clearedtask_stages bool
  19233. done bool
  19234. oldValue func(context.Context) (*SopTask, error)
  19235. predicates []predicate.SopTask
  19236. }
  19237. var _ ent.Mutation = (*SopTaskMutation)(nil)
  19238. // soptaskOption allows management of the mutation configuration using functional options.
  19239. type soptaskOption func(*SopTaskMutation)
  19240. // newSopTaskMutation creates new mutation for the SopTask entity.
  19241. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  19242. m := &SopTaskMutation{
  19243. config: c,
  19244. op: op,
  19245. typ: TypeSopTask,
  19246. clearedFields: make(map[string]struct{}),
  19247. }
  19248. for _, opt := range opts {
  19249. opt(m)
  19250. }
  19251. return m
  19252. }
  19253. // withSopTaskID sets the ID field of the mutation.
  19254. func withSopTaskID(id uint64) soptaskOption {
  19255. return func(m *SopTaskMutation) {
  19256. var (
  19257. err error
  19258. once sync.Once
  19259. value *SopTask
  19260. )
  19261. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  19262. once.Do(func() {
  19263. if m.done {
  19264. err = errors.New("querying old values post mutation is not allowed")
  19265. } else {
  19266. value, err = m.Client().SopTask.Get(ctx, id)
  19267. }
  19268. })
  19269. return value, err
  19270. }
  19271. m.id = &id
  19272. }
  19273. }
  19274. // withSopTask sets the old SopTask of the mutation.
  19275. func withSopTask(node *SopTask) soptaskOption {
  19276. return func(m *SopTaskMutation) {
  19277. m.oldValue = func(context.Context) (*SopTask, error) {
  19278. return node, nil
  19279. }
  19280. m.id = &node.ID
  19281. }
  19282. }
  19283. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19284. // executed in a transaction (ent.Tx), a transactional client is returned.
  19285. func (m SopTaskMutation) Client() *Client {
  19286. client := &Client{config: m.config}
  19287. client.init()
  19288. return client
  19289. }
  19290. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19291. // it returns an error otherwise.
  19292. func (m SopTaskMutation) Tx() (*Tx, error) {
  19293. if _, ok := m.driver.(*txDriver); !ok {
  19294. return nil, errors.New("ent: mutation is not running in a transaction")
  19295. }
  19296. tx := &Tx{config: m.config}
  19297. tx.init()
  19298. return tx, nil
  19299. }
  19300. // SetID sets the value of the id field. Note that this
  19301. // operation is only accepted on creation of SopTask entities.
  19302. func (m *SopTaskMutation) SetID(id uint64) {
  19303. m.id = &id
  19304. }
  19305. // ID returns the ID value in the mutation. Note that the ID is only available
  19306. // if it was provided to the builder or after it was returned from the database.
  19307. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  19308. if m.id == nil {
  19309. return
  19310. }
  19311. return *m.id, true
  19312. }
  19313. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19314. // That means, if the mutation is applied within a transaction with an isolation level such
  19315. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19316. // or updated by the mutation.
  19317. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  19318. switch {
  19319. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19320. id, exists := m.ID()
  19321. if exists {
  19322. return []uint64{id}, nil
  19323. }
  19324. fallthrough
  19325. case m.op.Is(OpUpdate | OpDelete):
  19326. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  19327. default:
  19328. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19329. }
  19330. }
  19331. // SetCreatedAt sets the "created_at" field.
  19332. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  19333. m.created_at = &t
  19334. }
  19335. // CreatedAt returns the value of the "created_at" field in the mutation.
  19336. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  19337. v := m.created_at
  19338. if v == nil {
  19339. return
  19340. }
  19341. return *v, true
  19342. }
  19343. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  19344. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19346. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19347. if !m.op.Is(OpUpdateOne) {
  19348. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19349. }
  19350. if m.id == nil || m.oldValue == nil {
  19351. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19352. }
  19353. oldValue, err := m.oldValue(ctx)
  19354. if err != nil {
  19355. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19356. }
  19357. return oldValue.CreatedAt, nil
  19358. }
  19359. // ResetCreatedAt resets all changes to the "created_at" field.
  19360. func (m *SopTaskMutation) ResetCreatedAt() {
  19361. m.created_at = nil
  19362. }
  19363. // SetUpdatedAt sets the "updated_at" field.
  19364. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  19365. m.updated_at = &t
  19366. }
  19367. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19368. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  19369. v := m.updated_at
  19370. if v == nil {
  19371. return
  19372. }
  19373. return *v, true
  19374. }
  19375. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  19376. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19378. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19379. if !m.op.Is(OpUpdateOne) {
  19380. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19381. }
  19382. if m.id == nil || m.oldValue == nil {
  19383. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19384. }
  19385. oldValue, err := m.oldValue(ctx)
  19386. if err != nil {
  19387. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19388. }
  19389. return oldValue.UpdatedAt, nil
  19390. }
  19391. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19392. func (m *SopTaskMutation) ResetUpdatedAt() {
  19393. m.updated_at = nil
  19394. }
  19395. // SetStatus sets the "status" field.
  19396. func (m *SopTaskMutation) SetStatus(u uint8) {
  19397. m.status = &u
  19398. m.addstatus = nil
  19399. }
  19400. // Status returns the value of the "status" field in the mutation.
  19401. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  19402. v := m.status
  19403. if v == nil {
  19404. return
  19405. }
  19406. return *v, true
  19407. }
  19408. // OldStatus returns the old "status" field's value of the SopTask entity.
  19409. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19411. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19412. if !m.op.Is(OpUpdateOne) {
  19413. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19414. }
  19415. if m.id == nil || m.oldValue == nil {
  19416. return v, errors.New("OldStatus requires an ID field in the mutation")
  19417. }
  19418. oldValue, err := m.oldValue(ctx)
  19419. if err != nil {
  19420. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19421. }
  19422. return oldValue.Status, nil
  19423. }
  19424. // AddStatus adds u to the "status" field.
  19425. func (m *SopTaskMutation) AddStatus(u int8) {
  19426. if m.addstatus != nil {
  19427. *m.addstatus += u
  19428. } else {
  19429. m.addstatus = &u
  19430. }
  19431. }
  19432. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19433. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  19434. v := m.addstatus
  19435. if v == nil {
  19436. return
  19437. }
  19438. return *v, true
  19439. }
  19440. // ClearStatus clears the value of the "status" field.
  19441. func (m *SopTaskMutation) ClearStatus() {
  19442. m.status = nil
  19443. m.addstatus = nil
  19444. m.clearedFields[soptask.FieldStatus] = struct{}{}
  19445. }
  19446. // StatusCleared returns if the "status" field was cleared in this mutation.
  19447. func (m *SopTaskMutation) StatusCleared() bool {
  19448. _, ok := m.clearedFields[soptask.FieldStatus]
  19449. return ok
  19450. }
  19451. // ResetStatus resets all changes to the "status" field.
  19452. func (m *SopTaskMutation) ResetStatus() {
  19453. m.status = nil
  19454. m.addstatus = nil
  19455. delete(m.clearedFields, soptask.FieldStatus)
  19456. }
  19457. // SetDeletedAt sets the "deleted_at" field.
  19458. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  19459. m.deleted_at = &t
  19460. }
  19461. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19462. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  19463. v := m.deleted_at
  19464. if v == nil {
  19465. return
  19466. }
  19467. return *v, true
  19468. }
  19469. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  19470. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19472. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19473. if !m.op.Is(OpUpdateOne) {
  19474. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19475. }
  19476. if m.id == nil || m.oldValue == nil {
  19477. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19478. }
  19479. oldValue, err := m.oldValue(ctx)
  19480. if err != nil {
  19481. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19482. }
  19483. return oldValue.DeletedAt, nil
  19484. }
  19485. // ClearDeletedAt clears the value of the "deleted_at" field.
  19486. func (m *SopTaskMutation) ClearDeletedAt() {
  19487. m.deleted_at = nil
  19488. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  19489. }
  19490. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19491. func (m *SopTaskMutation) DeletedAtCleared() bool {
  19492. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  19493. return ok
  19494. }
  19495. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19496. func (m *SopTaskMutation) ResetDeletedAt() {
  19497. m.deleted_at = nil
  19498. delete(m.clearedFields, soptask.FieldDeletedAt)
  19499. }
  19500. // SetName sets the "name" field.
  19501. func (m *SopTaskMutation) SetName(s string) {
  19502. m.name = &s
  19503. }
  19504. // Name returns the value of the "name" field in the mutation.
  19505. func (m *SopTaskMutation) Name() (r string, exists bool) {
  19506. v := m.name
  19507. if v == nil {
  19508. return
  19509. }
  19510. return *v, true
  19511. }
  19512. // OldName returns the old "name" field's value of the SopTask entity.
  19513. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19515. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  19516. if !m.op.Is(OpUpdateOne) {
  19517. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19518. }
  19519. if m.id == nil || m.oldValue == nil {
  19520. return v, errors.New("OldName requires an ID field in the mutation")
  19521. }
  19522. oldValue, err := m.oldValue(ctx)
  19523. if err != nil {
  19524. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19525. }
  19526. return oldValue.Name, nil
  19527. }
  19528. // ResetName resets all changes to the "name" field.
  19529. func (m *SopTaskMutation) ResetName() {
  19530. m.name = nil
  19531. }
  19532. // SetBotWxidList sets the "bot_wxid_list" field.
  19533. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  19534. m.bot_wxid_list = &s
  19535. m.appendbot_wxid_list = nil
  19536. }
  19537. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  19538. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  19539. v := m.bot_wxid_list
  19540. if v == nil {
  19541. return
  19542. }
  19543. return *v, true
  19544. }
  19545. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  19546. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19548. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  19549. if !m.op.Is(OpUpdateOne) {
  19550. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  19551. }
  19552. if m.id == nil || m.oldValue == nil {
  19553. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  19554. }
  19555. oldValue, err := m.oldValue(ctx)
  19556. if err != nil {
  19557. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  19558. }
  19559. return oldValue.BotWxidList, nil
  19560. }
  19561. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  19562. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  19563. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  19564. }
  19565. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  19566. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  19567. if len(m.appendbot_wxid_list) == 0 {
  19568. return nil, false
  19569. }
  19570. return m.appendbot_wxid_list, true
  19571. }
  19572. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  19573. func (m *SopTaskMutation) ClearBotWxidList() {
  19574. m.bot_wxid_list = nil
  19575. m.appendbot_wxid_list = nil
  19576. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  19577. }
  19578. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  19579. func (m *SopTaskMutation) BotWxidListCleared() bool {
  19580. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  19581. return ok
  19582. }
  19583. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  19584. func (m *SopTaskMutation) ResetBotWxidList() {
  19585. m.bot_wxid_list = nil
  19586. m.appendbot_wxid_list = nil
  19587. delete(m.clearedFields, soptask.FieldBotWxidList)
  19588. }
  19589. // SetType sets the "type" field.
  19590. func (m *SopTaskMutation) SetType(i int) {
  19591. m._type = &i
  19592. m.add_type = nil
  19593. }
  19594. // GetType returns the value of the "type" field in the mutation.
  19595. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  19596. v := m._type
  19597. if v == nil {
  19598. return
  19599. }
  19600. return *v, true
  19601. }
  19602. // OldType returns the old "type" field's value of the SopTask entity.
  19603. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19605. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  19606. if !m.op.Is(OpUpdateOne) {
  19607. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19608. }
  19609. if m.id == nil || m.oldValue == nil {
  19610. return v, errors.New("OldType requires an ID field in the mutation")
  19611. }
  19612. oldValue, err := m.oldValue(ctx)
  19613. if err != nil {
  19614. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19615. }
  19616. return oldValue.Type, nil
  19617. }
  19618. // AddType adds i to the "type" field.
  19619. func (m *SopTaskMutation) AddType(i int) {
  19620. if m.add_type != nil {
  19621. *m.add_type += i
  19622. } else {
  19623. m.add_type = &i
  19624. }
  19625. }
  19626. // AddedType returns the value that was added to the "type" field in this mutation.
  19627. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  19628. v := m.add_type
  19629. if v == nil {
  19630. return
  19631. }
  19632. return *v, true
  19633. }
  19634. // ResetType resets all changes to the "type" field.
  19635. func (m *SopTaskMutation) ResetType() {
  19636. m._type = nil
  19637. m.add_type = nil
  19638. }
  19639. // SetPlanStartTime sets the "plan_start_time" field.
  19640. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  19641. m.plan_start_time = &t
  19642. }
  19643. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  19644. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  19645. v := m.plan_start_time
  19646. if v == nil {
  19647. return
  19648. }
  19649. return *v, true
  19650. }
  19651. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  19652. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19654. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  19655. if !m.op.Is(OpUpdateOne) {
  19656. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  19657. }
  19658. if m.id == nil || m.oldValue == nil {
  19659. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  19660. }
  19661. oldValue, err := m.oldValue(ctx)
  19662. if err != nil {
  19663. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  19664. }
  19665. return oldValue.PlanStartTime, nil
  19666. }
  19667. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  19668. func (m *SopTaskMutation) ClearPlanStartTime() {
  19669. m.plan_start_time = nil
  19670. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  19671. }
  19672. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  19673. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  19674. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  19675. return ok
  19676. }
  19677. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  19678. func (m *SopTaskMutation) ResetPlanStartTime() {
  19679. m.plan_start_time = nil
  19680. delete(m.clearedFields, soptask.FieldPlanStartTime)
  19681. }
  19682. // SetPlanEndTime sets the "plan_end_time" field.
  19683. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  19684. m.plan_end_time = &t
  19685. }
  19686. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  19687. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  19688. v := m.plan_end_time
  19689. if v == nil {
  19690. return
  19691. }
  19692. return *v, true
  19693. }
  19694. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  19695. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19697. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  19698. if !m.op.Is(OpUpdateOne) {
  19699. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  19700. }
  19701. if m.id == nil || m.oldValue == nil {
  19702. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  19703. }
  19704. oldValue, err := m.oldValue(ctx)
  19705. if err != nil {
  19706. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  19707. }
  19708. return oldValue.PlanEndTime, nil
  19709. }
  19710. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  19711. func (m *SopTaskMutation) ClearPlanEndTime() {
  19712. m.plan_end_time = nil
  19713. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  19714. }
  19715. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  19716. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  19717. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  19718. return ok
  19719. }
  19720. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  19721. func (m *SopTaskMutation) ResetPlanEndTime() {
  19722. m.plan_end_time = nil
  19723. delete(m.clearedFields, soptask.FieldPlanEndTime)
  19724. }
  19725. // SetCreatorID sets the "creator_id" field.
  19726. func (m *SopTaskMutation) SetCreatorID(s string) {
  19727. m.creator_id = &s
  19728. }
  19729. // CreatorID returns the value of the "creator_id" field in the mutation.
  19730. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  19731. v := m.creator_id
  19732. if v == nil {
  19733. return
  19734. }
  19735. return *v, true
  19736. }
  19737. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  19738. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19740. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  19741. if !m.op.Is(OpUpdateOne) {
  19742. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  19743. }
  19744. if m.id == nil || m.oldValue == nil {
  19745. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  19746. }
  19747. oldValue, err := m.oldValue(ctx)
  19748. if err != nil {
  19749. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  19750. }
  19751. return oldValue.CreatorID, nil
  19752. }
  19753. // ClearCreatorID clears the value of the "creator_id" field.
  19754. func (m *SopTaskMutation) ClearCreatorID() {
  19755. m.creator_id = nil
  19756. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  19757. }
  19758. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  19759. func (m *SopTaskMutation) CreatorIDCleared() bool {
  19760. _, ok := m.clearedFields[soptask.FieldCreatorID]
  19761. return ok
  19762. }
  19763. // ResetCreatorID resets all changes to the "creator_id" field.
  19764. func (m *SopTaskMutation) ResetCreatorID() {
  19765. m.creator_id = nil
  19766. delete(m.clearedFields, soptask.FieldCreatorID)
  19767. }
  19768. // SetOrganizationID sets the "organization_id" field.
  19769. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  19770. m.organization_id = &u
  19771. m.addorganization_id = nil
  19772. }
  19773. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19774. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  19775. v := m.organization_id
  19776. if v == nil {
  19777. return
  19778. }
  19779. return *v, true
  19780. }
  19781. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  19782. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19784. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19785. if !m.op.Is(OpUpdateOne) {
  19786. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19787. }
  19788. if m.id == nil || m.oldValue == nil {
  19789. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19790. }
  19791. oldValue, err := m.oldValue(ctx)
  19792. if err != nil {
  19793. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19794. }
  19795. return oldValue.OrganizationID, nil
  19796. }
  19797. // AddOrganizationID adds u to the "organization_id" field.
  19798. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  19799. if m.addorganization_id != nil {
  19800. *m.addorganization_id += u
  19801. } else {
  19802. m.addorganization_id = &u
  19803. }
  19804. }
  19805. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19806. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  19807. v := m.addorganization_id
  19808. if v == nil {
  19809. return
  19810. }
  19811. return *v, true
  19812. }
  19813. // ClearOrganizationID clears the value of the "organization_id" field.
  19814. func (m *SopTaskMutation) ClearOrganizationID() {
  19815. m.organization_id = nil
  19816. m.addorganization_id = nil
  19817. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  19818. }
  19819. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19820. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  19821. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  19822. return ok
  19823. }
  19824. // ResetOrganizationID resets all changes to the "organization_id" field.
  19825. func (m *SopTaskMutation) ResetOrganizationID() {
  19826. m.organization_id = nil
  19827. m.addorganization_id = nil
  19828. delete(m.clearedFields, soptask.FieldOrganizationID)
  19829. }
  19830. // SetToken sets the "token" field.
  19831. func (m *SopTaskMutation) SetToken(s []string) {
  19832. m.token = &s
  19833. m.appendtoken = nil
  19834. }
  19835. // Token returns the value of the "token" field in the mutation.
  19836. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  19837. v := m.token
  19838. if v == nil {
  19839. return
  19840. }
  19841. return *v, true
  19842. }
  19843. // OldToken returns the old "token" field's value of the SopTask entity.
  19844. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19846. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  19847. if !m.op.Is(OpUpdateOne) {
  19848. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  19849. }
  19850. if m.id == nil || m.oldValue == nil {
  19851. return v, errors.New("OldToken requires an ID field in the mutation")
  19852. }
  19853. oldValue, err := m.oldValue(ctx)
  19854. if err != nil {
  19855. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  19856. }
  19857. return oldValue.Token, nil
  19858. }
  19859. // AppendToken adds s to the "token" field.
  19860. func (m *SopTaskMutation) AppendToken(s []string) {
  19861. m.appendtoken = append(m.appendtoken, s...)
  19862. }
  19863. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  19864. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  19865. if len(m.appendtoken) == 0 {
  19866. return nil, false
  19867. }
  19868. return m.appendtoken, true
  19869. }
  19870. // ClearToken clears the value of the "token" field.
  19871. func (m *SopTaskMutation) ClearToken() {
  19872. m.token = nil
  19873. m.appendtoken = nil
  19874. m.clearedFields[soptask.FieldToken] = struct{}{}
  19875. }
  19876. // TokenCleared returns if the "token" field was cleared in this mutation.
  19877. func (m *SopTaskMutation) TokenCleared() bool {
  19878. _, ok := m.clearedFields[soptask.FieldToken]
  19879. return ok
  19880. }
  19881. // ResetToken resets all changes to the "token" field.
  19882. func (m *SopTaskMutation) ResetToken() {
  19883. m.token = nil
  19884. m.appendtoken = nil
  19885. delete(m.clearedFields, soptask.FieldToken)
  19886. }
  19887. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  19888. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  19889. if m.task_stages == nil {
  19890. m.task_stages = make(map[uint64]struct{})
  19891. }
  19892. for i := range ids {
  19893. m.task_stages[ids[i]] = struct{}{}
  19894. }
  19895. }
  19896. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  19897. func (m *SopTaskMutation) ClearTaskStages() {
  19898. m.clearedtask_stages = true
  19899. }
  19900. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  19901. func (m *SopTaskMutation) TaskStagesCleared() bool {
  19902. return m.clearedtask_stages
  19903. }
  19904. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  19905. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  19906. if m.removedtask_stages == nil {
  19907. m.removedtask_stages = make(map[uint64]struct{})
  19908. }
  19909. for i := range ids {
  19910. delete(m.task_stages, ids[i])
  19911. m.removedtask_stages[ids[i]] = struct{}{}
  19912. }
  19913. }
  19914. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  19915. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  19916. for id := range m.removedtask_stages {
  19917. ids = append(ids, id)
  19918. }
  19919. return
  19920. }
  19921. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  19922. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  19923. for id := range m.task_stages {
  19924. ids = append(ids, id)
  19925. }
  19926. return
  19927. }
  19928. // ResetTaskStages resets all changes to the "task_stages" edge.
  19929. func (m *SopTaskMutation) ResetTaskStages() {
  19930. m.task_stages = nil
  19931. m.clearedtask_stages = false
  19932. m.removedtask_stages = nil
  19933. }
  19934. // Where appends a list predicates to the SopTaskMutation builder.
  19935. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  19936. m.predicates = append(m.predicates, ps...)
  19937. }
  19938. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  19939. // users can use type-assertion to append predicates that do not depend on any generated package.
  19940. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  19941. p := make([]predicate.SopTask, len(ps))
  19942. for i := range ps {
  19943. p[i] = ps[i]
  19944. }
  19945. m.Where(p...)
  19946. }
  19947. // Op returns the operation name.
  19948. func (m *SopTaskMutation) Op() Op {
  19949. return m.op
  19950. }
  19951. // SetOp allows setting the mutation operation.
  19952. func (m *SopTaskMutation) SetOp(op Op) {
  19953. m.op = op
  19954. }
  19955. // Type returns the node type of this mutation (SopTask).
  19956. func (m *SopTaskMutation) Type() string {
  19957. return m.typ
  19958. }
  19959. // Fields returns all fields that were changed during this mutation. Note that in
  19960. // order to get all numeric fields that were incremented/decremented, call
  19961. // AddedFields().
  19962. func (m *SopTaskMutation) Fields() []string {
  19963. fields := make([]string, 0, 12)
  19964. if m.created_at != nil {
  19965. fields = append(fields, soptask.FieldCreatedAt)
  19966. }
  19967. if m.updated_at != nil {
  19968. fields = append(fields, soptask.FieldUpdatedAt)
  19969. }
  19970. if m.status != nil {
  19971. fields = append(fields, soptask.FieldStatus)
  19972. }
  19973. if m.deleted_at != nil {
  19974. fields = append(fields, soptask.FieldDeletedAt)
  19975. }
  19976. if m.name != nil {
  19977. fields = append(fields, soptask.FieldName)
  19978. }
  19979. if m.bot_wxid_list != nil {
  19980. fields = append(fields, soptask.FieldBotWxidList)
  19981. }
  19982. if m._type != nil {
  19983. fields = append(fields, soptask.FieldType)
  19984. }
  19985. if m.plan_start_time != nil {
  19986. fields = append(fields, soptask.FieldPlanStartTime)
  19987. }
  19988. if m.plan_end_time != nil {
  19989. fields = append(fields, soptask.FieldPlanEndTime)
  19990. }
  19991. if m.creator_id != nil {
  19992. fields = append(fields, soptask.FieldCreatorID)
  19993. }
  19994. if m.organization_id != nil {
  19995. fields = append(fields, soptask.FieldOrganizationID)
  19996. }
  19997. if m.token != nil {
  19998. fields = append(fields, soptask.FieldToken)
  19999. }
  20000. return fields
  20001. }
  20002. // Field returns the value of a field with the given name. The second boolean
  20003. // return value indicates that this field was not set, or was not defined in the
  20004. // schema.
  20005. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  20006. switch name {
  20007. case soptask.FieldCreatedAt:
  20008. return m.CreatedAt()
  20009. case soptask.FieldUpdatedAt:
  20010. return m.UpdatedAt()
  20011. case soptask.FieldStatus:
  20012. return m.Status()
  20013. case soptask.FieldDeletedAt:
  20014. return m.DeletedAt()
  20015. case soptask.FieldName:
  20016. return m.Name()
  20017. case soptask.FieldBotWxidList:
  20018. return m.BotWxidList()
  20019. case soptask.FieldType:
  20020. return m.GetType()
  20021. case soptask.FieldPlanStartTime:
  20022. return m.PlanStartTime()
  20023. case soptask.FieldPlanEndTime:
  20024. return m.PlanEndTime()
  20025. case soptask.FieldCreatorID:
  20026. return m.CreatorID()
  20027. case soptask.FieldOrganizationID:
  20028. return m.OrganizationID()
  20029. case soptask.FieldToken:
  20030. return m.Token()
  20031. }
  20032. return nil, false
  20033. }
  20034. // OldField returns the old value of the field from the database. An error is
  20035. // returned if the mutation operation is not UpdateOne, or the query to the
  20036. // database failed.
  20037. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20038. switch name {
  20039. case soptask.FieldCreatedAt:
  20040. return m.OldCreatedAt(ctx)
  20041. case soptask.FieldUpdatedAt:
  20042. return m.OldUpdatedAt(ctx)
  20043. case soptask.FieldStatus:
  20044. return m.OldStatus(ctx)
  20045. case soptask.FieldDeletedAt:
  20046. return m.OldDeletedAt(ctx)
  20047. case soptask.FieldName:
  20048. return m.OldName(ctx)
  20049. case soptask.FieldBotWxidList:
  20050. return m.OldBotWxidList(ctx)
  20051. case soptask.FieldType:
  20052. return m.OldType(ctx)
  20053. case soptask.FieldPlanStartTime:
  20054. return m.OldPlanStartTime(ctx)
  20055. case soptask.FieldPlanEndTime:
  20056. return m.OldPlanEndTime(ctx)
  20057. case soptask.FieldCreatorID:
  20058. return m.OldCreatorID(ctx)
  20059. case soptask.FieldOrganizationID:
  20060. return m.OldOrganizationID(ctx)
  20061. case soptask.FieldToken:
  20062. return m.OldToken(ctx)
  20063. }
  20064. return nil, fmt.Errorf("unknown SopTask field %s", name)
  20065. }
  20066. // SetField sets the value of a field with the given name. It returns an error if
  20067. // the field is not defined in the schema, or if the type mismatched the field
  20068. // type.
  20069. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  20070. switch name {
  20071. case soptask.FieldCreatedAt:
  20072. v, ok := value.(time.Time)
  20073. if !ok {
  20074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20075. }
  20076. m.SetCreatedAt(v)
  20077. return nil
  20078. case soptask.FieldUpdatedAt:
  20079. v, ok := value.(time.Time)
  20080. if !ok {
  20081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20082. }
  20083. m.SetUpdatedAt(v)
  20084. return nil
  20085. case soptask.FieldStatus:
  20086. v, ok := value.(uint8)
  20087. if !ok {
  20088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20089. }
  20090. m.SetStatus(v)
  20091. return nil
  20092. case soptask.FieldDeletedAt:
  20093. v, ok := value.(time.Time)
  20094. if !ok {
  20095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20096. }
  20097. m.SetDeletedAt(v)
  20098. return nil
  20099. case soptask.FieldName:
  20100. v, ok := value.(string)
  20101. if !ok {
  20102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20103. }
  20104. m.SetName(v)
  20105. return nil
  20106. case soptask.FieldBotWxidList:
  20107. v, ok := value.([]string)
  20108. if !ok {
  20109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20110. }
  20111. m.SetBotWxidList(v)
  20112. return nil
  20113. case soptask.FieldType:
  20114. v, ok := value.(int)
  20115. if !ok {
  20116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20117. }
  20118. m.SetType(v)
  20119. return nil
  20120. case soptask.FieldPlanStartTime:
  20121. v, ok := value.(time.Time)
  20122. if !ok {
  20123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20124. }
  20125. m.SetPlanStartTime(v)
  20126. return nil
  20127. case soptask.FieldPlanEndTime:
  20128. v, ok := value.(time.Time)
  20129. if !ok {
  20130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20131. }
  20132. m.SetPlanEndTime(v)
  20133. return nil
  20134. case soptask.FieldCreatorID:
  20135. v, ok := value.(string)
  20136. if !ok {
  20137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20138. }
  20139. m.SetCreatorID(v)
  20140. return nil
  20141. case soptask.FieldOrganizationID:
  20142. v, ok := value.(uint64)
  20143. if !ok {
  20144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20145. }
  20146. m.SetOrganizationID(v)
  20147. return nil
  20148. case soptask.FieldToken:
  20149. v, ok := value.([]string)
  20150. if !ok {
  20151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20152. }
  20153. m.SetToken(v)
  20154. return nil
  20155. }
  20156. return fmt.Errorf("unknown SopTask field %s", name)
  20157. }
  20158. // AddedFields returns all numeric fields that were incremented/decremented during
  20159. // this mutation.
  20160. func (m *SopTaskMutation) AddedFields() []string {
  20161. var fields []string
  20162. if m.addstatus != nil {
  20163. fields = append(fields, soptask.FieldStatus)
  20164. }
  20165. if m.add_type != nil {
  20166. fields = append(fields, soptask.FieldType)
  20167. }
  20168. if m.addorganization_id != nil {
  20169. fields = append(fields, soptask.FieldOrganizationID)
  20170. }
  20171. return fields
  20172. }
  20173. // AddedField returns the numeric value that was incremented/decremented on a field
  20174. // with the given name. The second boolean return value indicates that this field
  20175. // was not set, or was not defined in the schema.
  20176. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  20177. switch name {
  20178. case soptask.FieldStatus:
  20179. return m.AddedStatus()
  20180. case soptask.FieldType:
  20181. return m.AddedType()
  20182. case soptask.FieldOrganizationID:
  20183. return m.AddedOrganizationID()
  20184. }
  20185. return nil, false
  20186. }
  20187. // AddField adds the value to the field with the given name. It returns an error if
  20188. // the field is not defined in the schema, or if the type mismatched the field
  20189. // type.
  20190. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  20191. switch name {
  20192. case soptask.FieldStatus:
  20193. v, ok := value.(int8)
  20194. if !ok {
  20195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20196. }
  20197. m.AddStatus(v)
  20198. return nil
  20199. case soptask.FieldType:
  20200. v, ok := value.(int)
  20201. if !ok {
  20202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20203. }
  20204. m.AddType(v)
  20205. return nil
  20206. case soptask.FieldOrganizationID:
  20207. v, ok := value.(int64)
  20208. if !ok {
  20209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20210. }
  20211. m.AddOrganizationID(v)
  20212. return nil
  20213. }
  20214. return fmt.Errorf("unknown SopTask numeric field %s", name)
  20215. }
  20216. // ClearedFields returns all nullable fields that were cleared during this
  20217. // mutation.
  20218. func (m *SopTaskMutation) ClearedFields() []string {
  20219. var fields []string
  20220. if m.FieldCleared(soptask.FieldStatus) {
  20221. fields = append(fields, soptask.FieldStatus)
  20222. }
  20223. if m.FieldCleared(soptask.FieldDeletedAt) {
  20224. fields = append(fields, soptask.FieldDeletedAt)
  20225. }
  20226. if m.FieldCleared(soptask.FieldBotWxidList) {
  20227. fields = append(fields, soptask.FieldBotWxidList)
  20228. }
  20229. if m.FieldCleared(soptask.FieldPlanStartTime) {
  20230. fields = append(fields, soptask.FieldPlanStartTime)
  20231. }
  20232. if m.FieldCleared(soptask.FieldPlanEndTime) {
  20233. fields = append(fields, soptask.FieldPlanEndTime)
  20234. }
  20235. if m.FieldCleared(soptask.FieldCreatorID) {
  20236. fields = append(fields, soptask.FieldCreatorID)
  20237. }
  20238. if m.FieldCleared(soptask.FieldOrganizationID) {
  20239. fields = append(fields, soptask.FieldOrganizationID)
  20240. }
  20241. if m.FieldCleared(soptask.FieldToken) {
  20242. fields = append(fields, soptask.FieldToken)
  20243. }
  20244. return fields
  20245. }
  20246. // FieldCleared returns a boolean indicating if a field with the given name was
  20247. // cleared in this mutation.
  20248. func (m *SopTaskMutation) FieldCleared(name string) bool {
  20249. _, ok := m.clearedFields[name]
  20250. return ok
  20251. }
  20252. // ClearField clears the value of the field with the given name. It returns an
  20253. // error if the field is not defined in the schema.
  20254. func (m *SopTaskMutation) ClearField(name string) error {
  20255. switch name {
  20256. case soptask.FieldStatus:
  20257. m.ClearStatus()
  20258. return nil
  20259. case soptask.FieldDeletedAt:
  20260. m.ClearDeletedAt()
  20261. return nil
  20262. case soptask.FieldBotWxidList:
  20263. m.ClearBotWxidList()
  20264. return nil
  20265. case soptask.FieldPlanStartTime:
  20266. m.ClearPlanStartTime()
  20267. return nil
  20268. case soptask.FieldPlanEndTime:
  20269. m.ClearPlanEndTime()
  20270. return nil
  20271. case soptask.FieldCreatorID:
  20272. m.ClearCreatorID()
  20273. return nil
  20274. case soptask.FieldOrganizationID:
  20275. m.ClearOrganizationID()
  20276. return nil
  20277. case soptask.FieldToken:
  20278. m.ClearToken()
  20279. return nil
  20280. }
  20281. return fmt.Errorf("unknown SopTask nullable field %s", name)
  20282. }
  20283. // ResetField resets all changes in the mutation for the field with the given name.
  20284. // It returns an error if the field is not defined in the schema.
  20285. func (m *SopTaskMutation) ResetField(name string) error {
  20286. switch name {
  20287. case soptask.FieldCreatedAt:
  20288. m.ResetCreatedAt()
  20289. return nil
  20290. case soptask.FieldUpdatedAt:
  20291. m.ResetUpdatedAt()
  20292. return nil
  20293. case soptask.FieldStatus:
  20294. m.ResetStatus()
  20295. return nil
  20296. case soptask.FieldDeletedAt:
  20297. m.ResetDeletedAt()
  20298. return nil
  20299. case soptask.FieldName:
  20300. m.ResetName()
  20301. return nil
  20302. case soptask.FieldBotWxidList:
  20303. m.ResetBotWxidList()
  20304. return nil
  20305. case soptask.FieldType:
  20306. m.ResetType()
  20307. return nil
  20308. case soptask.FieldPlanStartTime:
  20309. m.ResetPlanStartTime()
  20310. return nil
  20311. case soptask.FieldPlanEndTime:
  20312. m.ResetPlanEndTime()
  20313. return nil
  20314. case soptask.FieldCreatorID:
  20315. m.ResetCreatorID()
  20316. return nil
  20317. case soptask.FieldOrganizationID:
  20318. m.ResetOrganizationID()
  20319. return nil
  20320. case soptask.FieldToken:
  20321. m.ResetToken()
  20322. return nil
  20323. }
  20324. return fmt.Errorf("unknown SopTask field %s", name)
  20325. }
  20326. // AddedEdges returns all edge names that were set/added in this mutation.
  20327. func (m *SopTaskMutation) AddedEdges() []string {
  20328. edges := make([]string, 0, 1)
  20329. if m.task_stages != nil {
  20330. edges = append(edges, soptask.EdgeTaskStages)
  20331. }
  20332. return edges
  20333. }
  20334. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20335. // name in this mutation.
  20336. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  20337. switch name {
  20338. case soptask.EdgeTaskStages:
  20339. ids := make([]ent.Value, 0, len(m.task_stages))
  20340. for id := range m.task_stages {
  20341. ids = append(ids, id)
  20342. }
  20343. return ids
  20344. }
  20345. return nil
  20346. }
  20347. // RemovedEdges returns all edge names that were removed in this mutation.
  20348. func (m *SopTaskMutation) RemovedEdges() []string {
  20349. edges := make([]string, 0, 1)
  20350. if m.removedtask_stages != nil {
  20351. edges = append(edges, soptask.EdgeTaskStages)
  20352. }
  20353. return edges
  20354. }
  20355. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20356. // the given name in this mutation.
  20357. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  20358. switch name {
  20359. case soptask.EdgeTaskStages:
  20360. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  20361. for id := range m.removedtask_stages {
  20362. ids = append(ids, id)
  20363. }
  20364. return ids
  20365. }
  20366. return nil
  20367. }
  20368. // ClearedEdges returns all edge names that were cleared in this mutation.
  20369. func (m *SopTaskMutation) ClearedEdges() []string {
  20370. edges := make([]string, 0, 1)
  20371. if m.clearedtask_stages {
  20372. edges = append(edges, soptask.EdgeTaskStages)
  20373. }
  20374. return edges
  20375. }
  20376. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20377. // was cleared in this mutation.
  20378. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  20379. switch name {
  20380. case soptask.EdgeTaskStages:
  20381. return m.clearedtask_stages
  20382. }
  20383. return false
  20384. }
  20385. // ClearEdge clears the value of the edge with the given name. It returns an error
  20386. // if that edge is not defined in the schema.
  20387. func (m *SopTaskMutation) ClearEdge(name string) error {
  20388. switch name {
  20389. }
  20390. return fmt.Errorf("unknown SopTask unique edge %s", name)
  20391. }
  20392. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20393. // It returns an error if the edge is not defined in the schema.
  20394. func (m *SopTaskMutation) ResetEdge(name string) error {
  20395. switch name {
  20396. case soptask.EdgeTaskStages:
  20397. m.ResetTaskStages()
  20398. return nil
  20399. }
  20400. return fmt.Errorf("unknown SopTask edge %s", name)
  20401. }
  20402. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  20403. type TokenMutation struct {
  20404. config
  20405. op Op
  20406. typ string
  20407. id *uint64
  20408. created_at *time.Time
  20409. updated_at *time.Time
  20410. deleted_at *time.Time
  20411. expire_at *time.Time
  20412. token *string
  20413. mac *string
  20414. organization_id *uint64
  20415. addorganization_id *int64
  20416. custom_agent_base *string
  20417. custom_agent_key *string
  20418. openai_base *string
  20419. openai_key *string
  20420. clearedFields map[string]struct{}
  20421. agent *uint64
  20422. clearedagent bool
  20423. done bool
  20424. oldValue func(context.Context) (*Token, error)
  20425. predicates []predicate.Token
  20426. }
  20427. var _ ent.Mutation = (*TokenMutation)(nil)
  20428. // tokenOption allows management of the mutation configuration using functional options.
  20429. type tokenOption func(*TokenMutation)
  20430. // newTokenMutation creates new mutation for the Token entity.
  20431. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  20432. m := &TokenMutation{
  20433. config: c,
  20434. op: op,
  20435. typ: TypeToken,
  20436. clearedFields: make(map[string]struct{}),
  20437. }
  20438. for _, opt := range opts {
  20439. opt(m)
  20440. }
  20441. return m
  20442. }
  20443. // withTokenID sets the ID field of the mutation.
  20444. func withTokenID(id uint64) tokenOption {
  20445. return func(m *TokenMutation) {
  20446. var (
  20447. err error
  20448. once sync.Once
  20449. value *Token
  20450. )
  20451. m.oldValue = func(ctx context.Context) (*Token, error) {
  20452. once.Do(func() {
  20453. if m.done {
  20454. err = errors.New("querying old values post mutation is not allowed")
  20455. } else {
  20456. value, err = m.Client().Token.Get(ctx, id)
  20457. }
  20458. })
  20459. return value, err
  20460. }
  20461. m.id = &id
  20462. }
  20463. }
  20464. // withToken sets the old Token of the mutation.
  20465. func withToken(node *Token) tokenOption {
  20466. return func(m *TokenMutation) {
  20467. m.oldValue = func(context.Context) (*Token, error) {
  20468. return node, nil
  20469. }
  20470. m.id = &node.ID
  20471. }
  20472. }
  20473. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20474. // executed in a transaction (ent.Tx), a transactional client is returned.
  20475. func (m TokenMutation) Client() *Client {
  20476. client := &Client{config: m.config}
  20477. client.init()
  20478. return client
  20479. }
  20480. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20481. // it returns an error otherwise.
  20482. func (m TokenMutation) Tx() (*Tx, error) {
  20483. if _, ok := m.driver.(*txDriver); !ok {
  20484. return nil, errors.New("ent: mutation is not running in a transaction")
  20485. }
  20486. tx := &Tx{config: m.config}
  20487. tx.init()
  20488. return tx, nil
  20489. }
  20490. // SetID sets the value of the id field. Note that this
  20491. // operation is only accepted on creation of Token entities.
  20492. func (m *TokenMutation) SetID(id uint64) {
  20493. m.id = &id
  20494. }
  20495. // ID returns the ID value in the mutation. Note that the ID is only available
  20496. // if it was provided to the builder or after it was returned from the database.
  20497. func (m *TokenMutation) ID() (id uint64, exists bool) {
  20498. if m.id == nil {
  20499. return
  20500. }
  20501. return *m.id, true
  20502. }
  20503. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20504. // That means, if the mutation is applied within a transaction with an isolation level such
  20505. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20506. // or updated by the mutation.
  20507. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  20508. switch {
  20509. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20510. id, exists := m.ID()
  20511. if exists {
  20512. return []uint64{id}, nil
  20513. }
  20514. fallthrough
  20515. case m.op.Is(OpUpdate | OpDelete):
  20516. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  20517. default:
  20518. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20519. }
  20520. }
  20521. // SetCreatedAt sets the "created_at" field.
  20522. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  20523. m.created_at = &t
  20524. }
  20525. // CreatedAt returns the value of the "created_at" field in the mutation.
  20526. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  20527. v := m.created_at
  20528. if v == nil {
  20529. return
  20530. }
  20531. return *v, true
  20532. }
  20533. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  20534. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20536. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20537. if !m.op.Is(OpUpdateOne) {
  20538. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20539. }
  20540. if m.id == nil || m.oldValue == nil {
  20541. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20542. }
  20543. oldValue, err := m.oldValue(ctx)
  20544. if err != nil {
  20545. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20546. }
  20547. return oldValue.CreatedAt, nil
  20548. }
  20549. // ResetCreatedAt resets all changes to the "created_at" field.
  20550. func (m *TokenMutation) ResetCreatedAt() {
  20551. m.created_at = nil
  20552. }
  20553. // SetUpdatedAt sets the "updated_at" field.
  20554. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  20555. m.updated_at = &t
  20556. }
  20557. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20558. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  20559. v := m.updated_at
  20560. if v == nil {
  20561. return
  20562. }
  20563. return *v, true
  20564. }
  20565. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  20566. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20568. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20569. if !m.op.Is(OpUpdateOne) {
  20570. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20571. }
  20572. if m.id == nil || m.oldValue == nil {
  20573. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20574. }
  20575. oldValue, err := m.oldValue(ctx)
  20576. if err != nil {
  20577. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20578. }
  20579. return oldValue.UpdatedAt, nil
  20580. }
  20581. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20582. func (m *TokenMutation) ResetUpdatedAt() {
  20583. m.updated_at = nil
  20584. }
  20585. // SetDeletedAt sets the "deleted_at" field.
  20586. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  20587. m.deleted_at = &t
  20588. }
  20589. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20590. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  20591. v := m.deleted_at
  20592. if v == nil {
  20593. return
  20594. }
  20595. return *v, true
  20596. }
  20597. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  20598. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20600. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20601. if !m.op.Is(OpUpdateOne) {
  20602. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20603. }
  20604. if m.id == nil || m.oldValue == nil {
  20605. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20606. }
  20607. oldValue, err := m.oldValue(ctx)
  20608. if err != nil {
  20609. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20610. }
  20611. return oldValue.DeletedAt, nil
  20612. }
  20613. // ClearDeletedAt clears the value of the "deleted_at" field.
  20614. func (m *TokenMutation) ClearDeletedAt() {
  20615. m.deleted_at = nil
  20616. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  20617. }
  20618. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20619. func (m *TokenMutation) DeletedAtCleared() bool {
  20620. _, ok := m.clearedFields[token.FieldDeletedAt]
  20621. return ok
  20622. }
  20623. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20624. func (m *TokenMutation) ResetDeletedAt() {
  20625. m.deleted_at = nil
  20626. delete(m.clearedFields, token.FieldDeletedAt)
  20627. }
  20628. // SetExpireAt sets the "expire_at" field.
  20629. func (m *TokenMutation) SetExpireAt(t time.Time) {
  20630. m.expire_at = &t
  20631. }
  20632. // ExpireAt returns the value of the "expire_at" field in the mutation.
  20633. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  20634. v := m.expire_at
  20635. if v == nil {
  20636. return
  20637. }
  20638. return *v, true
  20639. }
  20640. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  20641. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20643. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  20644. if !m.op.Is(OpUpdateOne) {
  20645. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  20646. }
  20647. if m.id == nil || m.oldValue == nil {
  20648. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  20649. }
  20650. oldValue, err := m.oldValue(ctx)
  20651. if err != nil {
  20652. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  20653. }
  20654. return oldValue.ExpireAt, nil
  20655. }
  20656. // ClearExpireAt clears the value of the "expire_at" field.
  20657. func (m *TokenMutation) ClearExpireAt() {
  20658. m.expire_at = nil
  20659. m.clearedFields[token.FieldExpireAt] = struct{}{}
  20660. }
  20661. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  20662. func (m *TokenMutation) ExpireAtCleared() bool {
  20663. _, ok := m.clearedFields[token.FieldExpireAt]
  20664. return ok
  20665. }
  20666. // ResetExpireAt resets all changes to the "expire_at" field.
  20667. func (m *TokenMutation) ResetExpireAt() {
  20668. m.expire_at = nil
  20669. delete(m.clearedFields, token.FieldExpireAt)
  20670. }
  20671. // SetToken sets the "token" field.
  20672. func (m *TokenMutation) SetToken(s string) {
  20673. m.token = &s
  20674. }
  20675. // Token returns the value of the "token" field in the mutation.
  20676. func (m *TokenMutation) Token() (r string, exists bool) {
  20677. v := m.token
  20678. if v == nil {
  20679. return
  20680. }
  20681. return *v, true
  20682. }
  20683. // OldToken returns the old "token" field's value of the Token entity.
  20684. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20686. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  20687. if !m.op.Is(OpUpdateOne) {
  20688. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20689. }
  20690. if m.id == nil || m.oldValue == nil {
  20691. return v, errors.New("OldToken requires an ID field in the mutation")
  20692. }
  20693. oldValue, err := m.oldValue(ctx)
  20694. if err != nil {
  20695. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20696. }
  20697. return oldValue.Token, nil
  20698. }
  20699. // ClearToken clears the value of the "token" field.
  20700. func (m *TokenMutation) ClearToken() {
  20701. m.token = nil
  20702. m.clearedFields[token.FieldToken] = struct{}{}
  20703. }
  20704. // TokenCleared returns if the "token" field was cleared in this mutation.
  20705. func (m *TokenMutation) TokenCleared() bool {
  20706. _, ok := m.clearedFields[token.FieldToken]
  20707. return ok
  20708. }
  20709. // ResetToken resets all changes to the "token" field.
  20710. func (m *TokenMutation) ResetToken() {
  20711. m.token = nil
  20712. delete(m.clearedFields, token.FieldToken)
  20713. }
  20714. // SetMAC sets the "mac" field.
  20715. func (m *TokenMutation) SetMAC(s string) {
  20716. m.mac = &s
  20717. }
  20718. // MAC returns the value of the "mac" field in the mutation.
  20719. func (m *TokenMutation) MAC() (r string, exists bool) {
  20720. v := m.mac
  20721. if v == nil {
  20722. return
  20723. }
  20724. return *v, true
  20725. }
  20726. // OldMAC returns the old "mac" field's value of the Token entity.
  20727. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20729. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  20730. if !m.op.Is(OpUpdateOne) {
  20731. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  20732. }
  20733. if m.id == nil || m.oldValue == nil {
  20734. return v, errors.New("OldMAC requires an ID field in the mutation")
  20735. }
  20736. oldValue, err := m.oldValue(ctx)
  20737. if err != nil {
  20738. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  20739. }
  20740. return oldValue.MAC, nil
  20741. }
  20742. // ClearMAC clears the value of the "mac" field.
  20743. func (m *TokenMutation) ClearMAC() {
  20744. m.mac = nil
  20745. m.clearedFields[token.FieldMAC] = struct{}{}
  20746. }
  20747. // MACCleared returns if the "mac" field was cleared in this mutation.
  20748. func (m *TokenMutation) MACCleared() bool {
  20749. _, ok := m.clearedFields[token.FieldMAC]
  20750. return ok
  20751. }
  20752. // ResetMAC resets all changes to the "mac" field.
  20753. func (m *TokenMutation) ResetMAC() {
  20754. m.mac = nil
  20755. delete(m.clearedFields, token.FieldMAC)
  20756. }
  20757. // SetOrganizationID sets the "organization_id" field.
  20758. func (m *TokenMutation) SetOrganizationID(u uint64) {
  20759. m.organization_id = &u
  20760. m.addorganization_id = nil
  20761. }
  20762. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20763. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  20764. v := m.organization_id
  20765. if v == nil {
  20766. return
  20767. }
  20768. return *v, true
  20769. }
  20770. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  20771. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20773. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20774. if !m.op.Is(OpUpdateOne) {
  20775. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20776. }
  20777. if m.id == nil || m.oldValue == nil {
  20778. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20779. }
  20780. oldValue, err := m.oldValue(ctx)
  20781. if err != nil {
  20782. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20783. }
  20784. return oldValue.OrganizationID, nil
  20785. }
  20786. // AddOrganizationID adds u to the "organization_id" field.
  20787. func (m *TokenMutation) AddOrganizationID(u int64) {
  20788. if m.addorganization_id != nil {
  20789. *m.addorganization_id += u
  20790. } else {
  20791. m.addorganization_id = &u
  20792. }
  20793. }
  20794. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20795. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  20796. v := m.addorganization_id
  20797. if v == nil {
  20798. return
  20799. }
  20800. return *v, true
  20801. }
  20802. // ResetOrganizationID resets all changes to the "organization_id" field.
  20803. func (m *TokenMutation) ResetOrganizationID() {
  20804. m.organization_id = nil
  20805. m.addorganization_id = nil
  20806. }
  20807. // SetAgentID sets the "agent_id" field.
  20808. func (m *TokenMutation) SetAgentID(u uint64) {
  20809. m.agent = &u
  20810. }
  20811. // AgentID returns the value of the "agent_id" field in the mutation.
  20812. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  20813. v := m.agent
  20814. if v == nil {
  20815. return
  20816. }
  20817. return *v, true
  20818. }
  20819. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  20820. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20822. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  20823. if !m.op.Is(OpUpdateOne) {
  20824. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  20825. }
  20826. if m.id == nil || m.oldValue == nil {
  20827. return v, errors.New("OldAgentID requires an ID field in the mutation")
  20828. }
  20829. oldValue, err := m.oldValue(ctx)
  20830. if err != nil {
  20831. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  20832. }
  20833. return oldValue.AgentID, nil
  20834. }
  20835. // ResetAgentID resets all changes to the "agent_id" field.
  20836. func (m *TokenMutation) ResetAgentID() {
  20837. m.agent = nil
  20838. }
  20839. // SetCustomAgentBase sets the "custom_agent_base" field.
  20840. func (m *TokenMutation) SetCustomAgentBase(s string) {
  20841. m.custom_agent_base = &s
  20842. }
  20843. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  20844. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  20845. v := m.custom_agent_base
  20846. if v == nil {
  20847. return
  20848. }
  20849. return *v, true
  20850. }
  20851. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  20852. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20854. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  20855. if !m.op.Is(OpUpdateOne) {
  20856. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  20857. }
  20858. if m.id == nil || m.oldValue == nil {
  20859. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  20860. }
  20861. oldValue, err := m.oldValue(ctx)
  20862. if err != nil {
  20863. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  20864. }
  20865. return oldValue.CustomAgentBase, nil
  20866. }
  20867. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  20868. func (m *TokenMutation) ClearCustomAgentBase() {
  20869. m.custom_agent_base = nil
  20870. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  20871. }
  20872. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  20873. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  20874. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  20875. return ok
  20876. }
  20877. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  20878. func (m *TokenMutation) ResetCustomAgentBase() {
  20879. m.custom_agent_base = nil
  20880. delete(m.clearedFields, token.FieldCustomAgentBase)
  20881. }
  20882. // SetCustomAgentKey sets the "custom_agent_key" field.
  20883. func (m *TokenMutation) SetCustomAgentKey(s string) {
  20884. m.custom_agent_key = &s
  20885. }
  20886. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  20887. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  20888. v := m.custom_agent_key
  20889. if v == nil {
  20890. return
  20891. }
  20892. return *v, true
  20893. }
  20894. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  20895. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20897. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  20898. if !m.op.Is(OpUpdateOne) {
  20899. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  20900. }
  20901. if m.id == nil || m.oldValue == nil {
  20902. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  20903. }
  20904. oldValue, err := m.oldValue(ctx)
  20905. if err != nil {
  20906. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  20907. }
  20908. return oldValue.CustomAgentKey, nil
  20909. }
  20910. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  20911. func (m *TokenMutation) ClearCustomAgentKey() {
  20912. m.custom_agent_key = nil
  20913. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  20914. }
  20915. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  20916. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  20917. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  20918. return ok
  20919. }
  20920. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  20921. func (m *TokenMutation) ResetCustomAgentKey() {
  20922. m.custom_agent_key = nil
  20923. delete(m.clearedFields, token.FieldCustomAgentKey)
  20924. }
  20925. // SetOpenaiBase sets the "openai_base" field.
  20926. func (m *TokenMutation) SetOpenaiBase(s string) {
  20927. m.openai_base = &s
  20928. }
  20929. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  20930. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  20931. v := m.openai_base
  20932. if v == nil {
  20933. return
  20934. }
  20935. return *v, true
  20936. }
  20937. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  20938. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20940. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  20941. if !m.op.Is(OpUpdateOne) {
  20942. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  20943. }
  20944. if m.id == nil || m.oldValue == nil {
  20945. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  20946. }
  20947. oldValue, err := m.oldValue(ctx)
  20948. if err != nil {
  20949. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  20950. }
  20951. return oldValue.OpenaiBase, nil
  20952. }
  20953. // ClearOpenaiBase clears the value of the "openai_base" field.
  20954. func (m *TokenMutation) ClearOpenaiBase() {
  20955. m.openai_base = nil
  20956. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  20957. }
  20958. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  20959. func (m *TokenMutation) OpenaiBaseCleared() bool {
  20960. _, ok := m.clearedFields[token.FieldOpenaiBase]
  20961. return ok
  20962. }
  20963. // ResetOpenaiBase resets all changes to the "openai_base" field.
  20964. func (m *TokenMutation) ResetOpenaiBase() {
  20965. m.openai_base = nil
  20966. delete(m.clearedFields, token.FieldOpenaiBase)
  20967. }
  20968. // SetOpenaiKey sets the "openai_key" field.
  20969. func (m *TokenMutation) SetOpenaiKey(s string) {
  20970. m.openai_key = &s
  20971. }
  20972. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  20973. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  20974. v := m.openai_key
  20975. if v == nil {
  20976. return
  20977. }
  20978. return *v, true
  20979. }
  20980. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  20981. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20983. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  20984. if !m.op.Is(OpUpdateOne) {
  20985. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  20986. }
  20987. if m.id == nil || m.oldValue == nil {
  20988. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  20989. }
  20990. oldValue, err := m.oldValue(ctx)
  20991. if err != nil {
  20992. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  20993. }
  20994. return oldValue.OpenaiKey, nil
  20995. }
  20996. // ClearOpenaiKey clears the value of the "openai_key" field.
  20997. func (m *TokenMutation) ClearOpenaiKey() {
  20998. m.openai_key = nil
  20999. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  21000. }
  21001. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  21002. func (m *TokenMutation) OpenaiKeyCleared() bool {
  21003. _, ok := m.clearedFields[token.FieldOpenaiKey]
  21004. return ok
  21005. }
  21006. // ResetOpenaiKey resets all changes to the "openai_key" field.
  21007. func (m *TokenMutation) ResetOpenaiKey() {
  21008. m.openai_key = nil
  21009. delete(m.clearedFields, token.FieldOpenaiKey)
  21010. }
  21011. // ClearAgent clears the "agent" edge to the Agent entity.
  21012. func (m *TokenMutation) ClearAgent() {
  21013. m.clearedagent = true
  21014. m.clearedFields[token.FieldAgentID] = struct{}{}
  21015. }
  21016. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  21017. func (m *TokenMutation) AgentCleared() bool {
  21018. return m.clearedagent
  21019. }
  21020. // AgentIDs returns the "agent" edge IDs in the mutation.
  21021. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21022. // AgentID instead. It exists only for internal usage by the builders.
  21023. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  21024. if id := m.agent; id != nil {
  21025. ids = append(ids, *id)
  21026. }
  21027. return
  21028. }
  21029. // ResetAgent resets all changes to the "agent" edge.
  21030. func (m *TokenMutation) ResetAgent() {
  21031. m.agent = nil
  21032. m.clearedagent = false
  21033. }
  21034. // Where appends a list predicates to the TokenMutation builder.
  21035. func (m *TokenMutation) Where(ps ...predicate.Token) {
  21036. m.predicates = append(m.predicates, ps...)
  21037. }
  21038. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  21039. // users can use type-assertion to append predicates that do not depend on any generated package.
  21040. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  21041. p := make([]predicate.Token, len(ps))
  21042. for i := range ps {
  21043. p[i] = ps[i]
  21044. }
  21045. m.Where(p...)
  21046. }
  21047. // Op returns the operation name.
  21048. func (m *TokenMutation) Op() Op {
  21049. return m.op
  21050. }
  21051. // SetOp allows setting the mutation operation.
  21052. func (m *TokenMutation) SetOp(op Op) {
  21053. m.op = op
  21054. }
  21055. // Type returns the node type of this mutation (Token).
  21056. func (m *TokenMutation) Type() string {
  21057. return m.typ
  21058. }
  21059. // Fields returns all fields that were changed during this mutation. Note that in
  21060. // order to get all numeric fields that were incremented/decremented, call
  21061. // AddedFields().
  21062. func (m *TokenMutation) Fields() []string {
  21063. fields := make([]string, 0, 12)
  21064. if m.created_at != nil {
  21065. fields = append(fields, token.FieldCreatedAt)
  21066. }
  21067. if m.updated_at != nil {
  21068. fields = append(fields, token.FieldUpdatedAt)
  21069. }
  21070. if m.deleted_at != nil {
  21071. fields = append(fields, token.FieldDeletedAt)
  21072. }
  21073. if m.expire_at != nil {
  21074. fields = append(fields, token.FieldExpireAt)
  21075. }
  21076. if m.token != nil {
  21077. fields = append(fields, token.FieldToken)
  21078. }
  21079. if m.mac != nil {
  21080. fields = append(fields, token.FieldMAC)
  21081. }
  21082. if m.organization_id != nil {
  21083. fields = append(fields, token.FieldOrganizationID)
  21084. }
  21085. if m.agent != nil {
  21086. fields = append(fields, token.FieldAgentID)
  21087. }
  21088. if m.custom_agent_base != nil {
  21089. fields = append(fields, token.FieldCustomAgentBase)
  21090. }
  21091. if m.custom_agent_key != nil {
  21092. fields = append(fields, token.FieldCustomAgentKey)
  21093. }
  21094. if m.openai_base != nil {
  21095. fields = append(fields, token.FieldOpenaiBase)
  21096. }
  21097. if m.openai_key != nil {
  21098. fields = append(fields, token.FieldOpenaiKey)
  21099. }
  21100. return fields
  21101. }
  21102. // Field returns the value of a field with the given name. The second boolean
  21103. // return value indicates that this field was not set, or was not defined in the
  21104. // schema.
  21105. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  21106. switch name {
  21107. case token.FieldCreatedAt:
  21108. return m.CreatedAt()
  21109. case token.FieldUpdatedAt:
  21110. return m.UpdatedAt()
  21111. case token.FieldDeletedAt:
  21112. return m.DeletedAt()
  21113. case token.FieldExpireAt:
  21114. return m.ExpireAt()
  21115. case token.FieldToken:
  21116. return m.Token()
  21117. case token.FieldMAC:
  21118. return m.MAC()
  21119. case token.FieldOrganizationID:
  21120. return m.OrganizationID()
  21121. case token.FieldAgentID:
  21122. return m.AgentID()
  21123. case token.FieldCustomAgentBase:
  21124. return m.CustomAgentBase()
  21125. case token.FieldCustomAgentKey:
  21126. return m.CustomAgentKey()
  21127. case token.FieldOpenaiBase:
  21128. return m.OpenaiBase()
  21129. case token.FieldOpenaiKey:
  21130. return m.OpenaiKey()
  21131. }
  21132. return nil, false
  21133. }
  21134. // OldField returns the old value of the field from the database. An error is
  21135. // returned if the mutation operation is not UpdateOne, or the query to the
  21136. // database failed.
  21137. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21138. switch name {
  21139. case token.FieldCreatedAt:
  21140. return m.OldCreatedAt(ctx)
  21141. case token.FieldUpdatedAt:
  21142. return m.OldUpdatedAt(ctx)
  21143. case token.FieldDeletedAt:
  21144. return m.OldDeletedAt(ctx)
  21145. case token.FieldExpireAt:
  21146. return m.OldExpireAt(ctx)
  21147. case token.FieldToken:
  21148. return m.OldToken(ctx)
  21149. case token.FieldMAC:
  21150. return m.OldMAC(ctx)
  21151. case token.FieldOrganizationID:
  21152. return m.OldOrganizationID(ctx)
  21153. case token.FieldAgentID:
  21154. return m.OldAgentID(ctx)
  21155. case token.FieldCustomAgentBase:
  21156. return m.OldCustomAgentBase(ctx)
  21157. case token.FieldCustomAgentKey:
  21158. return m.OldCustomAgentKey(ctx)
  21159. case token.FieldOpenaiBase:
  21160. return m.OldOpenaiBase(ctx)
  21161. case token.FieldOpenaiKey:
  21162. return m.OldOpenaiKey(ctx)
  21163. }
  21164. return nil, fmt.Errorf("unknown Token field %s", name)
  21165. }
  21166. // SetField sets the value of a field with the given name. It returns an error if
  21167. // the field is not defined in the schema, or if the type mismatched the field
  21168. // type.
  21169. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  21170. switch name {
  21171. case token.FieldCreatedAt:
  21172. v, ok := value.(time.Time)
  21173. if !ok {
  21174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21175. }
  21176. m.SetCreatedAt(v)
  21177. return nil
  21178. case token.FieldUpdatedAt:
  21179. v, ok := value.(time.Time)
  21180. if !ok {
  21181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21182. }
  21183. m.SetUpdatedAt(v)
  21184. return nil
  21185. case token.FieldDeletedAt:
  21186. v, ok := value.(time.Time)
  21187. if !ok {
  21188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21189. }
  21190. m.SetDeletedAt(v)
  21191. return nil
  21192. case token.FieldExpireAt:
  21193. v, ok := value.(time.Time)
  21194. if !ok {
  21195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21196. }
  21197. m.SetExpireAt(v)
  21198. return nil
  21199. case token.FieldToken:
  21200. v, ok := value.(string)
  21201. if !ok {
  21202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21203. }
  21204. m.SetToken(v)
  21205. return nil
  21206. case token.FieldMAC:
  21207. v, ok := value.(string)
  21208. if !ok {
  21209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21210. }
  21211. m.SetMAC(v)
  21212. return nil
  21213. case token.FieldOrganizationID:
  21214. v, ok := value.(uint64)
  21215. if !ok {
  21216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21217. }
  21218. m.SetOrganizationID(v)
  21219. return nil
  21220. case token.FieldAgentID:
  21221. v, ok := value.(uint64)
  21222. if !ok {
  21223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21224. }
  21225. m.SetAgentID(v)
  21226. return nil
  21227. case token.FieldCustomAgentBase:
  21228. v, ok := value.(string)
  21229. if !ok {
  21230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21231. }
  21232. m.SetCustomAgentBase(v)
  21233. return nil
  21234. case token.FieldCustomAgentKey:
  21235. v, ok := value.(string)
  21236. if !ok {
  21237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21238. }
  21239. m.SetCustomAgentKey(v)
  21240. return nil
  21241. case token.FieldOpenaiBase:
  21242. v, ok := value.(string)
  21243. if !ok {
  21244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21245. }
  21246. m.SetOpenaiBase(v)
  21247. return nil
  21248. case token.FieldOpenaiKey:
  21249. v, ok := value.(string)
  21250. if !ok {
  21251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21252. }
  21253. m.SetOpenaiKey(v)
  21254. return nil
  21255. }
  21256. return fmt.Errorf("unknown Token field %s", name)
  21257. }
  21258. // AddedFields returns all numeric fields that were incremented/decremented during
  21259. // this mutation.
  21260. func (m *TokenMutation) AddedFields() []string {
  21261. var fields []string
  21262. if m.addorganization_id != nil {
  21263. fields = append(fields, token.FieldOrganizationID)
  21264. }
  21265. return fields
  21266. }
  21267. // AddedField returns the numeric value that was incremented/decremented on a field
  21268. // with the given name. The second boolean return value indicates that this field
  21269. // was not set, or was not defined in the schema.
  21270. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  21271. switch name {
  21272. case token.FieldOrganizationID:
  21273. return m.AddedOrganizationID()
  21274. }
  21275. return nil, false
  21276. }
  21277. // AddField adds the value to the field with the given name. It returns an error if
  21278. // the field is not defined in the schema, or if the type mismatched the field
  21279. // type.
  21280. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  21281. switch name {
  21282. case token.FieldOrganizationID:
  21283. v, ok := value.(int64)
  21284. if !ok {
  21285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21286. }
  21287. m.AddOrganizationID(v)
  21288. return nil
  21289. }
  21290. return fmt.Errorf("unknown Token numeric field %s", name)
  21291. }
  21292. // ClearedFields returns all nullable fields that were cleared during this
  21293. // mutation.
  21294. func (m *TokenMutation) ClearedFields() []string {
  21295. var fields []string
  21296. if m.FieldCleared(token.FieldDeletedAt) {
  21297. fields = append(fields, token.FieldDeletedAt)
  21298. }
  21299. if m.FieldCleared(token.FieldExpireAt) {
  21300. fields = append(fields, token.FieldExpireAt)
  21301. }
  21302. if m.FieldCleared(token.FieldToken) {
  21303. fields = append(fields, token.FieldToken)
  21304. }
  21305. if m.FieldCleared(token.FieldMAC) {
  21306. fields = append(fields, token.FieldMAC)
  21307. }
  21308. if m.FieldCleared(token.FieldCustomAgentBase) {
  21309. fields = append(fields, token.FieldCustomAgentBase)
  21310. }
  21311. if m.FieldCleared(token.FieldCustomAgentKey) {
  21312. fields = append(fields, token.FieldCustomAgentKey)
  21313. }
  21314. if m.FieldCleared(token.FieldOpenaiBase) {
  21315. fields = append(fields, token.FieldOpenaiBase)
  21316. }
  21317. if m.FieldCleared(token.FieldOpenaiKey) {
  21318. fields = append(fields, token.FieldOpenaiKey)
  21319. }
  21320. return fields
  21321. }
  21322. // FieldCleared returns a boolean indicating if a field with the given name was
  21323. // cleared in this mutation.
  21324. func (m *TokenMutation) FieldCleared(name string) bool {
  21325. _, ok := m.clearedFields[name]
  21326. return ok
  21327. }
  21328. // ClearField clears the value of the field with the given name. It returns an
  21329. // error if the field is not defined in the schema.
  21330. func (m *TokenMutation) ClearField(name string) error {
  21331. switch name {
  21332. case token.FieldDeletedAt:
  21333. m.ClearDeletedAt()
  21334. return nil
  21335. case token.FieldExpireAt:
  21336. m.ClearExpireAt()
  21337. return nil
  21338. case token.FieldToken:
  21339. m.ClearToken()
  21340. return nil
  21341. case token.FieldMAC:
  21342. m.ClearMAC()
  21343. return nil
  21344. case token.FieldCustomAgentBase:
  21345. m.ClearCustomAgentBase()
  21346. return nil
  21347. case token.FieldCustomAgentKey:
  21348. m.ClearCustomAgentKey()
  21349. return nil
  21350. case token.FieldOpenaiBase:
  21351. m.ClearOpenaiBase()
  21352. return nil
  21353. case token.FieldOpenaiKey:
  21354. m.ClearOpenaiKey()
  21355. return nil
  21356. }
  21357. return fmt.Errorf("unknown Token nullable field %s", name)
  21358. }
  21359. // ResetField resets all changes in the mutation for the field with the given name.
  21360. // It returns an error if the field is not defined in the schema.
  21361. func (m *TokenMutation) ResetField(name string) error {
  21362. switch name {
  21363. case token.FieldCreatedAt:
  21364. m.ResetCreatedAt()
  21365. return nil
  21366. case token.FieldUpdatedAt:
  21367. m.ResetUpdatedAt()
  21368. return nil
  21369. case token.FieldDeletedAt:
  21370. m.ResetDeletedAt()
  21371. return nil
  21372. case token.FieldExpireAt:
  21373. m.ResetExpireAt()
  21374. return nil
  21375. case token.FieldToken:
  21376. m.ResetToken()
  21377. return nil
  21378. case token.FieldMAC:
  21379. m.ResetMAC()
  21380. return nil
  21381. case token.FieldOrganizationID:
  21382. m.ResetOrganizationID()
  21383. return nil
  21384. case token.FieldAgentID:
  21385. m.ResetAgentID()
  21386. return nil
  21387. case token.FieldCustomAgentBase:
  21388. m.ResetCustomAgentBase()
  21389. return nil
  21390. case token.FieldCustomAgentKey:
  21391. m.ResetCustomAgentKey()
  21392. return nil
  21393. case token.FieldOpenaiBase:
  21394. m.ResetOpenaiBase()
  21395. return nil
  21396. case token.FieldOpenaiKey:
  21397. m.ResetOpenaiKey()
  21398. return nil
  21399. }
  21400. return fmt.Errorf("unknown Token field %s", name)
  21401. }
  21402. // AddedEdges returns all edge names that were set/added in this mutation.
  21403. func (m *TokenMutation) AddedEdges() []string {
  21404. edges := make([]string, 0, 1)
  21405. if m.agent != nil {
  21406. edges = append(edges, token.EdgeAgent)
  21407. }
  21408. return edges
  21409. }
  21410. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21411. // name in this mutation.
  21412. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  21413. switch name {
  21414. case token.EdgeAgent:
  21415. if id := m.agent; id != nil {
  21416. return []ent.Value{*id}
  21417. }
  21418. }
  21419. return nil
  21420. }
  21421. // RemovedEdges returns all edge names that were removed in this mutation.
  21422. func (m *TokenMutation) RemovedEdges() []string {
  21423. edges := make([]string, 0, 1)
  21424. return edges
  21425. }
  21426. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21427. // the given name in this mutation.
  21428. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  21429. return nil
  21430. }
  21431. // ClearedEdges returns all edge names that were cleared in this mutation.
  21432. func (m *TokenMutation) ClearedEdges() []string {
  21433. edges := make([]string, 0, 1)
  21434. if m.clearedagent {
  21435. edges = append(edges, token.EdgeAgent)
  21436. }
  21437. return edges
  21438. }
  21439. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21440. // was cleared in this mutation.
  21441. func (m *TokenMutation) EdgeCleared(name string) bool {
  21442. switch name {
  21443. case token.EdgeAgent:
  21444. return m.clearedagent
  21445. }
  21446. return false
  21447. }
  21448. // ClearEdge clears the value of the edge with the given name. It returns an error
  21449. // if that edge is not defined in the schema.
  21450. func (m *TokenMutation) ClearEdge(name string) error {
  21451. switch name {
  21452. case token.EdgeAgent:
  21453. m.ClearAgent()
  21454. return nil
  21455. }
  21456. return fmt.Errorf("unknown Token unique edge %s", name)
  21457. }
  21458. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21459. // It returns an error if the edge is not defined in the schema.
  21460. func (m *TokenMutation) ResetEdge(name string) error {
  21461. switch name {
  21462. case token.EdgeAgent:
  21463. m.ResetAgent()
  21464. return nil
  21465. }
  21466. return fmt.Errorf("unknown Token edge %s", name)
  21467. }
  21468. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  21469. type TutorialMutation struct {
  21470. config
  21471. op Op
  21472. typ string
  21473. id *uint64
  21474. created_at *time.Time
  21475. updated_at *time.Time
  21476. deleted_at *time.Time
  21477. index *int
  21478. addindex *int
  21479. title *string
  21480. content *string
  21481. organization_id *uint64
  21482. addorganization_id *int64
  21483. clearedFields map[string]struct{}
  21484. employee *uint64
  21485. clearedemployee bool
  21486. done bool
  21487. oldValue func(context.Context) (*Tutorial, error)
  21488. predicates []predicate.Tutorial
  21489. }
  21490. var _ ent.Mutation = (*TutorialMutation)(nil)
  21491. // tutorialOption allows management of the mutation configuration using functional options.
  21492. type tutorialOption func(*TutorialMutation)
  21493. // newTutorialMutation creates new mutation for the Tutorial entity.
  21494. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  21495. m := &TutorialMutation{
  21496. config: c,
  21497. op: op,
  21498. typ: TypeTutorial,
  21499. clearedFields: make(map[string]struct{}),
  21500. }
  21501. for _, opt := range opts {
  21502. opt(m)
  21503. }
  21504. return m
  21505. }
  21506. // withTutorialID sets the ID field of the mutation.
  21507. func withTutorialID(id uint64) tutorialOption {
  21508. return func(m *TutorialMutation) {
  21509. var (
  21510. err error
  21511. once sync.Once
  21512. value *Tutorial
  21513. )
  21514. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  21515. once.Do(func() {
  21516. if m.done {
  21517. err = errors.New("querying old values post mutation is not allowed")
  21518. } else {
  21519. value, err = m.Client().Tutorial.Get(ctx, id)
  21520. }
  21521. })
  21522. return value, err
  21523. }
  21524. m.id = &id
  21525. }
  21526. }
  21527. // withTutorial sets the old Tutorial of the mutation.
  21528. func withTutorial(node *Tutorial) tutorialOption {
  21529. return func(m *TutorialMutation) {
  21530. m.oldValue = func(context.Context) (*Tutorial, error) {
  21531. return node, nil
  21532. }
  21533. m.id = &node.ID
  21534. }
  21535. }
  21536. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21537. // executed in a transaction (ent.Tx), a transactional client is returned.
  21538. func (m TutorialMutation) Client() *Client {
  21539. client := &Client{config: m.config}
  21540. client.init()
  21541. return client
  21542. }
  21543. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21544. // it returns an error otherwise.
  21545. func (m TutorialMutation) Tx() (*Tx, error) {
  21546. if _, ok := m.driver.(*txDriver); !ok {
  21547. return nil, errors.New("ent: mutation is not running in a transaction")
  21548. }
  21549. tx := &Tx{config: m.config}
  21550. tx.init()
  21551. return tx, nil
  21552. }
  21553. // SetID sets the value of the id field. Note that this
  21554. // operation is only accepted on creation of Tutorial entities.
  21555. func (m *TutorialMutation) SetID(id uint64) {
  21556. m.id = &id
  21557. }
  21558. // ID returns the ID value in the mutation. Note that the ID is only available
  21559. // if it was provided to the builder or after it was returned from the database.
  21560. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  21561. if m.id == nil {
  21562. return
  21563. }
  21564. return *m.id, true
  21565. }
  21566. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21567. // That means, if the mutation is applied within a transaction with an isolation level such
  21568. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21569. // or updated by the mutation.
  21570. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  21571. switch {
  21572. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21573. id, exists := m.ID()
  21574. if exists {
  21575. return []uint64{id}, nil
  21576. }
  21577. fallthrough
  21578. case m.op.Is(OpUpdate | OpDelete):
  21579. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  21580. default:
  21581. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21582. }
  21583. }
  21584. // SetCreatedAt sets the "created_at" field.
  21585. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  21586. m.created_at = &t
  21587. }
  21588. // CreatedAt returns the value of the "created_at" field in the mutation.
  21589. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  21590. v := m.created_at
  21591. if v == nil {
  21592. return
  21593. }
  21594. return *v, true
  21595. }
  21596. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  21597. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21599. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21600. if !m.op.Is(OpUpdateOne) {
  21601. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21602. }
  21603. if m.id == nil || m.oldValue == nil {
  21604. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21605. }
  21606. oldValue, err := m.oldValue(ctx)
  21607. if err != nil {
  21608. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21609. }
  21610. return oldValue.CreatedAt, nil
  21611. }
  21612. // ResetCreatedAt resets all changes to the "created_at" field.
  21613. func (m *TutorialMutation) ResetCreatedAt() {
  21614. m.created_at = nil
  21615. }
  21616. // SetUpdatedAt sets the "updated_at" field.
  21617. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  21618. m.updated_at = &t
  21619. }
  21620. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21621. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  21622. v := m.updated_at
  21623. if v == nil {
  21624. return
  21625. }
  21626. return *v, true
  21627. }
  21628. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  21629. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21631. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21632. if !m.op.Is(OpUpdateOne) {
  21633. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21634. }
  21635. if m.id == nil || m.oldValue == nil {
  21636. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21637. }
  21638. oldValue, err := m.oldValue(ctx)
  21639. if err != nil {
  21640. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21641. }
  21642. return oldValue.UpdatedAt, nil
  21643. }
  21644. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21645. func (m *TutorialMutation) ResetUpdatedAt() {
  21646. m.updated_at = nil
  21647. }
  21648. // SetDeletedAt sets the "deleted_at" field.
  21649. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  21650. m.deleted_at = &t
  21651. }
  21652. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21653. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  21654. v := m.deleted_at
  21655. if v == nil {
  21656. return
  21657. }
  21658. return *v, true
  21659. }
  21660. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  21661. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21663. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21664. if !m.op.Is(OpUpdateOne) {
  21665. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21666. }
  21667. if m.id == nil || m.oldValue == nil {
  21668. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21669. }
  21670. oldValue, err := m.oldValue(ctx)
  21671. if err != nil {
  21672. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21673. }
  21674. return oldValue.DeletedAt, nil
  21675. }
  21676. // ClearDeletedAt clears the value of the "deleted_at" field.
  21677. func (m *TutorialMutation) ClearDeletedAt() {
  21678. m.deleted_at = nil
  21679. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  21680. }
  21681. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21682. func (m *TutorialMutation) DeletedAtCleared() bool {
  21683. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  21684. return ok
  21685. }
  21686. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21687. func (m *TutorialMutation) ResetDeletedAt() {
  21688. m.deleted_at = nil
  21689. delete(m.clearedFields, tutorial.FieldDeletedAt)
  21690. }
  21691. // SetEmployeeID sets the "employee_id" field.
  21692. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  21693. m.employee = &u
  21694. }
  21695. // EmployeeID returns the value of the "employee_id" field in the mutation.
  21696. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  21697. v := m.employee
  21698. if v == nil {
  21699. return
  21700. }
  21701. return *v, true
  21702. }
  21703. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  21704. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21706. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  21707. if !m.op.Is(OpUpdateOne) {
  21708. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  21709. }
  21710. if m.id == nil || m.oldValue == nil {
  21711. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  21712. }
  21713. oldValue, err := m.oldValue(ctx)
  21714. if err != nil {
  21715. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  21716. }
  21717. return oldValue.EmployeeID, nil
  21718. }
  21719. // ResetEmployeeID resets all changes to the "employee_id" field.
  21720. func (m *TutorialMutation) ResetEmployeeID() {
  21721. m.employee = nil
  21722. }
  21723. // SetIndex sets the "index" field.
  21724. func (m *TutorialMutation) SetIndex(i int) {
  21725. m.index = &i
  21726. m.addindex = nil
  21727. }
  21728. // Index returns the value of the "index" field in the mutation.
  21729. func (m *TutorialMutation) Index() (r int, exists bool) {
  21730. v := m.index
  21731. if v == nil {
  21732. return
  21733. }
  21734. return *v, true
  21735. }
  21736. // OldIndex returns the old "index" field's value of the Tutorial entity.
  21737. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21739. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  21740. if !m.op.Is(OpUpdateOne) {
  21741. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  21742. }
  21743. if m.id == nil || m.oldValue == nil {
  21744. return v, errors.New("OldIndex requires an ID field in the mutation")
  21745. }
  21746. oldValue, err := m.oldValue(ctx)
  21747. if err != nil {
  21748. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  21749. }
  21750. return oldValue.Index, nil
  21751. }
  21752. // AddIndex adds i to the "index" field.
  21753. func (m *TutorialMutation) AddIndex(i int) {
  21754. if m.addindex != nil {
  21755. *m.addindex += i
  21756. } else {
  21757. m.addindex = &i
  21758. }
  21759. }
  21760. // AddedIndex returns the value that was added to the "index" field in this mutation.
  21761. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  21762. v := m.addindex
  21763. if v == nil {
  21764. return
  21765. }
  21766. return *v, true
  21767. }
  21768. // ResetIndex resets all changes to the "index" field.
  21769. func (m *TutorialMutation) ResetIndex() {
  21770. m.index = nil
  21771. m.addindex = nil
  21772. }
  21773. // SetTitle sets the "title" field.
  21774. func (m *TutorialMutation) SetTitle(s string) {
  21775. m.title = &s
  21776. }
  21777. // Title returns the value of the "title" field in the mutation.
  21778. func (m *TutorialMutation) Title() (r string, exists bool) {
  21779. v := m.title
  21780. if v == nil {
  21781. return
  21782. }
  21783. return *v, true
  21784. }
  21785. // OldTitle returns the old "title" field's value of the Tutorial entity.
  21786. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21788. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  21789. if !m.op.Is(OpUpdateOne) {
  21790. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  21791. }
  21792. if m.id == nil || m.oldValue == nil {
  21793. return v, errors.New("OldTitle requires an ID field in the mutation")
  21794. }
  21795. oldValue, err := m.oldValue(ctx)
  21796. if err != nil {
  21797. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  21798. }
  21799. return oldValue.Title, nil
  21800. }
  21801. // ResetTitle resets all changes to the "title" field.
  21802. func (m *TutorialMutation) ResetTitle() {
  21803. m.title = nil
  21804. }
  21805. // SetContent sets the "content" field.
  21806. func (m *TutorialMutation) SetContent(s string) {
  21807. m.content = &s
  21808. }
  21809. // Content returns the value of the "content" field in the mutation.
  21810. func (m *TutorialMutation) Content() (r string, exists bool) {
  21811. v := m.content
  21812. if v == nil {
  21813. return
  21814. }
  21815. return *v, true
  21816. }
  21817. // OldContent returns the old "content" field's value of the Tutorial entity.
  21818. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21820. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  21821. if !m.op.Is(OpUpdateOne) {
  21822. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21823. }
  21824. if m.id == nil || m.oldValue == nil {
  21825. return v, errors.New("OldContent requires an ID field in the mutation")
  21826. }
  21827. oldValue, err := m.oldValue(ctx)
  21828. if err != nil {
  21829. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21830. }
  21831. return oldValue.Content, nil
  21832. }
  21833. // ResetContent resets all changes to the "content" field.
  21834. func (m *TutorialMutation) ResetContent() {
  21835. m.content = nil
  21836. }
  21837. // SetOrganizationID sets the "organization_id" field.
  21838. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  21839. m.organization_id = &u
  21840. m.addorganization_id = nil
  21841. }
  21842. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21843. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  21844. v := m.organization_id
  21845. if v == nil {
  21846. return
  21847. }
  21848. return *v, true
  21849. }
  21850. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  21851. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21853. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21854. if !m.op.Is(OpUpdateOne) {
  21855. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21856. }
  21857. if m.id == nil || m.oldValue == nil {
  21858. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21859. }
  21860. oldValue, err := m.oldValue(ctx)
  21861. if err != nil {
  21862. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21863. }
  21864. return oldValue.OrganizationID, nil
  21865. }
  21866. // AddOrganizationID adds u to the "organization_id" field.
  21867. func (m *TutorialMutation) AddOrganizationID(u int64) {
  21868. if m.addorganization_id != nil {
  21869. *m.addorganization_id += u
  21870. } else {
  21871. m.addorganization_id = &u
  21872. }
  21873. }
  21874. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21875. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  21876. v := m.addorganization_id
  21877. if v == nil {
  21878. return
  21879. }
  21880. return *v, true
  21881. }
  21882. // ResetOrganizationID resets all changes to the "organization_id" field.
  21883. func (m *TutorialMutation) ResetOrganizationID() {
  21884. m.organization_id = nil
  21885. m.addorganization_id = nil
  21886. }
  21887. // ClearEmployee clears the "employee" edge to the Employee entity.
  21888. func (m *TutorialMutation) ClearEmployee() {
  21889. m.clearedemployee = true
  21890. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  21891. }
  21892. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  21893. func (m *TutorialMutation) EmployeeCleared() bool {
  21894. return m.clearedemployee
  21895. }
  21896. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  21897. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21898. // EmployeeID instead. It exists only for internal usage by the builders.
  21899. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  21900. if id := m.employee; id != nil {
  21901. ids = append(ids, *id)
  21902. }
  21903. return
  21904. }
  21905. // ResetEmployee resets all changes to the "employee" edge.
  21906. func (m *TutorialMutation) ResetEmployee() {
  21907. m.employee = nil
  21908. m.clearedemployee = false
  21909. }
  21910. // Where appends a list predicates to the TutorialMutation builder.
  21911. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  21912. m.predicates = append(m.predicates, ps...)
  21913. }
  21914. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  21915. // users can use type-assertion to append predicates that do not depend on any generated package.
  21916. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  21917. p := make([]predicate.Tutorial, len(ps))
  21918. for i := range ps {
  21919. p[i] = ps[i]
  21920. }
  21921. m.Where(p...)
  21922. }
  21923. // Op returns the operation name.
  21924. func (m *TutorialMutation) Op() Op {
  21925. return m.op
  21926. }
  21927. // SetOp allows setting the mutation operation.
  21928. func (m *TutorialMutation) SetOp(op Op) {
  21929. m.op = op
  21930. }
  21931. // Type returns the node type of this mutation (Tutorial).
  21932. func (m *TutorialMutation) Type() string {
  21933. return m.typ
  21934. }
  21935. // Fields returns all fields that were changed during this mutation. Note that in
  21936. // order to get all numeric fields that were incremented/decremented, call
  21937. // AddedFields().
  21938. func (m *TutorialMutation) Fields() []string {
  21939. fields := make([]string, 0, 8)
  21940. if m.created_at != nil {
  21941. fields = append(fields, tutorial.FieldCreatedAt)
  21942. }
  21943. if m.updated_at != nil {
  21944. fields = append(fields, tutorial.FieldUpdatedAt)
  21945. }
  21946. if m.deleted_at != nil {
  21947. fields = append(fields, tutorial.FieldDeletedAt)
  21948. }
  21949. if m.employee != nil {
  21950. fields = append(fields, tutorial.FieldEmployeeID)
  21951. }
  21952. if m.index != nil {
  21953. fields = append(fields, tutorial.FieldIndex)
  21954. }
  21955. if m.title != nil {
  21956. fields = append(fields, tutorial.FieldTitle)
  21957. }
  21958. if m.content != nil {
  21959. fields = append(fields, tutorial.FieldContent)
  21960. }
  21961. if m.organization_id != nil {
  21962. fields = append(fields, tutorial.FieldOrganizationID)
  21963. }
  21964. return fields
  21965. }
  21966. // Field returns the value of a field with the given name. The second boolean
  21967. // return value indicates that this field was not set, or was not defined in the
  21968. // schema.
  21969. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  21970. switch name {
  21971. case tutorial.FieldCreatedAt:
  21972. return m.CreatedAt()
  21973. case tutorial.FieldUpdatedAt:
  21974. return m.UpdatedAt()
  21975. case tutorial.FieldDeletedAt:
  21976. return m.DeletedAt()
  21977. case tutorial.FieldEmployeeID:
  21978. return m.EmployeeID()
  21979. case tutorial.FieldIndex:
  21980. return m.Index()
  21981. case tutorial.FieldTitle:
  21982. return m.Title()
  21983. case tutorial.FieldContent:
  21984. return m.Content()
  21985. case tutorial.FieldOrganizationID:
  21986. return m.OrganizationID()
  21987. }
  21988. return nil, false
  21989. }
  21990. // OldField returns the old value of the field from the database. An error is
  21991. // returned if the mutation operation is not UpdateOne, or the query to the
  21992. // database failed.
  21993. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21994. switch name {
  21995. case tutorial.FieldCreatedAt:
  21996. return m.OldCreatedAt(ctx)
  21997. case tutorial.FieldUpdatedAt:
  21998. return m.OldUpdatedAt(ctx)
  21999. case tutorial.FieldDeletedAt:
  22000. return m.OldDeletedAt(ctx)
  22001. case tutorial.FieldEmployeeID:
  22002. return m.OldEmployeeID(ctx)
  22003. case tutorial.FieldIndex:
  22004. return m.OldIndex(ctx)
  22005. case tutorial.FieldTitle:
  22006. return m.OldTitle(ctx)
  22007. case tutorial.FieldContent:
  22008. return m.OldContent(ctx)
  22009. case tutorial.FieldOrganizationID:
  22010. return m.OldOrganizationID(ctx)
  22011. }
  22012. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  22013. }
  22014. // SetField sets the value of a field with the given name. It returns an error if
  22015. // the field is not defined in the schema, or if the type mismatched the field
  22016. // type.
  22017. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  22018. switch name {
  22019. case tutorial.FieldCreatedAt:
  22020. v, ok := value.(time.Time)
  22021. if !ok {
  22022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22023. }
  22024. m.SetCreatedAt(v)
  22025. return nil
  22026. case tutorial.FieldUpdatedAt:
  22027. v, ok := value.(time.Time)
  22028. if !ok {
  22029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22030. }
  22031. m.SetUpdatedAt(v)
  22032. return nil
  22033. case tutorial.FieldDeletedAt:
  22034. v, ok := value.(time.Time)
  22035. if !ok {
  22036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22037. }
  22038. m.SetDeletedAt(v)
  22039. return nil
  22040. case tutorial.FieldEmployeeID:
  22041. v, ok := value.(uint64)
  22042. if !ok {
  22043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22044. }
  22045. m.SetEmployeeID(v)
  22046. return nil
  22047. case tutorial.FieldIndex:
  22048. v, ok := value.(int)
  22049. if !ok {
  22050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22051. }
  22052. m.SetIndex(v)
  22053. return nil
  22054. case tutorial.FieldTitle:
  22055. v, ok := value.(string)
  22056. if !ok {
  22057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22058. }
  22059. m.SetTitle(v)
  22060. return nil
  22061. case tutorial.FieldContent:
  22062. v, ok := value.(string)
  22063. if !ok {
  22064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22065. }
  22066. m.SetContent(v)
  22067. return nil
  22068. case tutorial.FieldOrganizationID:
  22069. v, ok := value.(uint64)
  22070. if !ok {
  22071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22072. }
  22073. m.SetOrganizationID(v)
  22074. return nil
  22075. }
  22076. return fmt.Errorf("unknown Tutorial field %s", name)
  22077. }
  22078. // AddedFields returns all numeric fields that were incremented/decremented during
  22079. // this mutation.
  22080. func (m *TutorialMutation) AddedFields() []string {
  22081. var fields []string
  22082. if m.addindex != nil {
  22083. fields = append(fields, tutorial.FieldIndex)
  22084. }
  22085. if m.addorganization_id != nil {
  22086. fields = append(fields, tutorial.FieldOrganizationID)
  22087. }
  22088. return fields
  22089. }
  22090. // AddedField returns the numeric value that was incremented/decremented on a field
  22091. // with the given name. The second boolean return value indicates that this field
  22092. // was not set, or was not defined in the schema.
  22093. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  22094. switch name {
  22095. case tutorial.FieldIndex:
  22096. return m.AddedIndex()
  22097. case tutorial.FieldOrganizationID:
  22098. return m.AddedOrganizationID()
  22099. }
  22100. return nil, false
  22101. }
  22102. // AddField adds the value to the field with the given name. It returns an error if
  22103. // the field is not defined in the schema, or if the type mismatched the field
  22104. // type.
  22105. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  22106. switch name {
  22107. case tutorial.FieldIndex:
  22108. v, ok := value.(int)
  22109. if !ok {
  22110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22111. }
  22112. m.AddIndex(v)
  22113. return nil
  22114. case tutorial.FieldOrganizationID:
  22115. v, ok := value.(int64)
  22116. if !ok {
  22117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22118. }
  22119. m.AddOrganizationID(v)
  22120. return nil
  22121. }
  22122. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  22123. }
  22124. // ClearedFields returns all nullable fields that were cleared during this
  22125. // mutation.
  22126. func (m *TutorialMutation) ClearedFields() []string {
  22127. var fields []string
  22128. if m.FieldCleared(tutorial.FieldDeletedAt) {
  22129. fields = append(fields, tutorial.FieldDeletedAt)
  22130. }
  22131. return fields
  22132. }
  22133. // FieldCleared returns a boolean indicating if a field with the given name was
  22134. // cleared in this mutation.
  22135. func (m *TutorialMutation) FieldCleared(name string) bool {
  22136. _, ok := m.clearedFields[name]
  22137. return ok
  22138. }
  22139. // ClearField clears the value of the field with the given name. It returns an
  22140. // error if the field is not defined in the schema.
  22141. func (m *TutorialMutation) ClearField(name string) error {
  22142. switch name {
  22143. case tutorial.FieldDeletedAt:
  22144. m.ClearDeletedAt()
  22145. return nil
  22146. }
  22147. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  22148. }
  22149. // ResetField resets all changes in the mutation for the field with the given name.
  22150. // It returns an error if the field is not defined in the schema.
  22151. func (m *TutorialMutation) ResetField(name string) error {
  22152. switch name {
  22153. case tutorial.FieldCreatedAt:
  22154. m.ResetCreatedAt()
  22155. return nil
  22156. case tutorial.FieldUpdatedAt:
  22157. m.ResetUpdatedAt()
  22158. return nil
  22159. case tutorial.FieldDeletedAt:
  22160. m.ResetDeletedAt()
  22161. return nil
  22162. case tutorial.FieldEmployeeID:
  22163. m.ResetEmployeeID()
  22164. return nil
  22165. case tutorial.FieldIndex:
  22166. m.ResetIndex()
  22167. return nil
  22168. case tutorial.FieldTitle:
  22169. m.ResetTitle()
  22170. return nil
  22171. case tutorial.FieldContent:
  22172. m.ResetContent()
  22173. return nil
  22174. case tutorial.FieldOrganizationID:
  22175. m.ResetOrganizationID()
  22176. return nil
  22177. }
  22178. return fmt.Errorf("unknown Tutorial field %s", name)
  22179. }
  22180. // AddedEdges returns all edge names that were set/added in this mutation.
  22181. func (m *TutorialMutation) AddedEdges() []string {
  22182. edges := make([]string, 0, 1)
  22183. if m.employee != nil {
  22184. edges = append(edges, tutorial.EdgeEmployee)
  22185. }
  22186. return edges
  22187. }
  22188. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22189. // name in this mutation.
  22190. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  22191. switch name {
  22192. case tutorial.EdgeEmployee:
  22193. if id := m.employee; id != nil {
  22194. return []ent.Value{*id}
  22195. }
  22196. }
  22197. return nil
  22198. }
  22199. // RemovedEdges returns all edge names that were removed in this mutation.
  22200. func (m *TutorialMutation) RemovedEdges() []string {
  22201. edges := make([]string, 0, 1)
  22202. return edges
  22203. }
  22204. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22205. // the given name in this mutation.
  22206. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  22207. return nil
  22208. }
  22209. // ClearedEdges returns all edge names that were cleared in this mutation.
  22210. func (m *TutorialMutation) ClearedEdges() []string {
  22211. edges := make([]string, 0, 1)
  22212. if m.clearedemployee {
  22213. edges = append(edges, tutorial.EdgeEmployee)
  22214. }
  22215. return edges
  22216. }
  22217. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22218. // was cleared in this mutation.
  22219. func (m *TutorialMutation) EdgeCleared(name string) bool {
  22220. switch name {
  22221. case tutorial.EdgeEmployee:
  22222. return m.clearedemployee
  22223. }
  22224. return false
  22225. }
  22226. // ClearEdge clears the value of the edge with the given name. It returns an error
  22227. // if that edge is not defined in the schema.
  22228. func (m *TutorialMutation) ClearEdge(name string) error {
  22229. switch name {
  22230. case tutorial.EdgeEmployee:
  22231. m.ClearEmployee()
  22232. return nil
  22233. }
  22234. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  22235. }
  22236. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22237. // It returns an error if the edge is not defined in the schema.
  22238. func (m *TutorialMutation) ResetEdge(name string) error {
  22239. switch name {
  22240. case tutorial.EdgeEmployee:
  22241. m.ResetEmployee()
  22242. return nil
  22243. }
  22244. return fmt.Errorf("unknown Tutorial edge %s", name)
  22245. }
  22246. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  22247. type UsageDetailMutation struct {
  22248. config
  22249. op Op
  22250. typ string
  22251. id *uint64
  22252. created_at *time.Time
  22253. updated_at *time.Time
  22254. status *uint8
  22255. addstatus *int8
  22256. _type *int
  22257. add_type *int
  22258. bot_id *string
  22259. receiver_id *string
  22260. app *int
  22261. addapp *int
  22262. session_id *uint64
  22263. addsession_id *int64
  22264. request *string
  22265. response *string
  22266. total_tokens *uint64
  22267. addtotal_tokens *int64
  22268. prompt_tokens *uint64
  22269. addprompt_tokens *int64
  22270. completion_tokens *uint64
  22271. addcompletion_tokens *int64
  22272. organization_id *uint64
  22273. addorganization_id *int64
  22274. clearedFields map[string]struct{}
  22275. done bool
  22276. oldValue func(context.Context) (*UsageDetail, error)
  22277. predicates []predicate.UsageDetail
  22278. }
  22279. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  22280. // usagedetailOption allows management of the mutation configuration using functional options.
  22281. type usagedetailOption func(*UsageDetailMutation)
  22282. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  22283. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  22284. m := &UsageDetailMutation{
  22285. config: c,
  22286. op: op,
  22287. typ: TypeUsageDetail,
  22288. clearedFields: make(map[string]struct{}),
  22289. }
  22290. for _, opt := range opts {
  22291. opt(m)
  22292. }
  22293. return m
  22294. }
  22295. // withUsageDetailID sets the ID field of the mutation.
  22296. func withUsageDetailID(id uint64) usagedetailOption {
  22297. return func(m *UsageDetailMutation) {
  22298. var (
  22299. err error
  22300. once sync.Once
  22301. value *UsageDetail
  22302. )
  22303. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  22304. once.Do(func() {
  22305. if m.done {
  22306. err = errors.New("querying old values post mutation is not allowed")
  22307. } else {
  22308. value, err = m.Client().UsageDetail.Get(ctx, id)
  22309. }
  22310. })
  22311. return value, err
  22312. }
  22313. m.id = &id
  22314. }
  22315. }
  22316. // withUsageDetail sets the old UsageDetail of the mutation.
  22317. func withUsageDetail(node *UsageDetail) usagedetailOption {
  22318. return func(m *UsageDetailMutation) {
  22319. m.oldValue = func(context.Context) (*UsageDetail, error) {
  22320. return node, nil
  22321. }
  22322. m.id = &node.ID
  22323. }
  22324. }
  22325. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22326. // executed in a transaction (ent.Tx), a transactional client is returned.
  22327. func (m UsageDetailMutation) Client() *Client {
  22328. client := &Client{config: m.config}
  22329. client.init()
  22330. return client
  22331. }
  22332. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22333. // it returns an error otherwise.
  22334. func (m UsageDetailMutation) Tx() (*Tx, error) {
  22335. if _, ok := m.driver.(*txDriver); !ok {
  22336. return nil, errors.New("ent: mutation is not running in a transaction")
  22337. }
  22338. tx := &Tx{config: m.config}
  22339. tx.init()
  22340. return tx, nil
  22341. }
  22342. // SetID sets the value of the id field. Note that this
  22343. // operation is only accepted on creation of UsageDetail entities.
  22344. func (m *UsageDetailMutation) SetID(id uint64) {
  22345. m.id = &id
  22346. }
  22347. // ID returns the ID value in the mutation. Note that the ID is only available
  22348. // if it was provided to the builder or after it was returned from the database.
  22349. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  22350. if m.id == nil {
  22351. return
  22352. }
  22353. return *m.id, true
  22354. }
  22355. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22356. // That means, if the mutation is applied within a transaction with an isolation level such
  22357. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22358. // or updated by the mutation.
  22359. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  22360. switch {
  22361. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22362. id, exists := m.ID()
  22363. if exists {
  22364. return []uint64{id}, nil
  22365. }
  22366. fallthrough
  22367. case m.op.Is(OpUpdate | OpDelete):
  22368. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  22369. default:
  22370. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22371. }
  22372. }
  22373. // SetCreatedAt sets the "created_at" field.
  22374. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  22375. m.created_at = &t
  22376. }
  22377. // CreatedAt returns the value of the "created_at" field in the mutation.
  22378. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  22379. v := m.created_at
  22380. if v == nil {
  22381. return
  22382. }
  22383. return *v, true
  22384. }
  22385. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  22386. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22388. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22389. if !m.op.Is(OpUpdateOne) {
  22390. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22391. }
  22392. if m.id == nil || m.oldValue == nil {
  22393. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22394. }
  22395. oldValue, err := m.oldValue(ctx)
  22396. if err != nil {
  22397. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22398. }
  22399. return oldValue.CreatedAt, nil
  22400. }
  22401. // ResetCreatedAt resets all changes to the "created_at" field.
  22402. func (m *UsageDetailMutation) ResetCreatedAt() {
  22403. m.created_at = nil
  22404. }
  22405. // SetUpdatedAt sets the "updated_at" field.
  22406. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  22407. m.updated_at = &t
  22408. }
  22409. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22410. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  22411. v := m.updated_at
  22412. if v == nil {
  22413. return
  22414. }
  22415. return *v, true
  22416. }
  22417. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  22418. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22420. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22421. if !m.op.Is(OpUpdateOne) {
  22422. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22423. }
  22424. if m.id == nil || m.oldValue == nil {
  22425. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22426. }
  22427. oldValue, err := m.oldValue(ctx)
  22428. if err != nil {
  22429. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22430. }
  22431. return oldValue.UpdatedAt, nil
  22432. }
  22433. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22434. func (m *UsageDetailMutation) ResetUpdatedAt() {
  22435. m.updated_at = nil
  22436. }
  22437. // SetStatus sets the "status" field.
  22438. func (m *UsageDetailMutation) SetStatus(u uint8) {
  22439. m.status = &u
  22440. m.addstatus = nil
  22441. }
  22442. // Status returns the value of the "status" field in the mutation.
  22443. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  22444. v := m.status
  22445. if v == nil {
  22446. return
  22447. }
  22448. return *v, true
  22449. }
  22450. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  22451. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22453. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22454. if !m.op.Is(OpUpdateOne) {
  22455. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22456. }
  22457. if m.id == nil || m.oldValue == nil {
  22458. return v, errors.New("OldStatus requires an ID field in the mutation")
  22459. }
  22460. oldValue, err := m.oldValue(ctx)
  22461. if err != nil {
  22462. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22463. }
  22464. return oldValue.Status, nil
  22465. }
  22466. // AddStatus adds u to the "status" field.
  22467. func (m *UsageDetailMutation) AddStatus(u int8) {
  22468. if m.addstatus != nil {
  22469. *m.addstatus += u
  22470. } else {
  22471. m.addstatus = &u
  22472. }
  22473. }
  22474. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22475. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  22476. v := m.addstatus
  22477. if v == nil {
  22478. return
  22479. }
  22480. return *v, true
  22481. }
  22482. // ClearStatus clears the value of the "status" field.
  22483. func (m *UsageDetailMutation) ClearStatus() {
  22484. m.status = nil
  22485. m.addstatus = nil
  22486. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  22487. }
  22488. // StatusCleared returns if the "status" field was cleared in this mutation.
  22489. func (m *UsageDetailMutation) StatusCleared() bool {
  22490. _, ok := m.clearedFields[usagedetail.FieldStatus]
  22491. return ok
  22492. }
  22493. // ResetStatus resets all changes to the "status" field.
  22494. func (m *UsageDetailMutation) ResetStatus() {
  22495. m.status = nil
  22496. m.addstatus = nil
  22497. delete(m.clearedFields, usagedetail.FieldStatus)
  22498. }
  22499. // SetType sets the "type" field.
  22500. func (m *UsageDetailMutation) SetType(i int) {
  22501. m._type = &i
  22502. m.add_type = nil
  22503. }
  22504. // GetType returns the value of the "type" field in the mutation.
  22505. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  22506. v := m._type
  22507. if v == nil {
  22508. return
  22509. }
  22510. return *v, true
  22511. }
  22512. // OldType returns the old "type" field's value of the UsageDetail entity.
  22513. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22515. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  22516. if !m.op.Is(OpUpdateOne) {
  22517. return v, errors.New("OldType is only allowed on UpdateOne operations")
  22518. }
  22519. if m.id == nil || m.oldValue == nil {
  22520. return v, errors.New("OldType requires an ID field in the mutation")
  22521. }
  22522. oldValue, err := m.oldValue(ctx)
  22523. if err != nil {
  22524. return v, fmt.Errorf("querying old value for OldType: %w", err)
  22525. }
  22526. return oldValue.Type, nil
  22527. }
  22528. // AddType adds i to the "type" field.
  22529. func (m *UsageDetailMutation) AddType(i int) {
  22530. if m.add_type != nil {
  22531. *m.add_type += i
  22532. } else {
  22533. m.add_type = &i
  22534. }
  22535. }
  22536. // AddedType returns the value that was added to the "type" field in this mutation.
  22537. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  22538. v := m.add_type
  22539. if v == nil {
  22540. return
  22541. }
  22542. return *v, true
  22543. }
  22544. // ClearType clears the value of the "type" field.
  22545. func (m *UsageDetailMutation) ClearType() {
  22546. m._type = nil
  22547. m.add_type = nil
  22548. m.clearedFields[usagedetail.FieldType] = struct{}{}
  22549. }
  22550. // TypeCleared returns if the "type" field was cleared in this mutation.
  22551. func (m *UsageDetailMutation) TypeCleared() bool {
  22552. _, ok := m.clearedFields[usagedetail.FieldType]
  22553. return ok
  22554. }
  22555. // ResetType resets all changes to the "type" field.
  22556. func (m *UsageDetailMutation) ResetType() {
  22557. m._type = nil
  22558. m.add_type = nil
  22559. delete(m.clearedFields, usagedetail.FieldType)
  22560. }
  22561. // SetBotID sets the "bot_id" field.
  22562. func (m *UsageDetailMutation) SetBotID(s string) {
  22563. m.bot_id = &s
  22564. }
  22565. // BotID returns the value of the "bot_id" field in the mutation.
  22566. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  22567. v := m.bot_id
  22568. if v == nil {
  22569. return
  22570. }
  22571. return *v, true
  22572. }
  22573. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  22574. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22576. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  22577. if !m.op.Is(OpUpdateOne) {
  22578. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  22579. }
  22580. if m.id == nil || m.oldValue == nil {
  22581. return v, errors.New("OldBotID requires an ID field in the mutation")
  22582. }
  22583. oldValue, err := m.oldValue(ctx)
  22584. if err != nil {
  22585. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  22586. }
  22587. return oldValue.BotID, nil
  22588. }
  22589. // ResetBotID resets all changes to the "bot_id" field.
  22590. func (m *UsageDetailMutation) ResetBotID() {
  22591. m.bot_id = nil
  22592. }
  22593. // SetReceiverID sets the "receiver_id" field.
  22594. func (m *UsageDetailMutation) SetReceiverID(s string) {
  22595. m.receiver_id = &s
  22596. }
  22597. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  22598. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  22599. v := m.receiver_id
  22600. if v == nil {
  22601. return
  22602. }
  22603. return *v, true
  22604. }
  22605. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  22606. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22608. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  22609. if !m.op.Is(OpUpdateOne) {
  22610. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  22611. }
  22612. if m.id == nil || m.oldValue == nil {
  22613. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  22614. }
  22615. oldValue, err := m.oldValue(ctx)
  22616. if err != nil {
  22617. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  22618. }
  22619. return oldValue.ReceiverID, nil
  22620. }
  22621. // ResetReceiverID resets all changes to the "receiver_id" field.
  22622. func (m *UsageDetailMutation) ResetReceiverID() {
  22623. m.receiver_id = nil
  22624. }
  22625. // SetApp sets the "app" field.
  22626. func (m *UsageDetailMutation) SetApp(i int) {
  22627. m.app = &i
  22628. m.addapp = nil
  22629. }
  22630. // App returns the value of the "app" field in the mutation.
  22631. func (m *UsageDetailMutation) App() (r int, exists bool) {
  22632. v := m.app
  22633. if v == nil {
  22634. return
  22635. }
  22636. return *v, true
  22637. }
  22638. // OldApp returns the old "app" field's value of the UsageDetail entity.
  22639. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22641. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  22642. if !m.op.Is(OpUpdateOne) {
  22643. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  22644. }
  22645. if m.id == nil || m.oldValue == nil {
  22646. return v, errors.New("OldApp requires an ID field in the mutation")
  22647. }
  22648. oldValue, err := m.oldValue(ctx)
  22649. if err != nil {
  22650. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  22651. }
  22652. return oldValue.App, nil
  22653. }
  22654. // AddApp adds i to the "app" field.
  22655. func (m *UsageDetailMutation) AddApp(i int) {
  22656. if m.addapp != nil {
  22657. *m.addapp += i
  22658. } else {
  22659. m.addapp = &i
  22660. }
  22661. }
  22662. // AddedApp returns the value that was added to the "app" field in this mutation.
  22663. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  22664. v := m.addapp
  22665. if v == nil {
  22666. return
  22667. }
  22668. return *v, true
  22669. }
  22670. // ClearApp clears the value of the "app" field.
  22671. func (m *UsageDetailMutation) ClearApp() {
  22672. m.app = nil
  22673. m.addapp = nil
  22674. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  22675. }
  22676. // AppCleared returns if the "app" field was cleared in this mutation.
  22677. func (m *UsageDetailMutation) AppCleared() bool {
  22678. _, ok := m.clearedFields[usagedetail.FieldApp]
  22679. return ok
  22680. }
  22681. // ResetApp resets all changes to the "app" field.
  22682. func (m *UsageDetailMutation) ResetApp() {
  22683. m.app = nil
  22684. m.addapp = nil
  22685. delete(m.clearedFields, usagedetail.FieldApp)
  22686. }
  22687. // SetSessionID sets the "session_id" field.
  22688. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  22689. m.session_id = &u
  22690. m.addsession_id = nil
  22691. }
  22692. // SessionID returns the value of the "session_id" field in the mutation.
  22693. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  22694. v := m.session_id
  22695. if v == nil {
  22696. return
  22697. }
  22698. return *v, true
  22699. }
  22700. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  22701. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22703. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  22704. if !m.op.Is(OpUpdateOne) {
  22705. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  22706. }
  22707. if m.id == nil || m.oldValue == nil {
  22708. return v, errors.New("OldSessionID requires an ID field in the mutation")
  22709. }
  22710. oldValue, err := m.oldValue(ctx)
  22711. if err != nil {
  22712. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  22713. }
  22714. return oldValue.SessionID, nil
  22715. }
  22716. // AddSessionID adds u to the "session_id" field.
  22717. func (m *UsageDetailMutation) AddSessionID(u int64) {
  22718. if m.addsession_id != nil {
  22719. *m.addsession_id += u
  22720. } else {
  22721. m.addsession_id = &u
  22722. }
  22723. }
  22724. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  22725. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  22726. v := m.addsession_id
  22727. if v == nil {
  22728. return
  22729. }
  22730. return *v, true
  22731. }
  22732. // ClearSessionID clears the value of the "session_id" field.
  22733. func (m *UsageDetailMutation) ClearSessionID() {
  22734. m.session_id = nil
  22735. m.addsession_id = nil
  22736. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  22737. }
  22738. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  22739. func (m *UsageDetailMutation) SessionIDCleared() bool {
  22740. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  22741. return ok
  22742. }
  22743. // ResetSessionID resets all changes to the "session_id" field.
  22744. func (m *UsageDetailMutation) ResetSessionID() {
  22745. m.session_id = nil
  22746. m.addsession_id = nil
  22747. delete(m.clearedFields, usagedetail.FieldSessionID)
  22748. }
  22749. // SetRequest sets the "request" field.
  22750. func (m *UsageDetailMutation) SetRequest(s string) {
  22751. m.request = &s
  22752. }
  22753. // Request returns the value of the "request" field in the mutation.
  22754. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  22755. v := m.request
  22756. if v == nil {
  22757. return
  22758. }
  22759. return *v, true
  22760. }
  22761. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  22762. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22764. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  22765. if !m.op.Is(OpUpdateOne) {
  22766. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  22767. }
  22768. if m.id == nil || m.oldValue == nil {
  22769. return v, errors.New("OldRequest requires an ID field in the mutation")
  22770. }
  22771. oldValue, err := m.oldValue(ctx)
  22772. if err != nil {
  22773. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  22774. }
  22775. return oldValue.Request, nil
  22776. }
  22777. // ResetRequest resets all changes to the "request" field.
  22778. func (m *UsageDetailMutation) ResetRequest() {
  22779. m.request = nil
  22780. }
  22781. // SetResponse sets the "response" field.
  22782. func (m *UsageDetailMutation) SetResponse(s string) {
  22783. m.response = &s
  22784. }
  22785. // Response returns the value of the "response" field in the mutation.
  22786. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  22787. v := m.response
  22788. if v == nil {
  22789. return
  22790. }
  22791. return *v, true
  22792. }
  22793. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  22794. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22796. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  22797. if !m.op.Is(OpUpdateOne) {
  22798. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  22799. }
  22800. if m.id == nil || m.oldValue == nil {
  22801. return v, errors.New("OldResponse requires an ID field in the mutation")
  22802. }
  22803. oldValue, err := m.oldValue(ctx)
  22804. if err != nil {
  22805. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  22806. }
  22807. return oldValue.Response, nil
  22808. }
  22809. // ResetResponse resets all changes to the "response" field.
  22810. func (m *UsageDetailMutation) ResetResponse() {
  22811. m.response = nil
  22812. }
  22813. // SetTotalTokens sets the "total_tokens" field.
  22814. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  22815. m.total_tokens = &u
  22816. m.addtotal_tokens = nil
  22817. }
  22818. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  22819. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  22820. v := m.total_tokens
  22821. if v == nil {
  22822. return
  22823. }
  22824. return *v, true
  22825. }
  22826. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  22827. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22829. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  22830. if !m.op.Is(OpUpdateOne) {
  22831. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  22832. }
  22833. if m.id == nil || m.oldValue == nil {
  22834. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  22835. }
  22836. oldValue, err := m.oldValue(ctx)
  22837. if err != nil {
  22838. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  22839. }
  22840. return oldValue.TotalTokens, nil
  22841. }
  22842. // AddTotalTokens adds u to the "total_tokens" field.
  22843. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  22844. if m.addtotal_tokens != nil {
  22845. *m.addtotal_tokens += u
  22846. } else {
  22847. m.addtotal_tokens = &u
  22848. }
  22849. }
  22850. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  22851. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  22852. v := m.addtotal_tokens
  22853. if v == nil {
  22854. return
  22855. }
  22856. return *v, true
  22857. }
  22858. // ClearTotalTokens clears the value of the "total_tokens" field.
  22859. func (m *UsageDetailMutation) ClearTotalTokens() {
  22860. m.total_tokens = nil
  22861. m.addtotal_tokens = nil
  22862. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  22863. }
  22864. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  22865. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  22866. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  22867. return ok
  22868. }
  22869. // ResetTotalTokens resets all changes to the "total_tokens" field.
  22870. func (m *UsageDetailMutation) ResetTotalTokens() {
  22871. m.total_tokens = nil
  22872. m.addtotal_tokens = nil
  22873. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  22874. }
  22875. // SetPromptTokens sets the "prompt_tokens" field.
  22876. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  22877. m.prompt_tokens = &u
  22878. m.addprompt_tokens = nil
  22879. }
  22880. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  22881. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  22882. v := m.prompt_tokens
  22883. if v == nil {
  22884. return
  22885. }
  22886. return *v, true
  22887. }
  22888. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  22889. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22891. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  22892. if !m.op.Is(OpUpdateOne) {
  22893. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  22894. }
  22895. if m.id == nil || m.oldValue == nil {
  22896. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  22897. }
  22898. oldValue, err := m.oldValue(ctx)
  22899. if err != nil {
  22900. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  22901. }
  22902. return oldValue.PromptTokens, nil
  22903. }
  22904. // AddPromptTokens adds u to the "prompt_tokens" field.
  22905. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  22906. if m.addprompt_tokens != nil {
  22907. *m.addprompt_tokens += u
  22908. } else {
  22909. m.addprompt_tokens = &u
  22910. }
  22911. }
  22912. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  22913. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  22914. v := m.addprompt_tokens
  22915. if v == nil {
  22916. return
  22917. }
  22918. return *v, true
  22919. }
  22920. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  22921. func (m *UsageDetailMutation) ClearPromptTokens() {
  22922. m.prompt_tokens = nil
  22923. m.addprompt_tokens = nil
  22924. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  22925. }
  22926. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  22927. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  22928. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  22929. return ok
  22930. }
  22931. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  22932. func (m *UsageDetailMutation) ResetPromptTokens() {
  22933. m.prompt_tokens = nil
  22934. m.addprompt_tokens = nil
  22935. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  22936. }
  22937. // SetCompletionTokens sets the "completion_tokens" field.
  22938. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  22939. m.completion_tokens = &u
  22940. m.addcompletion_tokens = nil
  22941. }
  22942. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  22943. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  22944. v := m.completion_tokens
  22945. if v == nil {
  22946. return
  22947. }
  22948. return *v, true
  22949. }
  22950. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  22951. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22953. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  22954. if !m.op.Is(OpUpdateOne) {
  22955. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  22956. }
  22957. if m.id == nil || m.oldValue == nil {
  22958. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  22959. }
  22960. oldValue, err := m.oldValue(ctx)
  22961. if err != nil {
  22962. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  22963. }
  22964. return oldValue.CompletionTokens, nil
  22965. }
  22966. // AddCompletionTokens adds u to the "completion_tokens" field.
  22967. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  22968. if m.addcompletion_tokens != nil {
  22969. *m.addcompletion_tokens += u
  22970. } else {
  22971. m.addcompletion_tokens = &u
  22972. }
  22973. }
  22974. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  22975. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  22976. v := m.addcompletion_tokens
  22977. if v == nil {
  22978. return
  22979. }
  22980. return *v, true
  22981. }
  22982. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  22983. func (m *UsageDetailMutation) ClearCompletionTokens() {
  22984. m.completion_tokens = nil
  22985. m.addcompletion_tokens = nil
  22986. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  22987. }
  22988. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  22989. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  22990. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  22991. return ok
  22992. }
  22993. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  22994. func (m *UsageDetailMutation) ResetCompletionTokens() {
  22995. m.completion_tokens = nil
  22996. m.addcompletion_tokens = nil
  22997. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  22998. }
  22999. // SetOrganizationID sets the "organization_id" field.
  23000. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  23001. m.organization_id = &u
  23002. m.addorganization_id = nil
  23003. }
  23004. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23005. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  23006. v := m.organization_id
  23007. if v == nil {
  23008. return
  23009. }
  23010. return *v, true
  23011. }
  23012. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  23013. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23015. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23016. if !m.op.Is(OpUpdateOne) {
  23017. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23018. }
  23019. if m.id == nil || m.oldValue == nil {
  23020. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23021. }
  23022. oldValue, err := m.oldValue(ctx)
  23023. if err != nil {
  23024. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23025. }
  23026. return oldValue.OrganizationID, nil
  23027. }
  23028. // AddOrganizationID adds u to the "organization_id" field.
  23029. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  23030. if m.addorganization_id != nil {
  23031. *m.addorganization_id += u
  23032. } else {
  23033. m.addorganization_id = &u
  23034. }
  23035. }
  23036. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23037. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  23038. v := m.addorganization_id
  23039. if v == nil {
  23040. return
  23041. }
  23042. return *v, true
  23043. }
  23044. // ClearOrganizationID clears the value of the "organization_id" field.
  23045. func (m *UsageDetailMutation) ClearOrganizationID() {
  23046. m.organization_id = nil
  23047. m.addorganization_id = nil
  23048. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  23049. }
  23050. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23051. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  23052. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  23053. return ok
  23054. }
  23055. // ResetOrganizationID resets all changes to the "organization_id" field.
  23056. func (m *UsageDetailMutation) ResetOrganizationID() {
  23057. m.organization_id = nil
  23058. m.addorganization_id = nil
  23059. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  23060. }
  23061. // Where appends a list predicates to the UsageDetailMutation builder.
  23062. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  23063. m.predicates = append(m.predicates, ps...)
  23064. }
  23065. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  23066. // users can use type-assertion to append predicates that do not depend on any generated package.
  23067. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  23068. p := make([]predicate.UsageDetail, len(ps))
  23069. for i := range ps {
  23070. p[i] = ps[i]
  23071. }
  23072. m.Where(p...)
  23073. }
  23074. // Op returns the operation name.
  23075. func (m *UsageDetailMutation) Op() Op {
  23076. return m.op
  23077. }
  23078. // SetOp allows setting the mutation operation.
  23079. func (m *UsageDetailMutation) SetOp(op Op) {
  23080. m.op = op
  23081. }
  23082. // Type returns the node type of this mutation (UsageDetail).
  23083. func (m *UsageDetailMutation) Type() string {
  23084. return m.typ
  23085. }
  23086. // Fields returns all fields that were changed during this mutation. Note that in
  23087. // order to get all numeric fields that were incremented/decremented, call
  23088. // AddedFields().
  23089. func (m *UsageDetailMutation) Fields() []string {
  23090. fields := make([]string, 0, 14)
  23091. if m.created_at != nil {
  23092. fields = append(fields, usagedetail.FieldCreatedAt)
  23093. }
  23094. if m.updated_at != nil {
  23095. fields = append(fields, usagedetail.FieldUpdatedAt)
  23096. }
  23097. if m.status != nil {
  23098. fields = append(fields, usagedetail.FieldStatus)
  23099. }
  23100. if m._type != nil {
  23101. fields = append(fields, usagedetail.FieldType)
  23102. }
  23103. if m.bot_id != nil {
  23104. fields = append(fields, usagedetail.FieldBotID)
  23105. }
  23106. if m.receiver_id != nil {
  23107. fields = append(fields, usagedetail.FieldReceiverID)
  23108. }
  23109. if m.app != nil {
  23110. fields = append(fields, usagedetail.FieldApp)
  23111. }
  23112. if m.session_id != nil {
  23113. fields = append(fields, usagedetail.FieldSessionID)
  23114. }
  23115. if m.request != nil {
  23116. fields = append(fields, usagedetail.FieldRequest)
  23117. }
  23118. if m.response != nil {
  23119. fields = append(fields, usagedetail.FieldResponse)
  23120. }
  23121. if m.total_tokens != nil {
  23122. fields = append(fields, usagedetail.FieldTotalTokens)
  23123. }
  23124. if m.prompt_tokens != nil {
  23125. fields = append(fields, usagedetail.FieldPromptTokens)
  23126. }
  23127. if m.completion_tokens != nil {
  23128. fields = append(fields, usagedetail.FieldCompletionTokens)
  23129. }
  23130. if m.organization_id != nil {
  23131. fields = append(fields, usagedetail.FieldOrganizationID)
  23132. }
  23133. return fields
  23134. }
  23135. // Field returns the value of a field with the given name. The second boolean
  23136. // return value indicates that this field was not set, or was not defined in the
  23137. // schema.
  23138. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  23139. switch name {
  23140. case usagedetail.FieldCreatedAt:
  23141. return m.CreatedAt()
  23142. case usagedetail.FieldUpdatedAt:
  23143. return m.UpdatedAt()
  23144. case usagedetail.FieldStatus:
  23145. return m.Status()
  23146. case usagedetail.FieldType:
  23147. return m.GetType()
  23148. case usagedetail.FieldBotID:
  23149. return m.BotID()
  23150. case usagedetail.FieldReceiverID:
  23151. return m.ReceiverID()
  23152. case usagedetail.FieldApp:
  23153. return m.App()
  23154. case usagedetail.FieldSessionID:
  23155. return m.SessionID()
  23156. case usagedetail.FieldRequest:
  23157. return m.Request()
  23158. case usagedetail.FieldResponse:
  23159. return m.Response()
  23160. case usagedetail.FieldTotalTokens:
  23161. return m.TotalTokens()
  23162. case usagedetail.FieldPromptTokens:
  23163. return m.PromptTokens()
  23164. case usagedetail.FieldCompletionTokens:
  23165. return m.CompletionTokens()
  23166. case usagedetail.FieldOrganizationID:
  23167. return m.OrganizationID()
  23168. }
  23169. return nil, false
  23170. }
  23171. // OldField returns the old value of the field from the database. An error is
  23172. // returned if the mutation operation is not UpdateOne, or the query to the
  23173. // database failed.
  23174. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23175. switch name {
  23176. case usagedetail.FieldCreatedAt:
  23177. return m.OldCreatedAt(ctx)
  23178. case usagedetail.FieldUpdatedAt:
  23179. return m.OldUpdatedAt(ctx)
  23180. case usagedetail.FieldStatus:
  23181. return m.OldStatus(ctx)
  23182. case usagedetail.FieldType:
  23183. return m.OldType(ctx)
  23184. case usagedetail.FieldBotID:
  23185. return m.OldBotID(ctx)
  23186. case usagedetail.FieldReceiverID:
  23187. return m.OldReceiverID(ctx)
  23188. case usagedetail.FieldApp:
  23189. return m.OldApp(ctx)
  23190. case usagedetail.FieldSessionID:
  23191. return m.OldSessionID(ctx)
  23192. case usagedetail.FieldRequest:
  23193. return m.OldRequest(ctx)
  23194. case usagedetail.FieldResponse:
  23195. return m.OldResponse(ctx)
  23196. case usagedetail.FieldTotalTokens:
  23197. return m.OldTotalTokens(ctx)
  23198. case usagedetail.FieldPromptTokens:
  23199. return m.OldPromptTokens(ctx)
  23200. case usagedetail.FieldCompletionTokens:
  23201. return m.OldCompletionTokens(ctx)
  23202. case usagedetail.FieldOrganizationID:
  23203. return m.OldOrganizationID(ctx)
  23204. }
  23205. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  23206. }
  23207. // SetField sets the value of a field with the given name. It returns an error if
  23208. // the field is not defined in the schema, or if the type mismatched the field
  23209. // type.
  23210. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  23211. switch name {
  23212. case usagedetail.FieldCreatedAt:
  23213. v, ok := value.(time.Time)
  23214. if !ok {
  23215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23216. }
  23217. m.SetCreatedAt(v)
  23218. return nil
  23219. case usagedetail.FieldUpdatedAt:
  23220. v, ok := value.(time.Time)
  23221. if !ok {
  23222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23223. }
  23224. m.SetUpdatedAt(v)
  23225. return nil
  23226. case usagedetail.FieldStatus:
  23227. v, ok := value.(uint8)
  23228. if !ok {
  23229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23230. }
  23231. m.SetStatus(v)
  23232. return nil
  23233. case usagedetail.FieldType:
  23234. v, ok := value.(int)
  23235. if !ok {
  23236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23237. }
  23238. m.SetType(v)
  23239. return nil
  23240. case usagedetail.FieldBotID:
  23241. v, ok := value.(string)
  23242. if !ok {
  23243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23244. }
  23245. m.SetBotID(v)
  23246. return nil
  23247. case usagedetail.FieldReceiverID:
  23248. v, ok := value.(string)
  23249. if !ok {
  23250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23251. }
  23252. m.SetReceiverID(v)
  23253. return nil
  23254. case usagedetail.FieldApp:
  23255. v, ok := value.(int)
  23256. if !ok {
  23257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23258. }
  23259. m.SetApp(v)
  23260. return nil
  23261. case usagedetail.FieldSessionID:
  23262. v, ok := value.(uint64)
  23263. if !ok {
  23264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23265. }
  23266. m.SetSessionID(v)
  23267. return nil
  23268. case usagedetail.FieldRequest:
  23269. v, ok := value.(string)
  23270. if !ok {
  23271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23272. }
  23273. m.SetRequest(v)
  23274. return nil
  23275. case usagedetail.FieldResponse:
  23276. v, ok := value.(string)
  23277. if !ok {
  23278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23279. }
  23280. m.SetResponse(v)
  23281. return nil
  23282. case usagedetail.FieldTotalTokens:
  23283. v, ok := value.(uint64)
  23284. if !ok {
  23285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23286. }
  23287. m.SetTotalTokens(v)
  23288. return nil
  23289. case usagedetail.FieldPromptTokens:
  23290. v, ok := value.(uint64)
  23291. if !ok {
  23292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23293. }
  23294. m.SetPromptTokens(v)
  23295. return nil
  23296. case usagedetail.FieldCompletionTokens:
  23297. v, ok := value.(uint64)
  23298. if !ok {
  23299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23300. }
  23301. m.SetCompletionTokens(v)
  23302. return nil
  23303. case usagedetail.FieldOrganizationID:
  23304. v, ok := value.(uint64)
  23305. if !ok {
  23306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23307. }
  23308. m.SetOrganizationID(v)
  23309. return nil
  23310. }
  23311. return fmt.Errorf("unknown UsageDetail field %s", name)
  23312. }
  23313. // AddedFields returns all numeric fields that were incremented/decremented during
  23314. // this mutation.
  23315. func (m *UsageDetailMutation) AddedFields() []string {
  23316. var fields []string
  23317. if m.addstatus != nil {
  23318. fields = append(fields, usagedetail.FieldStatus)
  23319. }
  23320. if m.add_type != nil {
  23321. fields = append(fields, usagedetail.FieldType)
  23322. }
  23323. if m.addapp != nil {
  23324. fields = append(fields, usagedetail.FieldApp)
  23325. }
  23326. if m.addsession_id != nil {
  23327. fields = append(fields, usagedetail.FieldSessionID)
  23328. }
  23329. if m.addtotal_tokens != nil {
  23330. fields = append(fields, usagedetail.FieldTotalTokens)
  23331. }
  23332. if m.addprompt_tokens != nil {
  23333. fields = append(fields, usagedetail.FieldPromptTokens)
  23334. }
  23335. if m.addcompletion_tokens != nil {
  23336. fields = append(fields, usagedetail.FieldCompletionTokens)
  23337. }
  23338. if m.addorganization_id != nil {
  23339. fields = append(fields, usagedetail.FieldOrganizationID)
  23340. }
  23341. return fields
  23342. }
  23343. // AddedField returns the numeric value that was incremented/decremented on a field
  23344. // with the given name. The second boolean return value indicates that this field
  23345. // was not set, or was not defined in the schema.
  23346. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  23347. switch name {
  23348. case usagedetail.FieldStatus:
  23349. return m.AddedStatus()
  23350. case usagedetail.FieldType:
  23351. return m.AddedType()
  23352. case usagedetail.FieldApp:
  23353. return m.AddedApp()
  23354. case usagedetail.FieldSessionID:
  23355. return m.AddedSessionID()
  23356. case usagedetail.FieldTotalTokens:
  23357. return m.AddedTotalTokens()
  23358. case usagedetail.FieldPromptTokens:
  23359. return m.AddedPromptTokens()
  23360. case usagedetail.FieldCompletionTokens:
  23361. return m.AddedCompletionTokens()
  23362. case usagedetail.FieldOrganizationID:
  23363. return m.AddedOrganizationID()
  23364. }
  23365. return nil, false
  23366. }
  23367. // AddField adds the value to the field with the given name. It returns an error if
  23368. // the field is not defined in the schema, or if the type mismatched the field
  23369. // type.
  23370. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  23371. switch name {
  23372. case usagedetail.FieldStatus:
  23373. v, ok := value.(int8)
  23374. if !ok {
  23375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23376. }
  23377. m.AddStatus(v)
  23378. return nil
  23379. case usagedetail.FieldType:
  23380. v, ok := value.(int)
  23381. if !ok {
  23382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23383. }
  23384. m.AddType(v)
  23385. return nil
  23386. case usagedetail.FieldApp:
  23387. v, ok := value.(int)
  23388. if !ok {
  23389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23390. }
  23391. m.AddApp(v)
  23392. return nil
  23393. case usagedetail.FieldSessionID:
  23394. v, ok := value.(int64)
  23395. if !ok {
  23396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23397. }
  23398. m.AddSessionID(v)
  23399. return nil
  23400. case usagedetail.FieldTotalTokens:
  23401. v, ok := value.(int64)
  23402. if !ok {
  23403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23404. }
  23405. m.AddTotalTokens(v)
  23406. return nil
  23407. case usagedetail.FieldPromptTokens:
  23408. v, ok := value.(int64)
  23409. if !ok {
  23410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23411. }
  23412. m.AddPromptTokens(v)
  23413. return nil
  23414. case usagedetail.FieldCompletionTokens:
  23415. v, ok := value.(int64)
  23416. if !ok {
  23417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23418. }
  23419. m.AddCompletionTokens(v)
  23420. return nil
  23421. case usagedetail.FieldOrganizationID:
  23422. v, ok := value.(int64)
  23423. if !ok {
  23424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23425. }
  23426. m.AddOrganizationID(v)
  23427. return nil
  23428. }
  23429. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  23430. }
  23431. // ClearedFields returns all nullable fields that were cleared during this
  23432. // mutation.
  23433. func (m *UsageDetailMutation) ClearedFields() []string {
  23434. var fields []string
  23435. if m.FieldCleared(usagedetail.FieldStatus) {
  23436. fields = append(fields, usagedetail.FieldStatus)
  23437. }
  23438. if m.FieldCleared(usagedetail.FieldType) {
  23439. fields = append(fields, usagedetail.FieldType)
  23440. }
  23441. if m.FieldCleared(usagedetail.FieldApp) {
  23442. fields = append(fields, usagedetail.FieldApp)
  23443. }
  23444. if m.FieldCleared(usagedetail.FieldSessionID) {
  23445. fields = append(fields, usagedetail.FieldSessionID)
  23446. }
  23447. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  23448. fields = append(fields, usagedetail.FieldTotalTokens)
  23449. }
  23450. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  23451. fields = append(fields, usagedetail.FieldPromptTokens)
  23452. }
  23453. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  23454. fields = append(fields, usagedetail.FieldCompletionTokens)
  23455. }
  23456. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  23457. fields = append(fields, usagedetail.FieldOrganizationID)
  23458. }
  23459. return fields
  23460. }
  23461. // FieldCleared returns a boolean indicating if a field with the given name was
  23462. // cleared in this mutation.
  23463. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  23464. _, ok := m.clearedFields[name]
  23465. return ok
  23466. }
  23467. // ClearField clears the value of the field with the given name. It returns an
  23468. // error if the field is not defined in the schema.
  23469. func (m *UsageDetailMutation) ClearField(name string) error {
  23470. switch name {
  23471. case usagedetail.FieldStatus:
  23472. m.ClearStatus()
  23473. return nil
  23474. case usagedetail.FieldType:
  23475. m.ClearType()
  23476. return nil
  23477. case usagedetail.FieldApp:
  23478. m.ClearApp()
  23479. return nil
  23480. case usagedetail.FieldSessionID:
  23481. m.ClearSessionID()
  23482. return nil
  23483. case usagedetail.FieldTotalTokens:
  23484. m.ClearTotalTokens()
  23485. return nil
  23486. case usagedetail.FieldPromptTokens:
  23487. m.ClearPromptTokens()
  23488. return nil
  23489. case usagedetail.FieldCompletionTokens:
  23490. m.ClearCompletionTokens()
  23491. return nil
  23492. case usagedetail.FieldOrganizationID:
  23493. m.ClearOrganizationID()
  23494. return nil
  23495. }
  23496. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  23497. }
  23498. // ResetField resets all changes in the mutation for the field with the given name.
  23499. // It returns an error if the field is not defined in the schema.
  23500. func (m *UsageDetailMutation) ResetField(name string) error {
  23501. switch name {
  23502. case usagedetail.FieldCreatedAt:
  23503. m.ResetCreatedAt()
  23504. return nil
  23505. case usagedetail.FieldUpdatedAt:
  23506. m.ResetUpdatedAt()
  23507. return nil
  23508. case usagedetail.FieldStatus:
  23509. m.ResetStatus()
  23510. return nil
  23511. case usagedetail.FieldType:
  23512. m.ResetType()
  23513. return nil
  23514. case usagedetail.FieldBotID:
  23515. m.ResetBotID()
  23516. return nil
  23517. case usagedetail.FieldReceiverID:
  23518. m.ResetReceiverID()
  23519. return nil
  23520. case usagedetail.FieldApp:
  23521. m.ResetApp()
  23522. return nil
  23523. case usagedetail.FieldSessionID:
  23524. m.ResetSessionID()
  23525. return nil
  23526. case usagedetail.FieldRequest:
  23527. m.ResetRequest()
  23528. return nil
  23529. case usagedetail.FieldResponse:
  23530. m.ResetResponse()
  23531. return nil
  23532. case usagedetail.FieldTotalTokens:
  23533. m.ResetTotalTokens()
  23534. return nil
  23535. case usagedetail.FieldPromptTokens:
  23536. m.ResetPromptTokens()
  23537. return nil
  23538. case usagedetail.FieldCompletionTokens:
  23539. m.ResetCompletionTokens()
  23540. return nil
  23541. case usagedetail.FieldOrganizationID:
  23542. m.ResetOrganizationID()
  23543. return nil
  23544. }
  23545. return fmt.Errorf("unknown UsageDetail field %s", name)
  23546. }
  23547. // AddedEdges returns all edge names that were set/added in this mutation.
  23548. func (m *UsageDetailMutation) AddedEdges() []string {
  23549. edges := make([]string, 0, 0)
  23550. return edges
  23551. }
  23552. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23553. // name in this mutation.
  23554. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  23555. return nil
  23556. }
  23557. // RemovedEdges returns all edge names that were removed in this mutation.
  23558. func (m *UsageDetailMutation) RemovedEdges() []string {
  23559. edges := make([]string, 0, 0)
  23560. return edges
  23561. }
  23562. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23563. // the given name in this mutation.
  23564. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  23565. return nil
  23566. }
  23567. // ClearedEdges returns all edge names that were cleared in this mutation.
  23568. func (m *UsageDetailMutation) ClearedEdges() []string {
  23569. edges := make([]string, 0, 0)
  23570. return edges
  23571. }
  23572. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23573. // was cleared in this mutation.
  23574. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  23575. return false
  23576. }
  23577. // ClearEdge clears the value of the edge with the given name. It returns an error
  23578. // if that edge is not defined in the schema.
  23579. func (m *UsageDetailMutation) ClearEdge(name string) error {
  23580. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  23581. }
  23582. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23583. // It returns an error if the edge is not defined in the schema.
  23584. func (m *UsageDetailMutation) ResetEdge(name string) error {
  23585. return fmt.Errorf("unknown UsageDetail edge %s", name)
  23586. }
  23587. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  23588. type UsageStatisticDayMutation struct {
  23589. config
  23590. op Op
  23591. typ string
  23592. id *uint64
  23593. created_at *time.Time
  23594. updated_at *time.Time
  23595. status *uint8
  23596. addstatus *int8
  23597. deleted_at *time.Time
  23598. addtime *uint64
  23599. addaddtime *int64
  23600. _type *int
  23601. add_type *int
  23602. bot_id *string
  23603. organization_id *uint64
  23604. addorganization_id *int64
  23605. ai_response *uint64
  23606. addai_response *int64
  23607. sop_run *uint64
  23608. addsop_run *int64
  23609. total_friend *uint64
  23610. addtotal_friend *int64
  23611. total_group *uint64
  23612. addtotal_group *int64
  23613. account_balance *uint64
  23614. addaccount_balance *int64
  23615. consume_token *uint64
  23616. addconsume_token *int64
  23617. active_user *uint64
  23618. addactive_user *int64
  23619. new_user *int64
  23620. addnew_user *int64
  23621. label_dist *[]custom_types.LabelDist
  23622. appendlabel_dist []custom_types.LabelDist
  23623. clearedFields map[string]struct{}
  23624. done bool
  23625. oldValue func(context.Context) (*UsageStatisticDay, error)
  23626. predicates []predicate.UsageStatisticDay
  23627. }
  23628. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  23629. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  23630. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  23631. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  23632. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  23633. m := &UsageStatisticDayMutation{
  23634. config: c,
  23635. op: op,
  23636. typ: TypeUsageStatisticDay,
  23637. clearedFields: make(map[string]struct{}),
  23638. }
  23639. for _, opt := range opts {
  23640. opt(m)
  23641. }
  23642. return m
  23643. }
  23644. // withUsageStatisticDayID sets the ID field of the mutation.
  23645. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  23646. return func(m *UsageStatisticDayMutation) {
  23647. var (
  23648. err error
  23649. once sync.Once
  23650. value *UsageStatisticDay
  23651. )
  23652. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  23653. once.Do(func() {
  23654. if m.done {
  23655. err = errors.New("querying old values post mutation is not allowed")
  23656. } else {
  23657. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  23658. }
  23659. })
  23660. return value, err
  23661. }
  23662. m.id = &id
  23663. }
  23664. }
  23665. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  23666. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  23667. return func(m *UsageStatisticDayMutation) {
  23668. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  23669. return node, nil
  23670. }
  23671. m.id = &node.ID
  23672. }
  23673. }
  23674. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23675. // executed in a transaction (ent.Tx), a transactional client is returned.
  23676. func (m UsageStatisticDayMutation) Client() *Client {
  23677. client := &Client{config: m.config}
  23678. client.init()
  23679. return client
  23680. }
  23681. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23682. // it returns an error otherwise.
  23683. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  23684. if _, ok := m.driver.(*txDriver); !ok {
  23685. return nil, errors.New("ent: mutation is not running in a transaction")
  23686. }
  23687. tx := &Tx{config: m.config}
  23688. tx.init()
  23689. return tx, nil
  23690. }
  23691. // SetID sets the value of the id field. Note that this
  23692. // operation is only accepted on creation of UsageStatisticDay entities.
  23693. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  23694. m.id = &id
  23695. }
  23696. // ID returns the ID value in the mutation. Note that the ID is only available
  23697. // if it was provided to the builder or after it was returned from the database.
  23698. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  23699. if m.id == nil {
  23700. return
  23701. }
  23702. return *m.id, true
  23703. }
  23704. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23705. // That means, if the mutation is applied within a transaction with an isolation level such
  23706. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23707. // or updated by the mutation.
  23708. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  23709. switch {
  23710. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23711. id, exists := m.ID()
  23712. if exists {
  23713. return []uint64{id}, nil
  23714. }
  23715. fallthrough
  23716. case m.op.Is(OpUpdate | OpDelete):
  23717. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  23718. default:
  23719. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23720. }
  23721. }
  23722. // SetCreatedAt sets the "created_at" field.
  23723. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  23724. m.created_at = &t
  23725. }
  23726. // CreatedAt returns the value of the "created_at" field in the mutation.
  23727. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  23728. v := m.created_at
  23729. if v == nil {
  23730. return
  23731. }
  23732. return *v, true
  23733. }
  23734. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  23735. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  23736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23737. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23738. if !m.op.Is(OpUpdateOne) {
  23739. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23740. }
  23741. if m.id == nil || m.oldValue == nil {
  23742. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23743. }
  23744. oldValue, err := m.oldValue(ctx)
  23745. if err != nil {
  23746. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23747. }
  23748. return oldValue.CreatedAt, nil
  23749. }
  23750. // ResetCreatedAt resets all changes to the "created_at" field.
  23751. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  23752. m.created_at = nil
  23753. }
  23754. // SetUpdatedAt sets the "updated_at" field.
  23755. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  23756. m.updated_at = &t
  23757. }
  23758. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23759. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  23760. v := m.updated_at
  23761. if v == nil {
  23762. return
  23763. }
  23764. return *v, true
  23765. }
  23766. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  23767. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  23768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23769. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23770. if !m.op.Is(OpUpdateOne) {
  23771. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23772. }
  23773. if m.id == nil || m.oldValue == nil {
  23774. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23775. }
  23776. oldValue, err := m.oldValue(ctx)
  23777. if err != nil {
  23778. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23779. }
  23780. return oldValue.UpdatedAt, nil
  23781. }
  23782. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23783. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  23784. m.updated_at = nil
  23785. }
  23786. // SetStatus sets the "status" field.
  23787. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  23788. m.status = &u
  23789. m.addstatus = nil
  23790. }
  23791. // Status returns the value of the "status" field in the mutation.
  23792. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  23793. v := m.status
  23794. if v == nil {
  23795. return
  23796. }
  23797. return *v, true
  23798. }
  23799. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  23800. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  23801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23802. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23803. if !m.op.Is(OpUpdateOne) {
  23804. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23805. }
  23806. if m.id == nil || m.oldValue == nil {
  23807. return v, errors.New("OldStatus requires an ID field in the mutation")
  23808. }
  23809. oldValue, err := m.oldValue(ctx)
  23810. if err != nil {
  23811. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23812. }
  23813. return oldValue.Status, nil
  23814. }
  23815. // AddStatus adds u to the "status" field.
  23816. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  23817. if m.addstatus != nil {
  23818. *m.addstatus += u
  23819. } else {
  23820. m.addstatus = &u
  23821. }
  23822. }
  23823. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23824. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  23825. v := m.addstatus
  23826. if v == nil {
  23827. return
  23828. }
  23829. return *v, true
  23830. }
  23831. // ClearStatus clears the value of the "status" field.
  23832. func (m *UsageStatisticDayMutation) ClearStatus() {
  23833. m.status = nil
  23834. m.addstatus = nil
  23835. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  23836. }
  23837. // StatusCleared returns if the "status" field was cleared in this mutation.
  23838. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  23839. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  23840. return ok
  23841. }
  23842. // ResetStatus resets all changes to the "status" field.
  23843. func (m *UsageStatisticDayMutation) ResetStatus() {
  23844. m.status = nil
  23845. m.addstatus = nil
  23846. delete(m.clearedFields, usagestatisticday.FieldStatus)
  23847. }
  23848. // SetDeletedAt sets the "deleted_at" field.
  23849. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  23850. m.deleted_at = &t
  23851. }
  23852. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23853. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  23854. v := m.deleted_at
  23855. if v == nil {
  23856. return
  23857. }
  23858. return *v, true
  23859. }
  23860. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  23861. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  23862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23863. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23864. if !m.op.Is(OpUpdateOne) {
  23865. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23866. }
  23867. if m.id == nil || m.oldValue == nil {
  23868. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23869. }
  23870. oldValue, err := m.oldValue(ctx)
  23871. if err != nil {
  23872. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23873. }
  23874. return oldValue.DeletedAt, nil
  23875. }
  23876. // ClearDeletedAt clears the value of the "deleted_at" field.
  23877. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  23878. m.deleted_at = nil
  23879. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  23880. }
  23881. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23882. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  23883. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  23884. return ok
  23885. }
  23886. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23887. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  23888. m.deleted_at = nil
  23889. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  23890. }
  23891. // SetAddtime sets the "addtime" field.
  23892. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  23893. m.addtime = &u
  23894. m.addaddtime = nil
  23895. }
  23896. // Addtime returns the value of the "addtime" field in the mutation.
  23897. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  23898. v := m.addtime
  23899. if v == nil {
  23900. return
  23901. }
  23902. return *v, true
  23903. }
  23904. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  23905. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  23906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23907. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  23908. if !m.op.Is(OpUpdateOne) {
  23909. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  23910. }
  23911. if m.id == nil || m.oldValue == nil {
  23912. return v, errors.New("OldAddtime requires an ID field in the mutation")
  23913. }
  23914. oldValue, err := m.oldValue(ctx)
  23915. if err != nil {
  23916. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  23917. }
  23918. return oldValue.Addtime, nil
  23919. }
  23920. // AddAddtime adds u to the "addtime" field.
  23921. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  23922. if m.addaddtime != nil {
  23923. *m.addaddtime += u
  23924. } else {
  23925. m.addaddtime = &u
  23926. }
  23927. }
  23928. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  23929. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  23930. v := m.addaddtime
  23931. if v == nil {
  23932. return
  23933. }
  23934. return *v, true
  23935. }
  23936. // ResetAddtime resets all changes to the "addtime" field.
  23937. func (m *UsageStatisticDayMutation) ResetAddtime() {
  23938. m.addtime = nil
  23939. m.addaddtime = nil
  23940. }
  23941. // SetType sets the "type" field.
  23942. func (m *UsageStatisticDayMutation) SetType(i int) {
  23943. m._type = &i
  23944. m.add_type = nil
  23945. }
  23946. // GetType returns the value of the "type" field in the mutation.
  23947. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  23948. v := m._type
  23949. if v == nil {
  23950. return
  23951. }
  23952. return *v, true
  23953. }
  23954. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  23955. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  23956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23957. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  23958. if !m.op.Is(OpUpdateOne) {
  23959. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23960. }
  23961. if m.id == nil || m.oldValue == nil {
  23962. return v, errors.New("OldType requires an ID field in the mutation")
  23963. }
  23964. oldValue, err := m.oldValue(ctx)
  23965. if err != nil {
  23966. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23967. }
  23968. return oldValue.Type, nil
  23969. }
  23970. // AddType adds i to the "type" field.
  23971. func (m *UsageStatisticDayMutation) AddType(i int) {
  23972. if m.add_type != nil {
  23973. *m.add_type += i
  23974. } else {
  23975. m.add_type = &i
  23976. }
  23977. }
  23978. // AddedType returns the value that was added to the "type" field in this mutation.
  23979. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  23980. v := m.add_type
  23981. if v == nil {
  23982. return
  23983. }
  23984. return *v, true
  23985. }
  23986. // ResetType resets all changes to the "type" field.
  23987. func (m *UsageStatisticDayMutation) ResetType() {
  23988. m._type = nil
  23989. m.add_type = nil
  23990. }
  23991. // SetBotID sets the "bot_id" field.
  23992. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  23993. m.bot_id = &s
  23994. }
  23995. // BotID returns the value of the "bot_id" field in the mutation.
  23996. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  23997. v := m.bot_id
  23998. if v == nil {
  23999. return
  24000. }
  24001. return *v, true
  24002. }
  24003. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  24004. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24006. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  24007. if !m.op.Is(OpUpdateOne) {
  24008. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  24009. }
  24010. if m.id == nil || m.oldValue == nil {
  24011. return v, errors.New("OldBotID requires an ID field in the mutation")
  24012. }
  24013. oldValue, err := m.oldValue(ctx)
  24014. if err != nil {
  24015. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  24016. }
  24017. return oldValue.BotID, nil
  24018. }
  24019. // ClearBotID clears the value of the "bot_id" field.
  24020. func (m *UsageStatisticDayMutation) ClearBotID() {
  24021. m.bot_id = nil
  24022. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  24023. }
  24024. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  24025. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  24026. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  24027. return ok
  24028. }
  24029. // ResetBotID resets all changes to the "bot_id" field.
  24030. func (m *UsageStatisticDayMutation) ResetBotID() {
  24031. m.bot_id = nil
  24032. delete(m.clearedFields, usagestatisticday.FieldBotID)
  24033. }
  24034. // SetOrganizationID sets the "organization_id" field.
  24035. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  24036. m.organization_id = &u
  24037. m.addorganization_id = nil
  24038. }
  24039. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24040. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  24041. v := m.organization_id
  24042. if v == nil {
  24043. return
  24044. }
  24045. return *v, true
  24046. }
  24047. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  24048. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24050. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24051. if !m.op.Is(OpUpdateOne) {
  24052. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24053. }
  24054. if m.id == nil || m.oldValue == nil {
  24055. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24056. }
  24057. oldValue, err := m.oldValue(ctx)
  24058. if err != nil {
  24059. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24060. }
  24061. return oldValue.OrganizationID, nil
  24062. }
  24063. // AddOrganizationID adds u to the "organization_id" field.
  24064. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  24065. if m.addorganization_id != nil {
  24066. *m.addorganization_id += u
  24067. } else {
  24068. m.addorganization_id = &u
  24069. }
  24070. }
  24071. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24072. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  24073. v := m.addorganization_id
  24074. if v == nil {
  24075. return
  24076. }
  24077. return *v, true
  24078. }
  24079. // ClearOrganizationID clears the value of the "organization_id" field.
  24080. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  24081. m.organization_id = nil
  24082. m.addorganization_id = nil
  24083. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  24084. }
  24085. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24086. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  24087. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  24088. return ok
  24089. }
  24090. // ResetOrganizationID resets all changes to the "organization_id" field.
  24091. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  24092. m.organization_id = nil
  24093. m.addorganization_id = nil
  24094. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  24095. }
  24096. // SetAiResponse sets the "ai_response" field.
  24097. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  24098. m.ai_response = &u
  24099. m.addai_response = nil
  24100. }
  24101. // AiResponse returns the value of the "ai_response" field in the mutation.
  24102. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  24103. v := m.ai_response
  24104. if v == nil {
  24105. return
  24106. }
  24107. return *v, true
  24108. }
  24109. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  24110. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24112. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  24113. if !m.op.Is(OpUpdateOne) {
  24114. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  24115. }
  24116. if m.id == nil || m.oldValue == nil {
  24117. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  24118. }
  24119. oldValue, err := m.oldValue(ctx)
  24120. if err != nil {
  24121. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  24122. }
  24123. return oldValue.AiResponse, nil
  24124. }
  24125. // AddAiResponse adds u to the "ai_response" field.
  24126. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  24127. if m.addai_response != nil {
  24128. *m.addai_response += u
  24129. } else {
  24130. m.addai_response = &u
  24131. }
  24132. }
  24133. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  24134. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  24135. v := m.addai_response
  24136. if v == nil {
  24137. return
  24138. }
  24139. return *v, true
  24140. }
  24141. // ResetAiResponse resets all changes to the "ai_response" field.
  24142. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  24143. m.ai_response = nil
  24144. m.addai_response = nil
  24145. }
  24146. // SetSopRun sets the "sop_run" field.
  24147. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  24148. m.sop_run = &u
  24149. m.addsop_run = nil
  24150. }
  24151. // SopRun returns the value of the "sop_run" field in the mutation.
  24152. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  24153. v := m.sop_run
  24154. if v == nil {
  24155. return
  24156. }
  24157. return *v, true
  24158. }
  24159. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  24160. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24162. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  24163. if !m.op.Is(OpUpdateOne) {
  24164. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  24165. }
  24166. if m.id == nil || m.oldValue == nil {
  24167. return v, errors.New("OldSopRun requires an ID field in the mutation")
  24168. }
  24169. oldValue, err := m.oldValue(ctx)
  24170. if err != nil {
  24171. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  24172. }
  24173. return oldValue.SopRun, nil
  24174. }
  24175. // AddSopRun adds u to the "sop_run" field.
  24176. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  24177. if m.addsop_run != nil {
  24178. *m.addsop_run += u
  24179. } else {
  24180. m.addsop_run = &u
  24181. }
  24182. }
  24183. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  24184. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  24185. v := m.addsop_run
  24186. if v == nil {
  24187. return
  24188. }
  24189. return *v, true
  24190. }
  24191. // ResetSopRun resets all changes to the "sop_run" field.
  24192. func (m *UsageStatisticDayMutation) ResetSopRun() {
  24193. m.sop_run = nil
  24194. m.addsop_run = nil
  24195. }
  24196. // SetTotalFriend sets the "total_friend" field.
  24197. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  24198. m.total_friend = &u
  24199. m.addtotal_friend = nil
  24200. }
  24201. // TotalFriend returns the value of the "total_friend" field in the mutation.
  24202. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  24203. v := m.total_friend
  24204. if v == nil {
  24205. return
  24206. }
  24207. return *v, true
  24208. }
  24209. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  24210. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24212. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  24213. if !m.op.Is(OpUpdateOne) {
  24214. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  24215. }
  24216. if m.id == nil || m.oldValue == nil {
  24217. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  24218. }
  24219. oldValue, err := m.oldValue(ctx)
  24220. if err != nil {
  24221. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  24222. }
  24223. return oldValue.TotalFriend, nil
  24224. }
  24225. // AddTotalFriend adds u to the "total_friend" field.
  24226. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  24227. if m.addtotal_friend != nil {
  24228. *m.addtotal_friend += u
  24229. } else {
  24230. m.addtotal_friend = &u
  24231. }
  24232. }
  24233. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  24234. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  24235. v := m.addtotal_friend
  24236. if v == nil {
  24237. return
  24238. }
  24239. return *v, true
  24240. }
  24241. // ResetTotalFriend resets all changes to the "total_friend" field.
  24242. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  24243. m.total_friend = nil
  24244. m.addtotal_friend = nil
  24245. }
  24246. // SetTotalGroup sets the "total_group" field.
  24247. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  24248. m.total_group = &u
  24249. m.addtotal_group = nil
  24250. }
  24251. // TotalGroup returns the value of the "total_group" field in the mutation.
  24252. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  24253. v := m.total_group
  24254. if v == nil {
  24255. return
  24256. }
  24257. return *v, true
  24258. }
  24259. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  24260. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24262. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  24263. if !m.op.Is(OpUpdateOne) {
  24264. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  24265. }
  24266. if m.id == nil || m.oldValue == nil {
  24267. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  24268. }
  24269. oldValue, err := m.oldValue(ctx)
  24270. if err != nil {
  24271. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  24272. }
  24273. return oldValue.TotalGroup, nil
  24274. }
  24275. // AddTotalGroup adds u to the "total_group" field.
  24276. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  24277. if m.addtotal_group != nil {
  24278. *m.addtotal_group += u
  24279. } else {
  24280. m.addtotal_group = &u
  24281. }
  24282. }
  24283. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  24284. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  24285. v := m.addtotal_group
  24286. if v == nil {
  24287. return
  24288. }
  24289. return *v, true
  24290. }
  24291. // ResetTotalGroup resets all changes to the "total_group" field.
  24292. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  24293. m.total_group = nil
  24294. m.addtotal_group = nil
  24295. }
  24296. // SetAccountBalance sets the "account_balance" field.
  24297. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  24298. m.account_balance = &u
  24299. m.addaccount_balance = nil
  24300. }
  24301. // AccountBalance returns the value of the "account_balance" field in the mutation.
  24302. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  24303. v := m.account_balance
  24304. if v == nil {
  24305. return
  24306. }
  24307. return *v, true
  24308. }
  24309. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  24310. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24312. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  24313. if !m.op.Is(OpUpdateOne) {
  24314. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  24315. }
  24316. if m.id == nil || m.oldValue == nil {
  24317. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  24318. }
  24319. oldValue, err := m.oldValue(ctx)
  24320. if err != nil {
  24321. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  24322. }
  24323. return oldValue.AccountBalance, nil
  24324. }
  24325. // AddAccountBalance adds u to the "account_balance" field.
  24326. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  24327. if m.addaccount_balance != nil {
  24328. *m.addaccount_balance += u
  24329. } else {
  24330. m.addaccount_balance = &u
  24331. }
  24332. }
  24333. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  24334. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  24335. v := m.addaccount_balance
  24336. if v == nil {
  24337. return
  24338. }
  24339. return *v, true
  24340. }
  24341. // ResetAccountBalance resets all changes to the "account_balance" field.
  24342. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  24343. m.account_balance = nil
  24344. m.addaccount_balance = nil
  24345. }
  24346. // SetConsumeToken sets the "consume_token" field.
  24347. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  24348. m.consume_token = &u
  24349. m.addconsume_token = nil
  24350. }
  24351. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  24352. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  24353. v := m.consume_token
  24354. if v == nil {
  24355. return
  24356. }
  24357. return *v, true
  24358. }
  24359. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  24360. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24362. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  24363. if !m.op.Is(OpUpdateOne) {
  24364. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  24365. }
  24366. if m.id == nil || m.oldValue == nil {
  24367. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  24368. }
  24369. oldValue, err := m.oldValue(ctx)
  24370. if err != nil {
  24371. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  24372. }
  24373. return oldValue.ConsumeToken, nil
  24374. }
  24375. // AddConsumeToken adds u to the "consume_token" field.
  24376. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  24377. if m.addconsume_token != nil {
  24378. *m.addconsume_token += u
  24379. } else {
  24380. m.addconsume_token = &u
  24381. }
  24382. }
  24383. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  24384. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  24385. v := m.addconsume_token
  24386. if v == nil {
  24387. return
  24388. }
  24389. return *v, true
  24390. }
  24391. // ResetConsumeToken resets all changes to the "consume_token" field.
  24392. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  24393. m.consume_token = nil
  24394. m.addconsume_token = nil
  24395. }
  24396. // SetActiveUser sets the "active_user" field.
  24397. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  24398. m.active_user = &u
  24399. m.addactive_user = nil
  24400. }
  24401. // ActiveUser returns the value of the "active_user" field in the mutation.
  24402. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  24403. v := m.active_user
  24404. if v == nil {
  24405. return
  24406. }
  24407. return *v, true
  24408. }
  24409. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  24410. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24412. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  24413. if !m.op.Is(OpUpdateOne) {
  24414. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  24415. }
  24416. if m.id == nil || m.oldValue == nil {
  24417. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  24418. }
  24419. oldValue, err := m.oldValue(ctx)
  24420. if err != nil {
  24421. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  24422. }
  24423. return oldValue.ActiveUser, nil
  24424. }
  24425. // AddActiveUser adds u to the "active_user" field.
  24426. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  24427. if m.addactive_user != nil {
  24428. *m.addactive_user += u
  24429. } else {
  24430. m.addactive_user = &u
  24431. }
  24432. }
  24433. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  24434. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  24435. v := m.addactive_user
  24436. if v == nil {
  24437. return
  24438. }
  24439. return *v, true
  24440. }
  24441. // ResetActiveUser resets all changes to the "active_user" field.
  24442. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  24443. m.active_user = nil
  24444. m.addactive_user = nil
  24445. }
  24446. // SetNewUser sets the "new_user" field.
  24447. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  24448. m.new_user = &i
  24449. m.addnew_user = nil
  24450. }
  24451. // NewUser returns the value of the "new_user" field in the mutation.
  24452. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  24453. v := m.new_user
  24454. if v == nil {
  24455. return
  24456. }
  24457. return *v, true
  24458. }
  24459. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  24460. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24462. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  24463. if !m.op.Is(OpUpdateOne) {
  24464. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  24465. }
  24466. if m.id == nil || m.oldValue == nil {
  24467. return v, errors.New("OldNewUser requires an ID field in the mutation")
  24468. }
  24469. oldValue, err := m.oldValue(ctx)
  24470. if err != nil {
  24471. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  24472. }
  24473. return oldValue.NewUser, nil
  24474. }
  24475. // AddNewUser adds i to the "new_user" field.
  24476. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  24477. if m.addnew_user != nil {
  24478. *m.addnew_user += i
  24479. } else {
  24480. m.addnew_user = &i
  24481. }
  24482. }
  24483. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  24484. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  24485. v := m.addnew_user
  24486. if v == nil {
  24487. return
  24488. }
  24489. return *v, true
  24490. }
  24491. // ResetNewUser resets all changes to the "new_user" field.
  24492. func (m *UsageStatisticDayMutation) ResetNewUser() {
  24493. m.new_user = nil
  24494. m.addnew_user = nil
  24495. }
  24496. // SetLabelDist sets the "label_dist" field.
  24497. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  24498. m.label_dist = &ctd
  24499. m.appendlabel_dist = nil
  24500. }
  24501. // LabelDist returns the value of the "label_dist" field in the mutation.
  24502. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  24503. v := m.label_dist
  24504. if v == nil {
  24505. return
  24506. }
  24507. return *v, true
  24508. }
  24509. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  24510. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24512. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  24513. if !m.op.Is(OpUpdateOne) {
  24514. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  24515. }
  24516. if m.id == nil || m.oldValue == nil {
  24517. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  24518. }
  24519. oldValue, err := m.oldValue(ctx)
  24520. if err != nil {
  24521. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  24522. }
  24523. return oldValue.LabelDist, nil
  24524. }
  24525. // AppendLabelDist adds ctd to the "label_dist" field.
  24526. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  24527. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  24528. }
  24529. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  24530. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  24531. if len(m.appendlabel_dist) == 0 {
  24532. return nil, false
  24533. }
  24534. return m.appendlabel_dist, true
  24535. }
  24536. // ResetLabelDist resets all changes to the "label_dist" field.
  24537. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  24538. m.label_dist = nil
  24539. m.appendlabel_dist = nil
  24540. }
  24541. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  24542. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  24543. m.predicates = append(m.predicates, ps...)
  24544. }
  24545. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  24546. // users can use type-assertion to append predicates that do not depend on any generated package.
  24547. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  24548. p := make([]predicate.UsageStatisticDay, len(ps))
  24549. for i := range ps {
  24550. p[i] = ps[i]
  24551. }
  24552. m.Where(p...)
  24553. }
  24554. // Op returns the operation name.
  24555. func (m *UsageStatisticDayMutation) Op() Op {
  24556. return m.op
  24557. }
  24558. // SetOp allows setting the mutation operation.
  24559. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  24560. m.op = op
  24561. }
  24562. // Type returns the node type of this mutation (UsageStatisticDay).
  24563. func (m *UsageStatisticDayMutation) Type() string {
  24564. return m.typ
  24565. }
  24566. // Fields returns all fields that were changed during this mutation. Note that in
  24567. // order to get all numeric fields that were incremented/decremented, call
  24568. // AddedFields().
  24569. func (m *UsageStatisticDayMutation) Fields() []string {
  24570. fields := make([]string, 0, 17)
  24571. if m.created_at != nil {
  24572. fields = append(fields, usagestatisticday.FieldCreatedAt)
  24573. }
  24574. if m.updated_at != nil {
  24575. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  24576. }
  24577. if m.status != nil {
  24578. fields = append(fields, usagestatisticday.FieldStatus)
  24579. }
  24580. if m.deleted_at != nil {
  24581. fields = append(fields, usagestatisticday.FieldDeletedAt)
  24582. }
  24583. if m.addtime != nil {
  24584. fields = append(fields, usagestatisticday.FieldAddtime)
  24585. }
  24586. if m._type != nil {
  24587. fields = append(fields, usagestatisticday.FieldType)
  24588. }
  24589. if m.bot_id != nil {
  24590. fields = append(fields, usagestatisticday.FieldBotID)
  24591. }
  24592. if m.organization_id != nil {
  24593. fields = append(fields, usagestatisticday.FieldOrganizationID)
  24594. }
  24595. if m.ai_response != nil {
  24596. fields = append(fields, usagestatisticday.FieldAiResponse)
  24597. }
  24598. if m.sop_run != nil {
  24599. fields = append(fields, usagestatisticday.FieldSopRun)
  24600. }
  24601. if m.total_friend != nil {
  24602. fields = append(fields, usagestatisticday.FieldTotalFriend)
  24603. }
  24604. if m.total_group != nil {
  24605. fields = append(fields, usagestatisticday.FieldTotalGroup)
  24606. }
  24607. if m.account_balance != nil {
  24608. fields = append(fields, usagestatisticday.FieldAccountBalance)
  24609. }
  24610. if m.consume_token != nil {
  24611. fields = append(fields, usagestatisticday.FieldConsumeToken)
  24612. }
  24613. if m.active_user != nil {
  24614. fields = append(fields, usagestatisticday.FieldActiveUser)
  24615. }
  24616. if m.new_user != nil {
  24617. fields = append(fields, usagestatisticday.FieldNewUser)
  24618. }
  24619. if m.label_dist != nil {
  24620. fields = append(fields, usagestatisticday.FieldLabelDist)
  24621. }
  24622. return fields
  24623. }
  24624. // Field returns the value of a field with the given name. The second boolean
  24625. // return value indicates that this field was not set, or was not defined in the
  24626. // schema.
  24627. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  24628. switch name {
  24629. case usagestatisticday.FieldCreatedAt:
  24630. return m.CreatedAt()
  24631. case usagestatisticday.FieldUpdatedAt:
  24632. return m.UpdatedAt()
  24633. case usagestatisticday.FieldStatus:
  24634. return m.Status()
  24635. case usagestatisticday.FieldDeletedAt:
  24636. return m.DeletedAt()
  24637. case usagestatisticday.FieldAddtime:
  24638. return m.Addtime()
  24639. case usagestatisticday.FieldType:
  24640. return m.GetType()
  24641. case usagestatisticday.FieldBotID:
  24642. return m.BotID()
  24643. case usagestatisticday.FieldOrganizationID:
  24644. return m.OrganizationID()
  24645. case usagestatisticday.FieldAiResponse:
  24646. return m.AiResponse()
  24647. case usagestatisticday.FieldSopRun:
  24648. return m.SopRun()
  24649. case usagestatisticday.FieldTotalFriend:
  24650. return m.TotalFriend()
  24651. case usagestatisticday.FieldTotalGroup:
  24652. return m.TotalGroup()
  24653. case usagestatisticday.FieldAccountBalance:
  24654. return m.AccountBalance()
  24655. case usagestatisticday.FieldConsumeToken:
  24656. return m.ConsumeToken()
  24657. case usagestatisticday.FieldActiveUser:
  24658. return m.ActiveUser()
  24659. case usagestatisticday.FieldNewUser:
  24660. return m.NewUser()
  24661. case usagestatisticday.FieldLabelDist:
  24662. return m.LabelDist()
  24663. }
  24664. return nil, false
  24665. }
  24666. // OldField returns the old value of the field from the database. An error is
  24667. // returned if the mutation operation is not UpdateOne, or the query to the
  24668. // database failed.
  24669. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24670. switch name {
  24671. case usagestatisticday.FieldCreatedAt:
  24672. return m.OldCreatedAt(ctx)
  24673. case usagestatisticday.FieldUpdatedAt:
  24674. return m.OldUpdatedAt(ctx)
  24675. case usagestatisticday.FieldStatus:
  24676. return m.OldStatus(ctx)
  24677. case usagestatisticday.FieldDeletedAt:
  24678. return m.OldDeletedAt(ctx)
  24679. case usagestatisticday.FieldAddtime:
  24680. return m.OldAddtime(ctx)
  24681. case usagestatisticday.FieldType:
  24682. return m.OldType(ctx)
  24683. case usagestatisticday.FieldBotID:
  24684. return m.OldBotID(ctx)
  24685. case usagestatisticday.FieldOrganizationID:
  24686. return m.OldOrganizationID(ctx)
  24687. case usagestatisticday.FieldAiResponse:
  24688. return m.OldAiResponse(ctx)
  24689. case usagestatisticday.FieldSopRun:
  24690. return m.OldSopRun(ctx)
  24691. case usagestatisticday.FieldTotalFriend:
  24692. return m.OldTotalFriend(ctx)
  24693. case usagestatisticday.FieldTotalGroup:
  24694. return m.OldTotalGroup(ctx)
  24695. case usagestatisticday.FieldAccountBalance:
  24696. return m.OldAccountBalance(ctx)
  24697. case usagestatisticday.FieldConsumeToken:
  24698. return m.OldConsumeToken(ctx)
  24699. case usagestatisticday.FieldActiveUser:
  24700. return m.OldActiveUser(ctx)
  24701. case usagestatisticday.FieldNewUser:
  24702. return m.OldNewUser(ctx)
  24703. case usagestatisticday.FieldLabelDist:
  24704. return m.OldLabelDist(ctx)
  24705. }
  24706. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  24707. }
  24708. // SetField sets the value of a field with the given name. It returns an error if
  24709. // the field is not defined in the schema, or if the type mismatched the field
  24710. // type.
  24711. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  24712. switch name {
  24713. case usagestatisticday.FieldCreatedAt:
  24714. v, ok := value.(time.Time)
  24715. if !ok {
  24716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24717. }
  24718. m.SetCreatedAt(v)
  24719. return nil
  24720. case usagestatisticday.FieldUpdatedAt:
  24721. v, ok := value.(time.Time)
  24722. if !ok {
  24723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24724. }
  24725. m.SetUpdatedAt(v)
  24726. return nil
  24727. case usagestatisticday.FieldStatus:
  24728. v, ok := value.(uint8)
  24729. if !ok {
  24730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24731. }
  24732. m.SetStatus(v)
  24733. return nil
  24734. case usagestatisticday.FieldDeletedAt:
  24735. v, ok := value.(time.Time)
  24736. if !ok {
  24737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24738. }
  24739. m.SetDeletedAt(v)
  24740. return nil
  24741. case usagestatisticday.FieldAddtime:
  24742. v, ok := value.(uint64)
  24743. if !ok {
  24744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24745. }
  24746. m.SetAddtime(v)
  24747. return nil
  24748. case usagestatisticday.FieldType:
  24749. v, ok := value.(int)
  24750. if !ok {
  24751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24752. }
  24753. m.SetType(v)
  24754. return nil
  24755. case usagestatisticday.FieldBotID:
  24756. v, ok := value.(string)
  24757. if !ok {
  24758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24759. }
  24760. m.SetBotID(v)
  24761. return nil
  24762. case usagestatisticday.FieldOrganizationID:
  24763. v, ok := value.(uint64)
  24764. if !ok {
  24765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24766. }
  24767. m.SetOrganizationID(v)
  24768. return nil
  24769. case usagestatisticday.FieldAiResponse:
  24770. v, ok := value.(uint64)
  24771. if !ok {
  24772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24773. }
  24774. m.SetAiResponse(v)
  24775. return nil
  24776. case usagestatisticday.FieldSopRun:
  24777. v, ok := value.(uint64)
  24778. if !ok {
  24779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24780. }
  24781. m.SetSopRun(v)
  24782. return nil
  24783. case usagestatisticday.FieldTotalFriend:
  24784. v, ok := value.(uint64)
  24785. if !ok {
  24786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24787. }
  24788. m.SetTotalFriend(v)
  24789. return nil
  24790. case usagestatisticday.FieldTotalGroup:
  24791. v, ok := value.(uint64)
  24792. if !ok {
  24793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24794. }
  24795. m.SetTotalGroup(v)
  24796. return nil
  24797. case usagestatisticday.FieldAccountBalance:
  24798. v, ok := value.(uint64)
  24799. if !ok {
  24800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24801. }
  24802. m.SetAccountBalance(v)
  24803. return nil
  24804. case usagestatisticday.FieldConsumeToken:
  24805. v, ok := value.(uint64)
  24806. if !ok {
  24807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24808. }
  24809. m.SetConsumeToken(v)
  24810. return nil
  24811. case usagestatisticday.FieldActiveUser:
  24812. v, ok := value.(uint64)
  24813. if !ok {
  24814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24815. }
  24816. m.SetActiveUser(v)
  24817. return nil
  24818. case usagestatisticday.FieldNewUser:
  24819. v, ok := value.(int64)
  24820. if !ok {
  24821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24822. }
  24823. m.SetNewUser(v)
  24824. return nil
  24825. case usagestatisticday.FieldLabelDist:
  24826. v, ok := value.([]custom_types.LabelDist)
  24827. if !ok {
  24828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24829. }
  24830. m.SetLabelDist(v)
  24831. return nil
  24832. }
  24833. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  24834. }
  24835. // AddedFields returns all numeric fields that were incremented/decremented during
  24836. // this mutation.
  24837. func (m *UsageStatisticDayMutation) AddedFields() []string {
  24838. var fields []string
  24839. if m.addstatus != nil {
  24840. fields = append(fields, usagestatisticday.FieldStatus)
  24841. }
  24842. if m.addaddtime != nil {
  24843. fields = append(fields, usagestatisticday.FieldAddtime)
  24844. }
  24845. if m.add_type != nil {
  24846. fields = append(fields, usagestatisticday.FieldType)
  24847. }
  24848. if m.addorganization_id != nil {
  24849. fields = append(fields, usagestatisticday.FieldOrganizationID)
  24850. }
  24851. if m.addai_response != nil {
  24852. fields = append(fields, usagestatisticday.FieldAiResponse)
  24853. }
  24854. if m.addsop_run != nil {
  24855. fields = append(fields, usagestatisticday.FieldSopRun)
  24856. }
  24857. if m.addtotal_friend != nil {
  24858. fields = append(fields, usagestatisticday.FieldTotalFriend)
  24859. }
  24860. if m.addtotal_group != nil {
  24861. fields = append(fields, usagestatisticday.FieldTotalGroup)
  24862. }
  24863. if m.addaccount_balance != nil {
  24864. fields = append(fields, usagestatisticday.FieldAccountBalance)
  24865. }
  24866. if m.addconsume_token != nil {
  24867. fields = append(fields, usagestatisticday.FieldConsumeToken)
  24868. }
  24869. if m.addactive_user != nil {
  24870. fields = append(fields, usagestatisticday.FieldActiveUser)
  24871. }
  24872. if m.addnew_user != nil {
  24873. fields = append(fields, usagestatisticday.FieldNewUser)
  24874. }
  24875. return fields
  24876. }
  24877. // AddedField returns the numeric value that was incremented/decremented on a field
  24878. // with the given name. The second boolean return value indicates that this field
  24879. // was not set, or was not defined in the schema.
  24880. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  24881. switch name {
  24882. case usagestatisticday.FieldStatus:
  24883. return m.AddedStatus()
  24884. case usagestatisticday.FieldAddtime:
  24885. return m.AddedAddtime()
  24886. case usagestatisticday.FieldType:
  24887. return m.AddedType()
  24888. case usagestatisticday.FieldOrganizationID:
  24889. return m.AddedOrganizationID()
  24890. case usagestatisticday.FieldAiResponse:
  24891. return m.AddedAiResponse()
  24892. case usagestatisticday.FieldSopRun:
  24893. return m.AddedSopRun()
  24894. case usagestatisticday.FieldTotalFriend:
  24895. return m.AddedTotalFriend()
  24896. case usagestatisticday.FieldTotalGroup:
  24897. return m.AddedTotalGroup()
  24898. case usagestatisticday.FieldAccountBalance:
  24899. return m.AddedAccountBalance()
  24900. case usagestatisticday.FieldConsumeToken:
  24901. return m.AddedConsumeToken()
  24902. case usagestatisticday.FieldActiveUser:
  24903. return m.AddedActiveUser()
  24904. case usagestatisticday.FieldNewUser:
  24905. return m.AddedNewUser()
  24906. }
  24907. return nil, false
  24908. }
  24909. // AddField adds the value to the field with the given name. It returns an error if
  24910. // the field is not defined in the schema, or if the type mismatched the field
  24911. // type.
  24912. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  24913. switch name {
  24914. case usagestatisticday.FieldStatus:
  24915. v, ok := value.(int8)
  24916. if !ok {
  24917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24918. }
  24919. m.AddStatus(v)
  24920. return nil
  24921. case usagestatisticday.FieldAddtime:
  24922. v, ok := value.(int64)
  24923. if !ok {
  24924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24925. }
  24926. m.AddAddtime(v)
  24927. return nil
  24928. case usagestatisticday.FieldType:
  24929. v, ok := value.(int)
  24930. if !ok {
  24931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24932. }
  24933. m.AddType(v)
  24934. return nil
  24935. case usagestatisticday.FieldOrganizationID:
  24936. v, ok := value.(int64)
  24937. if !ok {
  24938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24939. }
  24940. m.AddOrganizationID(v)
  24941. return nil
  24942. case usagestatisticday.FieldAiResponse:
  24943. v, ok := value.(int64)
  24944. if !ok {
  24945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24946. }
  24947. m.AddAiResponse(v)
  24948. return nil
  24949. case usagestatisticday.FieldSopRun:
  24950. v, ok := value.(int64)
  24951. if !ok {
  24952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24953. }
  24954. m.AddSopRun(v)
  24955. return nil
  24956. case usagestatisticday.FieldTotalFriend:
  24957. v, ok := value.(int64)
  24958. if !ok {
  24959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24960. }
  24961. m.AddTotalFriend(v)
  24962. return nil
  24963. case usagestatisticday.FieldTotalGroup:
  24964. v, ok := value.(int64)
  24965. if !ok {
  24966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24967. }
  24968. m.AddTotalGroup(v)
  24969. return nil
  24970. case usagestatisticday.FieldAccountBalance:
  24971. v, ok := value.(int64)
  24972. if !ok {
  24973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24974. }
  24975. m.AddAccountBalance(v)
  24976. return nil
  24977. case usagestatisticday.FieldConsumeToken:
  24978. v, ok := value.(int64)
  24979. if !ok {
  24980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24981. }
  24982. m.AddConsumeToken(v)
  24983. return nil
  24984. case usagestatisticday.FieldActiveUser:
  24985. v, ok := value.(int64)
  24986. if !ok {
  24987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24988. }
  24989. m.AddActiveUser(v)
  24990. return nil
  24991. case usagestatisticday.FieldNewUser:
  24992. v, ok := value.(int64)
  24993. if !ok {
  24994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24995. }
  24996. m.AddNewUser(v)
  24997. return nil
  24998. }
  24999. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  25000. }
  25001. // ClearedFields returns all nullable fields that were cleared during this
  25002. // mutation.
  25003. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  25004. var fields []string
  25005. if m.FieldCleared(usagestatisticday.FieldStatus) {
  25006. fields = append(fields, usagestatisticday.FieldStatus)
  25007. }
  25008. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  25009. fields = append(fields, usagestatisticday.FieldDeletedAt)
  25010. }
  25011. if m.FieldCleared(usagestatisticday.FieldBotID) {
  25012. fields = append(fields, usagestatisticday.FieldBotID)
  25013. }
  25014. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  25015. fields = append(fields, usagestatisticday.FieldOrganizationID)
  25016. }
  25017. return fields
  25018. }
  25019. // FieldCleared returns a boolean indicating if a field with the given name was
  25020. // cleared in this mutation.
  25021. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  25022. _, ok := m.clearedFields[name]
  25023. return ok
  25024. }
  25025. // ClearField clears the value of the field with the given name. It returns an
  25026. // error if the field is not defined in the schema.
  25027. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  25028. switch name {
  25029. case usagestatisticday.FieldStatus:
  25030. m.ClearStatus()
  25031. return nil
  25032. case usagestatisticday.FieldDeletedAt:
  25033. m.ClearDeletedAt()
  25034. return nil
  25035. case usagestatisticday.FieldBotID:
  25036. m.ClearBotID()
  25037. return nil
  25038. case usagestatisticday.FieldOrganizationID:
  25039. m.ClearOrganizationID()
  25040. return nil
  25041. }
  25042. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  25043. }
  25044. // ResetField resets all changes in the mutation for the field with the given name.
  25045. // It returns an error if the field is not defined in the schema.
  25046. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  25047. switch name {
  25048. case usagestatisticday.FieldCreatedAt:
  25049. m.ResetCreatedAt()
  25050. return nil
  25051. case usagestatisticday.FieldUpdatedAt:
  25052. m.ResetUpdatedAt()
  25053. return nil
  25054. case usagestatisticday.FieldStatus:
  25055. m.ResetStatus()
  25056. return nil
  25057. case usagestatisticday.FieldDeletedAt:
  25058. m.ResetDeletedAt()
  25059. return nil
  25060. case usagestatisticday.FieldAddtime:
  25061. m.ResetAddtime()
  25062. return nil
  25063. case usagestatisticday.FieldType:
  25064. m.ResetType()
  25065. return nil
  25066. case usagestatisticday.FieldBotID:
  25067. m.ResetBotID()
  25068. return nil
  25069. case usagestatisticday.FieldOrganizationID:
  25070. m.ResetOrganizationID()
  25071. return nil
  25072. case usagestatisticday.FieldAiResponse:
  25073. m.ResetAiResponse()
  25074. return nil
  25075. case usagestatisticday.FieldSopRun:
  25076. m.ResetSopRun()
  25077. return nil
  25078. case usagestatisticday.FieldTotalFriend:
  25079. m.ResetTotalFriend()
  25080. return nil
  25081. case usagestatisticday.FieldTotalGroup:
  25082. m.ResetTotalGroup()
  25083. return nil
  25084. case usagestatisticday.FieldAccountBalance:
  25085. m.ResetAccountBalance()
  25086. return nil
  25087. case usagestatisticday.FieldConsumeToken:
  25088. m.ResetConsumeToken()
  25089. return nil
  25090. case usagestatisticday.FieldActiveUser:
  25091. m.ResetActiveUser()
  25092. return nil
  25093. case usagestatisticday.FieldNewUser:
  25094. m.ResetNewUser()
  25095. return nil
  25096. case usagestatisticday.FieldLabelDist:
  25097. m.ResetLabelDist()
  25098. return nil
  25099. }
  25100. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  25101. }
  25102. // AddedEdges returns all edge names that were set/added in this mutation.
  25103. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  25104. edges := make([]string, 0, 0)
  25105. return edges
  25106. }
  25107. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25108. // name in this mutation.
  25109. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  25110. return nil
  25111. }
  25112. // RemovedEdges returns all edge names that were removed in this mutation.
  25113. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  25114. edges := make([]string, 0, 0)
  25115. return edges
  25116. }
  25117. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25118. // the given name in this mutation.
  25119. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  25120. return nil
  25121. }
  25122. // ClearedEdges returns all edge names that were cleared in this mutation.
  25123. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  25124. edges := make([]string, 0, 0)
  25125. return edges
  25126. }
  25127. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25128. // was cleared in this mutation.
  25129. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  25130. return false
  25131. }
  25132. // ClearEdge clears the value of the edge with the given name. It returns an error
  25133. // if that edge is not defined in the schema.
  25134. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  25135. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  25136. }
  25137. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25138. // It returns an error if the edge is not defined in the schema.
  25139. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  25140. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  25141. }
  25142. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  25143. type UsageStatisticHourMutation struct {
  25144. config
  25145. op Op
  25146. typ string
  25147. id *uint64
  25148. created_at *time.Time
  25149. updated_at *time.Time
  25150. status *uint8
  25151. addstatus *int8
  25152. deleted_at *time.Time
  25153. addtime *uint64
  25154. addaddtime *int64
  25155. _type *int
  25156. add_type *int
  25157. bot_id *string
  25158. organization_id *uint64
  25159. addorganization_id *int64
  25160. ai_response *uint64
  25161. addai_response *int64
  25162. sop_run *uint64
  25163. addsop_run *int64
  25164. total_friend *uint64
  25165. addtotal_friend *int64
  25166. total_group *uint64
  25167. addtotal_group *int64
  25168. account_balance *uint64
  25169. addaccount_balance *int64
  25170. consume_token *uint64
  25171. addconsume_token *int64
  25172. active_user *uint64
  25173. addactive_user *int64
  25174. new_user *int64
  25175. addnew_user *int64
  25176. label_dist *[]custom_types.LabelDist
  25177. appendlabel_dist []custom_types.LabelDist
  25178. clearedFields map[string]struct{}
  25179. done bool
  25180. oldValue func(context.Context) (*UsageStatisticHour, error)
  25181. predicates []predicate.UsageStatisticHour
  25182. }
  25183. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  25184. // usagestatistichourOption allows management of the mutation configuration using functional options.
  25185. type usagestatistichourOption func(*UsageStatisticHourMutation)
  25186. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  25187. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  25188. m := &UsageStatisticHourMutation{
  25189. config: c,
  25190. op: op,
  25191. typ: TypeUsageStatisticHour,
  25192. clearedFields: make(map[string]struct{}),
  25193. }
  25194. for _, opt := range opts {
  25195. opt(m)
  25196. }
  25197. return m
  25198. }
  25199. // withUsageStatisticHourID sets the ID field of the mutation.
  25200. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  25201. return func(m *UsageStatisticHourMutation) {
  25202. var (
  25203. err error
  25204. once sync.Once
  25205. value *UsageStatisticHour
  25206. )
  25207. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  25208. once.Do(func() {
  25209. if m.done {
  25210. err = errors.New("querying old values post mutation is not allowed")
  25211. } else {
  25212. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  25213. }
  25214. })
  25215. return value, err
  25216. }
  25217. m.id = &id
  25218. }
  25219. }
  25220. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  25221. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  25222. return func(m *UsageStatisticHourMutation) {
  25223. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  25224. return node, nil
  25225. }
  25226. m.id = &node.ID
  25227. }
  25228. }
  25229. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25230. // executed in a transaction (ent.Tx), a transactional client is returned.
  25231. func (m UsageStatisticHourMutation) Client() *Client {
  25232. client := &Client{config: m.config}
  25233. client.init()
  25234. return client
  25235. }
  25236. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25237. // it returns an error otherwise.
  25238. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  25239. if _, ok := m.driver.(*txDriver); !ok {
  25240. return nil, errors.New("ent: mutation is not running in a transaction")
  25241. }
  25242. tx := &Tx{config: m.config}
  25243. tx.init()
  25244. return tx, nil
  25245. }
  25246. // SetID sets the value of the id field. Note that this
  25247. // operation is only accepted on creation of UsageStatisticHour entities.
  25248. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  25249. m.id = &id
  25250. }
  25251. // ID returns the ID value in the mutation. Note that the ID is only available
  25252. // if it was provided to the builder or after it was returned from the database.
  25253. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  25254. if m.id == nil {
  25255. return
  25256. }
  25257. return *m.id, true
  25258. }
  25259. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25260. // That means, if the mutation is applied within a transaction with an isolation level such
  25261. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25262. // or updated by the mutation.
  25263. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  25264. switch {
  25265. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25266. id, exists := m.ID()
  25267. if exists {
  25268. return []uint64{id}, nil
  25269. }
  25270. fallthrough
  25271. case m.op.Is(OpUpdate | OpDelete):
  25272. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  25273. default:
  25274. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25275. }
  25276. }
  25277. // SetCreatedAt sets the "created_at" field.
  25278. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  25279. m.created_at = &t
  25280. }
  25281. // CreatedAt returns the value of the "created_at" field in the mutation.
  25282. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  25283. v := m.created_at
  25284. if v == nil {
  25285. return
  25286. }
  25287. return *v, true
  25288. }
  25289. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  25290. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25292. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25293. if !m.op.Is(OpUpdateOne) {
  25294. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25295. }
  25296. if m.id == nil || m.oldValue == nil {
  25297. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25298. }
  25299. oldValue, err := m.oldValue(ctx)
  25300. if err != nil {
  25301. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25302. }
  25303. return oldValue.CreatedAt, nil
  25304. }
  25305. // ResetCreatedAt resets all changes to the "created_at" field.
  25306. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  25307. m.created_at = nil
  25308. }
  25309. // SetUpdatedAt sets the "updated_at" field.
  25310. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  25311. m.updated_at = &t
  25312. }
  25313. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25314. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  25315. v := m.updated_at
  25316. if v == nil {
  25317. return
  25318. }
  25319. return *v, true
  25320. }
  25321. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  25322. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25324. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25325. if !m.op.Is(OpUpdateOne) {
  25326. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25327. }
  25328. if m.id == nil || m.oldValue == nil {
  25329. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25330. }
  25331. oldValue, err := m.oldValue(ctx)
  25332. if err != nil {
  25333. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25334. }
  25335. return oldValue.UpdatedAt, nil
  25336. }
  25337. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25338. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  25339. m.updated_at = nil
  25340. }
  25341. // SetStatus sets the "status" field.
  25342. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  25343. m.status = &u
  25344. m.addstatus = nil
  25345. }
  25346. // Status returns the value of the "status" field in the mutation.
  25347. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  25348. v := m.status
  25349. if v == nil {
  25350. return
  25351. }
  25352. return *v, true
  25353. }
  25354. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  25355. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25357. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25358. if !m.op.Is(OpUpdateOne) {
  25359. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25360. }
  25361. if m.id == nil || m.oldValue == nil {
  25362. return v, errors.New("OldStatus requires an ID field in the mutation")
  25363. }
  25364. oldValue, err := m.oldValue(ctx)
  25365. if err != nil {
  25366. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25367. }
  25368. return oldValue.Status, nil
  25369. }
  25370. // AddStatus adds u to the "status" field.
  25371. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  25372. if m.addstatus != nil {
  25373. *m.addstatus += u
  25374. } else {
  25375. m.addstatus = &u
  25376. }
  25377. }
  25378. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25379. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  25380. v := m.addstatus
  25381. if v == nil {
  25382. return
  25383. }
  25384. return *v, true
  25385. }
  25386. // ClearStatus clears the value of the "status" field.
  25387. func (m *UsageStatisticHourMutation) ClearStatus() {
  25388. m.status = nil
  25389. m.addstatus = nil
  25390. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  25391. }
  25392. // StatusCleared returns if the "status" field was cleared in this mutation.
  25393. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  25394. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  25395. return ok
  25396. }
  25397. // ResetStatus resets all changes to the "status" field.
  25398. func (m *UsageStatisticHourMutation) ResetStatus() {
  25399. m.status = nil
  25400. m.addstatus = nil
  25401. delete(m.clearedFields, usagestatistichour.FieldStatus)
  25402. }
  25403. // SetDeletedAt sets the "deleted_at" field.
  25404. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  25405. m.deleted_at = &t
  25406. }
  25407. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25408. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  25409. v := m.deleted_at
  25410. if v == nil {
  25411. return
  25412. }
  25413. return *v, true
  25414. }
  25415. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  25416. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25418. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25419. if !m.op.Is(OpUpdateOne) {
  25420. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25421. }
  25422. if m.id == nil || m.oldValue == nil {
  25423. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25424. }
  25425. oldValue, err := m.oldValue(ctx)
  25426. if err != nil {
  25427. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25428. }
  25429. return oldValue.DeletedAt, nil
  25430. }
  25431. // ClearDeletedAt clears the value of the "deleted_at" field.
  25432. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  25433. m.deleted_at = nil
  25434. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  25435. }
  25436. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25437. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  25438. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  25439. return ok
  25440. }
  25441. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25442. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  25443. m.deleted_at = nil
  25444. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  25445. }
  25446. // SetAddtime sets the "addtime" field.
  25447. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  25448. m.addtime = &u
  25449. m.addaddtime = nil
  25450. }
  25451. // Addtime returns the value of the "addtime" field in the mutation.
  25452. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  25453. v := m.addtime
  25454. if v == nil {
  25455. return
  25456. }
  25457. return *v, true
  25458. }
  25459. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  25460. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25462. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  25463. if !m.op.Is(OpUpdateOne) {
  25464. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  25465. }
  25466. if m.id == nil || m.oldValue == nil {
  25467. return v, errors.New("OldAddtime requires an ID field in the mutation")
  25468. }
  25469. oldValue, err := m.oldValue(ctx)
  25470. if err != nil {
  25471. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  25472. }
  25473. return oldValue.Addtime, nil
  25474. }
  25475. // AddAddtime adds u to the "addtime" field.
  25476. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  25477. if m.addaddtime != nil {
  25478. *m.addaddtime += u
  25479. } else {
  25480. m.addaddtime = &u
  25481. }
  25482. }
  25483. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  25484. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  25485. v := m.addaddtime
  25486. if v == nil {
  25487. return
  25488. }
  25489. return *v, true
  25490. }
  25491. // ResetAddtime resets all changes to the "addtime" field.
  25492. func (m *UsageStatisticHourMutation) ResetAddtime() {
  25493. m.addtime = nil
  25494. m.addaddtime = nil
  25495. }
  25496. // SetType sets the "type" field.
  25497. func (m *UsageStatisticHourMutation) SetType(i int) {
  25498. m._type = &i
  25499. m.add_type = nil
  25500. }
  25501. // GetType returns the value of the "type" field in the mutation.
  25502. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  25503. v := m._type
  25504. if v == nil {
  25505. return
  25506. }
  25507. return *v, true
  25508. }
  25509. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  25510. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25512. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  25513. if !m.op.Is(OpUpdateOne) {
  25514. return v, errors.New("OldType is only allowed on UpdateOne operations")
  25515. }
  25516. if m.id == nil || m.oldValue == nil {
  25517. return v, errors.New("OldType requires an ID field in the mutation")
  25518. }
  25519. oldValue, err := m.oldValue(ctx)
  25520. if err != nil {
  25521. return v, fmt.Errorf("querying old value for OldType: %w", err)
  25522. }
  25523. return oldValue.Type, nil
  25524. }
  25525. // AddType adds i to the "type" field.
  25526. func (m *UsageStatisticHourMutation) AddType(i int) {
  25527. if m.add_type != nil {
  25528. *m.add_type += i
  25529. } else {
  25530. m.add_type = &i
  25531. }
  25532. }
  25533. // AddedType returns the value that was added to the "type" field in this mutation.
  25534. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  25535. v := m.add_type
  25536. if v == nil {
  25537. return
  25538. }
  25539. return *v, true
  25540. }
  25541. // ResetType resets all changes to the "type" field.
  25542. func (m *UsageStatisticHourMutation) ResetType() {
  25543. m._type = nil
  25544. m.add_type = nil
  25545. }
  25546. // SetBotID sets the "bot_id" field.
  25547. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  25548. m.bot_id = &s
  25549. }
  25550. // BotID returns the value of the "bot_id" field in the mutation.
  25551. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  25552. v := m.bot_id
  25553. if v == nil {
  25554. return
  25555. }
  25556. return *v, true
  25557. }
  25558. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  25559. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25561. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  25562. if !m.op.Is(OpUpdateOne) {
  25563. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  25564. }
  25565. if m.id == nil || m.oldValue == nil {
  25566. return v, errors.New("OldBotID requires an ID field in the mutation")
  25567. }
  25568. oldValue, err := m.oldValue(ctx)
  25569. if err != nil {
  25570. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  25571. }
  25572. return oldValue.BotID, nil
  25573. }
  25574. // ClearBotID clears the value of the "bot_id" field.
  25575. func (m *UsageStatisticHourMutation) ClearBotID() {
  25576. m.bot_id = nil
  25577. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  25578. }
  25579. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  25580. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  25581. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  25582. return ok
  25583. }
  25584. // ResetBotID resets all changes to the "bot_id" field.
  25585. func (m *UsageStatisticHourMutation) ResetBotID() {
  25586. m.bot_id = nil
  25587. delete(m.clearedFields, usagestatistichour.FieldBotID)
  25588. }
  25589. // SetOrganizationID sets the "organization_id" field.
  25590. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  25591. m.organization_id = &u
  25592. m.addorganization_id = nil
  25593. }
  25594. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25595. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  25596. v := m.organization_id
  25597. if v == nil {
  25598. return
  25599. }
  25600. return *v, true
  25601. }
  25602. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  25603. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25605. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25606. if !m.op.Is(OpUpdateOne) {
  25607. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25608. }
  25609. if m.id == nil || m.oldValue == nil {
  25610. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25611. }
  25612. oldValue, err := m.oldValue(ctx)
  25613. if err != nil {
  25614. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25615. }
  25616. return oldValue.OrganizationID, nil
  25617. }
  25618. // AddOrganizationID adds u to the "organization_id" field.
  25619. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  25620. if m.addorganization_id != nil {
  25621. *m.addorganization_id += u
  25622. } else {
  25623. m.addorganization_id = &u
  25624. }
  25625. }
  25626. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25627. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  25628. v := m.addorganization_id
  25629. if v == nil {
  25630. return
  25631. }
  25632. return *v, true
  25633. }
  25634. // ClearOrganizationID clears the value of the "organization_id" field.
  25635. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  25636. m.organization_id = nil
  25637. m.addorganization_id = nil
  25638. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  25639. }
  25640. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25641. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  25642. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  25643. return ok
  25644. }
  25645. // ResetOrganizationID resets all changes to the "organization_id" field.
  25646. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  25647. m.organization_id = nil
  25648. m.addorganization_id = nil
  25649. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  25650. }
  25651. // SetAiResponse sets the "ai_response" field.
  25652. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  25653. m.ai_response = &u
  25654. m.addai_response = nil
  25655. }
  25656. // AiResponse returns the value of the "ai_response" field in the mutation.
  25657. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  25658. v := m.ai_response
  25659. if v == nil {
  25660. return
  25661. }
  25662. return *v, true
  25663. }
  25664. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  25665. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25667. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  25668. if !m.op.Is(OpUpdateOne) {
  25669. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  25670. }
  25671. if m.id == nil || m.oldValue == nil {
  25672. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  25673. }
  25674. oldValue, err := m.oldValue(ctx)
  25675. if err != nil {
  25676. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  25677. }
  25678. return oldValue.AiResponse, nil
  25679. }
  25680. // AddAiResponse adds u to the "ai_response" field.
  25681. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  25682. if m.addai_response != nil {
  25683. *m.addai_response += u
  25684. } else {
  25685. m.addai_response = &u
  25686. }
  25687. }
  25688. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  25689. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  25690. v := m.addai_response
  25691. if v == nil {
  25692. return
  25693. }
  25694. return *v, true
  25695. }
  25696. // ResetAiResponse resets all changes to the "ai_response" field.
  25697. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  25698. m.ai_response = nil
  25699. m.addai_response = nil
  25700. }
  25701. // SetSopRun sets the "sop_run" field.
  25702. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  25703. m.sop_run = &u
  25704. m.addsop_run = nil
  25705. }
  25706. // SopRun returns the value of the "sop_run" field in the mutation.
  25707. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  25708. v := m.sop_run
  25709. if v == nil {
  25710. return
  25711. }
  25712. return *v, true
  25713. }
  25714. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  25715. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25717. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  25718. if !m.op.Is(OpUpdateOne) {
  25719. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  25720. }
  25721. if m.id == nil || m.oldValue == nil {
  25722. return v, errors.New("OldSopRun requires an ID field in the mutation")
  25723. }
  25724. oldValue, err := m.oldValue(ctx)
  25725. if err != nil {
  25726. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  25727. }
  25728. return oldValue.SopRun, nil
  25729. }
  25730. // AddSopRun adds u to the "sop_run" field.
  25731. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  25732. if m.addsop_run != nil {
  25733. *m.addsop_run += u
  25734. } else {
  25735. m.addsop_run = &u
  25736. }
  25737. }
  25738. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  25739. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  25740. v := m.addsop_run
  25741. if v == nil {
  25742. return
  25743. }
  25744. return *v, true
  25745. }
  25746. // ResetSopRun resets all changes to the "sop_run" field.
  25747. func (m *UsageStatisticHourMutation) ResetSopRun() {
  25748. m.sop_run = nil
  25749. m.addsop_run = nil
  25750. }
  25751. // SetTotalFriend sets the "total_friend" field.
  25752. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  25753. m.total_friend = &u
  25754. m.addtotal_friend = nil
  25755. }
  25756. // TotalFriend returns the value of the "total_friend" field in the mutation.
  25757. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  25758. v := m.total_friend
  25759. if v == nil {
  25760. return
  25761. }
  25762. return *v, true
  25763. }
  25764. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  25765. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25767. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  25768. if !m.op.Is(OpUpdateOne) {
  25769. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  25770. }
  25771. if m.id == nil || m.oldValue == nil {
  25772. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  25773. }
  25774. oldValue, err := m.oldValue(ctx)
  25775. if err != nil {
  25776. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  25777. }
  25778. return oldValue.TotalFriend, nil
  25779. }
  25780. // AddTotalFriend adds u to the "total_friend" field.
  25781. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  25782. if m.addtotal_friend != nil {
  25783. *m.addtotal_friend += u
  25784. } else {
  25785. m.addtotal_friend = &u
  25786. }
  25787. }
  25788. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  25789. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  25790. v := m.addtotal_friend
  25791. if v == nil {
  25792. return
  25793. }
  25794. return *v, true
  25795. }
  25796. // ResetTotalFriend resets all changes to the "total_friend" field.
  25797. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  25798. m.total_friend = nil
  25799. m.addtotal_friend = nil
  25800. }
  25801. // SetTotalGroup sets the "total_group" field.
  25802. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  25803. m.total_group = &u
  25804. m.addtotal_group = nil
  25805. }
  25806. // TotalGroup returns the value of the "total_group" field in the mutation.
  25807. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  25808. v := m.total_group
  25809. if v == nil {
  25810. return
  25811. }
  25812. return *v, true
  25813. }
  25814. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  25815. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25817. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  25818. if !m.op.Is(OpUpdateOne) {
  25819. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  25820. }
  25821. if m.id == nil || m.oldValue == nil {
  25822. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  25823. }
  25824. oldValue, err := m.oldValue(ctx)
  25825. if err != nil {
  25826. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  25827. }
  25828. return oldValue.TotalGroup, nil
  25829. }
  25830. // AddTotalGroup adds u to the "total_group" field.
  25831. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  25832. if m.addtotal_group != nil {
  25833. *m.addtotal_group += u
  25834. } else {
  25835. m.addtotal_group = &u
  25836. }
  25837. }
  25838. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  25839. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  25840. v := m.addtotal_group
  25841. if v == nil {
  25842. return
  25843. }
  25844. return *v, true
  25845. }
  25846. // ResetTotalGroup resets all changes to the "total_group" field.
  25847. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  25848. m.total_group = nil
  25849. m.addtotal_group = nil
  25850. }
  25851. // SetAccountBalance sets the "account_balance" field.
  25852. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  25853. m.account_balance = &u
  25854. m.addaccount_balance = nil
  25855. }
  25856. // AccountBalance returns the value of the "account_balance" field in the mutation.
  25857. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  25858. v := m.account_balance
  25859. if v == nil {
  25860. return
  25861. }
  25862. return *v, true
  25863. }
  25864. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  25865. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25867. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  25868. if !m.op.Is(OpUpdateOne) {
  25869. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  25870. }
  25871. if m.id == nil || m.oldValue == nil {
  25872. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  25873. }
  25874. oldValue, err := m.oldValue(ctx)
  25875. if err != nil {
  25876. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  25877. }
  25878. return oldValue.AccountBalance, nil
  25879. }
  25880. // AddAccountBalance adds u to the "account_balance" field.
  25881. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  25882. if m.addaccount_balance != nil {
  25883. *m.addaccount_balance += u
  25884. } else {
  25885. m.addaccount_balance = &u
  25886. }
  25887. }
  25888. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  25889. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  25890. v := m.addaccount_balance
  25891. if v == nil {
  25892. return
  25893. }
  25894. return *v, true
  25895. }
  25896. // ResetAccountBalance resets all changes to the "account_balance" field.
  25897. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  25898. m.account_balance = nil
  25899. m.addaccount_balance = nil
  25900. }
  25901. // SetConsumeToken sets the "consume_token" field.
  25902. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  25903. m.consume_token = &u
  25904. m.addconsume_token = nil
  25905. }
  25906. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  25907. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  25908. v := m.consume_token
  25909. if v == nil {
  25910. return
  25911. }
  25912. return *v, true
  25913. }
  25914. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  25915. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25917. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  25918. if !m.op.Is(OpUpdateOne) {
  25919. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  25920. }
  25921. if m.id == nil || m.oldValue == nil {
  25922. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  25923. }
  25924. oldValue, err := m.oldValue(ctx)
  25925. if err != nil {
  25926. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  25927. }
  25928. return oldValue.ConsumeToken, nil
  25929. }
  25930. // AddConsumeToken adds u to the "consume_token" field.
  25931. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  25932. if m.addconsume_token != nil {
  25933. *m.addconsume_token += u
  25934. } else {
  25935. m.addconsume_token = &u
  25936. }
  25937. }
  25938. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  25939. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  25940. v := m.addconsume_token
  25941. if v == nil {
  25942. return
  25943. }
  25944. return *v, true
  25945. }
  25946. // ResetConsumeToken resets all changes to the "consume_token" field.
  25947. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  25948. m.consume_token = nil
  25949. m.addconsume_token = nil
  25950. }
  25951. // SetActiveUser sets the "active_user" field.
  25952. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  25953. m.active_user = &u
  25954. m.addactive_user = nil
  25955. }
  25956. // ActiveUser returns the value of the "active_user" field in the mutation.
  25957. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  25958. v := m.active_user
  25959. if v == nil {
  25960. return
  25961. }
  25962. return *v, true
  25963. }
  25964. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  25965. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25967. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  25968. if !m.op.Is(OpUpdateOne) {
  25969. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  25970. }
  25971. if m.id == nil || m.oldValue == nil {
  25972. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  25973. }
  25974. oldValue, err := m.oldValue(ctx)
  25975. if err != nil {
  25976. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  25977. }
  25978. return oldValue.ActiveUser, nil
  25979. }
  25980. // AddActiveUser adds u to the "active_user" field.
  25981. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  25982. if m.addactive_user != nil {
  25983. *m.addactive_user += u
  25984. } else {
  25985. m.addactive_user = &u
  25986. }
  25987. }
  25988. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  25989. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  25990. v := m.addactive_user
  25991. if v == nil {
  25992. return
  25993. }
  25994. return *v, true
  25995. }
  25996. // ResetActiveUser resets all changes to the "active_user" field.
  25997. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  25998. m.active_user = nil
  25999. m.addactive_user = nil
  26000. }
  26001. // SetNewUser sets the "new_user" field.
  26002. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  26003. m.new_user = &i
  26004. m.addnew_user = nil
  26005. }
  26006. // NewUser returns the value of the "new_user" field in the mutation.
  26007. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  26008. v := m.new_user
  26009. if v == nil {
  26010. return
  26011. }
  26012. return *v, true
  26013. }
  26014. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  26015. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26017. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  26018. if !m.op.Is(OpUpdateOne) {
  26019. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  26020. }
  26021. if m.id == nil || m.oldValue == nil {
  26022. return v, errors.New("OldNewUser requires an ID field in the mutation")
  26023. }
  26024. oldValue, err := m.oldValue(ctx)
  26025. if err != nil {
  26026. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  26027. }
  26028. return oldValue.NewUser, nil
  26029. }
  26030. // AddNewUser adds i to the "new_user" field.
  26031. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  26032. if m.addnew_user != nil {
  26033. *m.addnew_user += i
  26034. } else {
  26035. m.addnew_user = &i
  26036. }
  26037. }
  26038. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  26039. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  26040. v := m.addnew_user
  26041. if v == nil {
  26042. return
  26043. }
  26044. return *v, true
  26045. }
  26046. // ResetNewUser resets all changes to the "new_user" field.
  26047. func (m *UsageStatisticHourMutation) ResetNewUser() {
  26048. m.new_user = nil
  26049. m.addnew_user = nil
  26050. }
  26051. // SetLabelDist sets the "label_dist" field.
  26052. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  26053. m.label_dist = &ctd
  26054. m.appendlabel_dist = nil
  26055. }
  26056. // LabelDist returns the value of the "label_dist" field in the mutation.
  26057. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  26058. v := m.label_dist
  26059. if v == nil {
  26060. return
  26061. }
  26062. return *v, true
  26063. }
  26064. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  26065. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26067. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  26068. if !m.op.Is(OpUpdateOne) {
  26069. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  26070. }
  26071. if m.id == nil || m.oldValue == nil {
  26072. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  26073. }
  26074. oldValue, err := m.oldValue(ctx)
  26075. if err != nil {
  26076. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  26077. }
  26078. return oldValue.LabelDist, nil
  26079. }
  26080. // AppendLabelDist adds ctd to the "label_dist" field.
  26081. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  26082. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  26083. }
  26084. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  26085. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  26086. if len(m.appendlabel_dist) == 0 {
  26087. return nil, false
  26088. }
  26089. return m.appendlabel_dist, true
  26090. }
  26091. // ResetLabelDist resets all changes to the "label_dist" field.
  26092. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  26093. m.label_dist = nil
  26094. m.appendlabel_dist = nil
  26095. }
  26096. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  26097. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  26098. m.predicates = append(m.predicates, ps...)
  26099. }
  26100. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  26101. // users can use type-assertion to append predicates that do not depend on any generated package.
  26102. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  26103. p := make([]predicate.UsageStatisticHour, len(ps))
  26104. for i := range ps {
  26105. p[i] = ps[i]
  26106. }
  26107. m.Where(p...)
  26108. }
  26109. // Op returns the operation name.
  26110. func (m *UsageStatisticHourMutation) Op() Op {
  26111. return m.op
  26112. }
  26113. // SetOp allows setting the mutation operation.
  26114. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  26115. m.op = op
  26116. }
  26117. // Type returns the node type of this mutation (UsageStatisticHour).
  26118. func (m *UsageStatisticHourMutation) Type() string {
  26119. return m.typ
  26120. }
  26121. // Fields returns all fields that were changed during this mutation. Note that in
  26122. // order to get all numeric fields that were incremented/decremented, call
  26123. // AddedFields().
  26124. func (m *UsageStatisticHourMutation) Fields() []string {
  26125. fields := make([]string, 0, 17)
  26126. if m.created_at != nil {
  26127. fields = append(fields, usagestatistichour.FieldCreatedAt)
  26128. }
  26129. if m.updated_at != nil {
  26130. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  26131. }
  26132. if m.status != nil {
  26133. fields = append(fields, usagestatistichour.FieldStatus)
  26134. }
  26135. if m.deleted_at != nil {
  26136. fields = append(fields, usagestatistichour.FieldDeletedAt)
  26137. }
  26138. if m.addtime != nil {
  26139. fields = append(fields, usagestatistichour.FieldAddtime)
  26140. }
  26141. if m._type != nil {
  26142. fields = append(fields, usagestatistichour.FieldType)
  26143. }
  26144. if m.bot_id != nil {
  26145. fields = append(fields, usagestatistichour.FieldBotID)
  26146. }
  26147. if m.organization_id != nil {
  26148. fields = append(fields, usagestatistichour.FieldOrganizationID)
  26149. }
  26150. if m.ai_response != nil {
  26151. fields = append(fields, usagestatistichour.FieldAiResponse)
  26152. }
  26153. if m.sop_run != nil {
  26154. fields = append(fields, usagestatistichour.FieldSopRun)
  26155. }
  26156. if m.total_friend != nil {
  26157. fields = append(fields, usagestatistichour.FieldTotalFriend)
  26158. }
  26159. if m.total_group != nil {
  26160. fields = append(fields, usagestatistichour.FieldTotalGroup)
  26161. }
  26162. if m.account_balance != nil {
  26163. fields = append(fields, usagestatistichour.FieldAccountBalance)
  26164. }
  26165. if m.consume_token != nil {
  26166. fields = append(fields, usagestatistichour.FieldConsumeToken)
  26167. }
  26168. if m.active_user != nil {
  26169. fields = append(fields, usagestatistichour.FieldActiveUser)
  26170. }
  26171. if m.new_user != nil {
  26172. fields = append(fields, usagestatistichour.FieldNewUser)
  26173. }
  26174. if m.label_dist != nil {
  26175. fields = append(fields, usagestatistichour.FieldLabelDist)
  26176. }
  26177. return fields
  26178. }
  26179. // Field returns the value of a field with the given name. The second boolean
  26180. // return value indicates that this field was not set, or was not defined in the
  26181. // schema.
  26182. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  26183. switch name {
  26184. case usagestatistichour.FieldCreatedAt:
  26185. return m.CreatedAt()
  26186. case usagestatistichour.FieldUpdatedAt:
  26187. return m.UpdatedAt()
  26188. case usagestatistichour.FieldStatus:
  26189. return m.Status()
  26190. case usagestatistichour.FieldDeletedAt:
  26191. return m.DeletedAt()
  26192. case usagestatistichour.FieldAddtime:
  26193. return m.Addtime()
  26194. case usagestatistichour.FieldType:
  26195. return m.GetType()
  26196. case usagestatistichour.FieldBotID:
  26197. return m.BotID()
  26198. case usagestatistichour.FieldOrganizationID:
  26199. return m.OrganizationID()
  26200. case usagestatistichour.FieldAiResponse:
  26201. return m.AiResponse()
  26202. case usagestatistichour.FieldSopRun:
  26203. return m.SopRun()
  26204. case usagestatistichour.FieldTotalFriend:
  26205. return m.TotalFriend()
  26206. case usagestatistichour.FieldTotalGroup:
  26207. return m.TotalGroup()
  26208. case usagestatistichour.FieldAccountBalance:
  26209. return m.AccountBalance()
  26210. case usagestatistichour.FieldConsumeToken:
  26211. return m.ConsumeToken()
  26212. case usagestatistichour.FieldActiveUser:
  26213. return m.ActiveUser()
  26214. case usagestatistichour.FieldNewUser:
  26215. return m.NewUser()
  26216. case usagestatistichour.FieldLabelDist:
  26217. return m.LabelDist()
  26218. }
  26219. return nil, false
  26220. }
  26221. // OldField returns the old value of the field from the database. An error is
  26222. // returned if the mutation operation is not UpdateOne, or the query to the
  26223. // database failed.
  26224. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26225. switch name {
  26226. case usagestatistichour.FieldCreatedAt:
  26227. return m.OldCreatedAt(ctx)
  26228. case usagestatistichour.FieldUpdatedAt:
  26229. return m.OldUpdatedAt(ctx)
  26230. case usagestatistichour.FieldStatus:
  26231. return m.OldStatus(ctx)
  26232. case usagestatistichour.FieldDeletedAt:
  26233. return m.OldDeletedAt(ctx)
  26234. case usagestatistichour.FieldAddtime:
  26235. return m.OldAddtime(ctx)
  26236. case usagestatistichour.FieldType:
  26237. return m.OldType(ctx)
  26238. case usagestatistichour.FieldBotID:
  26239. return m.OldBotID(ctx)
  26240. case usagestatistichour.FieldOrganizationID:
  26241. return m.OldOrganizationID(ctx)
  26242. case usagestatistichour.FieldAiResponse:
  26243. return m.OldAiResponse(ctx)
  26244. case usagestatistichour.FieldSopRun:
  26245. return m.OldSopRun(ctx)
  26246. case usagestatistichour.FieldTotalFriend:
  26247. return m.OldTotalFriend(ctx)
  26248. case usagestatistichour.FieldTotalGroup:
  26249. return m.OldTotalGroup(ctx)
  26250. case usagestatistichour.FieldAccountBalance:
  26251. return m.OldAccountBalance(ctx)
  26252. case usagestatistichour.FieldConsumeToken:
  26253. return m.OldConsumeToken(ctx)
  26254. case usagestatistichour.FieldActiveUser:
  26255. return m.OldActiveUser(ctx)
  26256. case usagestatistichour.FieldNewUser:
  26257. return m.OldNewUser(ctx)
  26258. case usagestatistichour.FieldLabelDist:
  26259. return m.OldLabelDist(ctx)
  26260. }
  26261. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  26262. }
  26263. // SetField sets the value of a field with the given name. It returns an error if
  26264. // the field is not defined in the schema, or if the type mismatched the field
  26265. // type.
  26266. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  26267. switch name {
  26268. case usagestatistichour.FieldCreatedAt:
  26269. v, ok := value.(time.Time)
  26270. if !ok {
  26271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26272. }
  26273. m.SetCreatedAt(v)
  26274. return nil
  26275. case usagestatistichour.FieldUpdatedAt:
  26276. v, ok := value.(time.Time)
  26277. if !ok {
  26278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26279. }
  26280. m.SetUpdatedAt(v)
  26281. return nil
  26282. case usagestatistichour.FieldStatus:
  26283. v, ok := value.(uint8)
  26284. if !ok {
  26285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26286. }
  26287. m.SetStatus(v)
  26288. return nil
  26289. case usagestatistichour.FieldDeletedAt:
  26290. v, ok := value.(time.Time)
  26291. if !ok {
  26292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26293. }
  26294. m.SetDeletedAt(v)
  26295. return nil
  26296. case usagestatistichour.FieldAddtime:
  26297. v, ok := value.(uint64)
  26298. if !ok {
  26299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26300. }
  26301. m.SetAddtime(v)
  26302. return nil
  26303. case usagestatistichour.FieldType:
  26304. v, ok := value.(int)
  26305. if !ok {
  26306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26307. }
  26308. m.SetType(v)
  26309. return nil
  26310. case usagestatistichour.FieldBotID:
  26311. v, ok := value.(string)
  26312. if !ok {
  26313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26314. }
  26315. m.SetBotID(v)
  26316. return nil
  26317. case usagestatistichour.FieldOrganizationID:
  26318. v, ok := value.(uint64)
  26319. if !ok {
  26320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26321. }
  26322. m.SetOrganizationID(v)
  26323. return nil
  26324. case usagestatistichour.FieldAiResponse:
  26325. v, ok := value.(uint64)
  26326. if !ok {
  26327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26328. }
  26329. m.SetAiResponse(v)
  26330. return nil
  26331. case usagestatistichour.FieldSopRun:
  26332. v, ok := value.(uint64)
  26333. if !ok {
  26334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26335. }
  26336. m.SetSopRun(v)
  26337. return nil
  26338. case usagestatistichour.FieldTotalFriend:
  26339. v, ok := value.(uint64)
  26340. if !ok {
  26341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26342. }
  26343. m.SetTotalFriend(v)
  26344. return nil
  26345. case usagestatistichour.FieldTotalGroup:
  26346. v, ok := value.(uint64)
  26347. if !ok {
  26348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26349. }
  26350. m.SetTotalGroup(v)
  26351. return nil
  26352. case usagestatistichour.FieldAccountBalance:
  26353. v, ok := value.(uint64)
  26354. if !ok {
  26355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26356. }
  26357. m.SetAccountBalance(v)
  26358. return nil
  26359. case usagestatistichour.FieldConsumeToken:
  26360. v, ok := value.(uint64)
  26361. if !ok {
  26362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26363. }
  26364. m.SetConsumeToken(v)
  26365. return nil
  26366. case usagestatistichour.FieldActiveUser:
  26367. v, ok := value.(uint64)
  26368. if !ok {
  26369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26370. }
  26371. m.SetActiveUser(v)
  26372. return nil
  26373. case usagestatistichour.FieldNewUser:
  26374. v, ok := value.(int64)
  26375. if !ok {
  26376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26377. }
  26378. m.SetNewUser(v)
  26379. return nil
  26380. case usagestatistichour.FieldLabelDist:
  26381. v, ok := value.([]custom_types.LabelDist)
  26382. if !ok {
  26383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26384. }
  26385. m.SetLabelDist(v)
  26386. return nil
  26387. }
  26388. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  26389. }
  26390. // AddedFields returns all numeric fields that were incremented/decremented during
  26391. // this mutation.
  26392. func (m *UsageStatisticHourMutation) AddedFields() []string {
  26393. var fields []string
  26394. if m.addstatus != nil {
  26395. fields = append(fields, usagestatistichour.FieldStatus)
  26396. }
  26397. if m.addaddtime != nil {
  26398. fields = append(fields, usagestatistichour.FieldAddtime)
  26399. }
  26400. if m.add_type != nil {
  26401. fields = append(fields, usagestatistichour.FieldType)
  26402. }
  26403. if m.addorganization_id != nil {
  26404. fields = append(fields, usagestatistichour.FieldOrganizationID)
  26405. }
  26406. if m.addai_response != nil {
  26407. fields = append(fields, usagestatistichour.FieldAiResponse)
  26408. }
  26409. if m.addsop_run != nil {
  26410. fields = append(fields, usagestatistichour.FieldSopRun)
  26411. }
  26412. if m.addtotal_friend != nil {
  26413. fields = append(fields, usagestatistichour.FieldTotalFriend)
  26414. }
  26415. if m.addtotal_group != nil {
  26416. fields = append(fields, usagestatistichour.FieldTotalGroup)
  26417. }
  26418. if m.addaccount_balance != nil {
  26419. fields = append(fields, usagestatistichour.FieldAccountBalance)
  26420. }
  26421. if m.addconsume_token != nil {
  26422. fields = append(fields, usagestatistichour.FieldConsumeToken)
  26423. }
  26424. if m.addactive_user != nil {
  26425. fields = append(fields, usagestatistichour.FieldActiveUser)
  26426. }
  26427. if m.addnew_user != nil {
  26428. fields = append(fields, usagestatistichour.FieldNewUser)
  26429. }
  26430. return fields
  26431. }
  26432. // AddedField returns the numeric value that was incremented/decremented on a field
  26433. // with the given name. The second boolean return value indicates that this field
  26434. // was not set, or was not defined in the schema.
  26435. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  26436. switch name {
  26437. case usagestatistichour.FieldStatus:
  26438. return m.AddedStatus()
  26439. case usagestatistichour.FieldAddtime:
  26440. return m.AddedAddtime()
  26441. case usagestatistichour.FieldType:
  26442. return m.AddedType()
  26443. case usagestatistichour.FieldOrganizationID:
  26444. return m.AddedOrganizationID()
  26445. case usagestatistichour.FieldAiResponse:
  26446. return m.AddedAiResponse()
  26447. case usagestatistichour.FieldSopRun:
  26448. return m.AddedSopRun()
  26449. case usagestatistichour.FieldTotalFriend:
  26450. return m.AddedTotalFriend()
  26451. case usagestatistichour.FieldTotalGroup:
  26452. return m.AddedTotalGroup()
  26453. case usagestatistichour.FieldAccountBalance:
  26454. return m.AddedAccountBalance()
  26455. case usagestatistichour.FieldConsumeToken:
  26456. return m.AddedConsumeToken()
  26457. case usagestatistichour.FieldActiveUser:
  26458. return m.AddedActiveUser()
  26459. case usagestatistichour.FieldNewUser:
  26460. return m.AddedNewUser()
  26461. }
  26462. return nil, false
  26463. }
  26464. // AddField adds the value to the field with the given name. It returns an error if
  26465. // the field is not defined in the schema, or if the type mismatched the field
  26466. // type.
  26467. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  26468. switch name {
  26469. case usagestatistichour.FieldStatus:
  26470. v, ok := value.(int8)
  26471. if !ok {
  26472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26473. }
  26474. m.AddStatus(v)
  26475. return nil
  26476. case usagestatistichour.FieldAddtime:
  26477. v, ok := value.(int64)
  26478. if !ok {
  26479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26480. }
  26481. m.AddAddtime(v)
  26482. return nil
  26483. case usagestatistichour.FieldType:
  26484. v, ok := value.(int)
  26485. if !ok {
  26486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26487. }
  26488. m.AddType(v)
  26489. return nil
  26490. case usagestatistichour.FieldOrganizationID:
  26491. v, ok := value.(int64)
  26492. if !ok {
  26493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26494. }
  26495. m.AddOrganizationID(v)
  26496. return nil
  26497. case usagestatistichour.FieldAiResponse:
  26498. v, ok := value.(int64)
  26499. if !ok {
  26500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26501. }
  26502. m.AddAiResponse(v)
  26503. return nil
  26504. case usagestatistichour.FieldSopRun:
  26505. v, ok := value.(int64)
  26506. if !ok {
  26507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26508. }
  26509. m.AddSopRun(v)
  26510. return nil
  26511. case usagestatistichour.FieldTotalFriend:
  26512. v, ok := value.(int64)
  26513. if !ok {
  26514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26515. }
  26516. m.AddTotalFriend(v)
  26517. return nil
  26518. case usagestatistichour.FieldTotalGroup:
  26519. v, ok := value.(int64)
  26520. if !ok {
  26521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26522. }
  26523. m.AddTotalGroup(v)
  26524. return nil
  26525. case usagestatistichour.FieldAccountBalance:
  26526. v, ok := value.(int64)
  26527. if !ok {
  26528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26529. }
  26530. m.AddAccountBalance(v)
  26531. return nil
  26532. case usagestatistichour.FieldConsumeToken:
  26533. v, ok := value.(int64)
  26534. if !ok {
  26535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26536. }
  26537. m.AddConsumeToken(v)
  26538. return nil
  26539. case usagestatistichour.FieldActiveUser:
  26540. v, ok := value.(int64)
  26541. if !ok {
  26542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26543. }
  26544. m.AddActiveUser(v)
  26545. return nil
  26546. case usagestatistichour.FieldNewUser:
  26547. v, ok := value.(int64)
  26548. if !ok {
  26549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26550. }
  26551. m.AddNewUser(v)
  26552. return nil
  26553. }
  26554. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  26555. }
  26556. // ClearedFields returns all nullable fields that were cleared during this
  26557. // mutation.
  26558. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  26559. var fields []string
  26560. if m.FieldCleared(usagestatistichour.FieldStatus) {
  26561. fields = append(fields, usagestatistichour.FieldStatus)
  26562. }
  26563. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  26564. fields = append(fields, usagestatistichour.FieldDeletedAt)
  26565. }
  26566. if m.FieldCleared(usagestatistichour.FieldBotID) {
  26567. fields = append(fields, usagestatistichour.FieldBotID)
  26568. }
  26569. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  26570. fields = append(fields, usagestatistichour.FieldOrganizationID)
  26571. }
  26572. return fields
  26573. }
  26574. // FieldCleared returns a boolean indicating if a field with the given name was
  26575. // cleared in this mutation.
  26576. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  26577. _, ok := m.clearedFields[name]
  26578. return ok
  26579. }
  26580. // ClearField clears the value of the field with the given name. It returns an
  26581. // error if the field is not defined in the schema.
  26582. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  26583. switch name {
  26584. case usagestatistichour.FieldStatus:
  26585. m.ClearStatus()
  26586. return nil
  26587. case usagestatistichour.FieldDeletedAt:
  26588. m.ClearDeletedAt()
  26589. return nil
  26590. case usagestatistichour.FieldBotID:
  26591. m.ClearBotID()
  26592. return nil
  26593. case usagestatistichour.FieldOrganizationID:
  26594. m.ClearOrganizationID()
  26595. return nil
  26596. }
  26597. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  26598. }
  26599. // ResetField resets all changes in the mutation for the field with the given name.
  26600. // It returns an error if the field is not defined in the schema.
  26601. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  26602. switch name {
  26603. case usagestatistichour.FieldCreatedAt:
  26604. m.ResetCreatedAt()
  26605. return nil
  26606. case usagestatistichour.FieldUpdatedAt:
  26607. m.ResetUpdatedAt()
  26608. return nil
  26609. case usagestatistichour.FieldStatus:
  26610. m.ResetStatus()
  26611. return nil
  26612. case usagestatistichour.FieldDeletedAt:
  26613. m.ResetDeletedAt()
  26614. return nil
  26615. case usagestatistichour.FieldAddtime:
  26616. m.ResetAddtime()
  26617. return nil
  26618. case usagestatistichour.FieldType:
  26619. m.ResetType()
  26620. return nil
  26621. case usagestatistichour.FieldBotID:
  26622. m.ResetBotID()
  26623. return nil
  26624. case usagestatistichour.FieldOrganizationID:
  26625. m.ResetOrganizationID()
  26626. return nil
  26627. case usagestatistichour.FieldAiResponse:
  26628. m.ResetAiResponse()
  26629. return nil
  26630. case usagestatistichour.FieldSopRun:
  26631. m.ResetSopRun()
  26632. return nil
  26633. case usagestatistichour.FieldTotalFriend:
  26634. m.ResetTotalFriend()
  26635. return nil
  26636. case usagestatistichour.FieldTotalGroup:
  26637. m.ResetTotalGroup()
  26638. return nil
  26639. case usagestatistichour.FieldAccountBalance:
  26640. m.ResetAccountBalance()
  26641. return nil
  26642. case usagestatistichour.FieldConsumeToken:
  26643. m.ResetConsumeToken()
  26644. return nil
  26645. case usagestatistichour.FieldActiveUser:
  26646. m.ResetActiveUser()
  26647. return nil
  26648. case usagestatistichour.FieldNewUser:
  26649. m.ResetNewUser()
  26650. return nil
  26651. case usagestatistichour.FieldLabelDist:
  26652. m.ResetLabelDist()
  26653. return nil
  26654. }
  26655. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  26656. }
  26657. // AddedEdges returns all edge names that were set/added in this mutation.
  26658. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  26659. edges := make([]string, 0, 0)
  26660. return edges
  26661. }
  26662. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26663. // name in this mutation.
  26664. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  26665. return nil
  26666. }
  26667. // RemovedEdges returns all edge names that were removed in this mutation.
  26668. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  26669. edges := make([]string, 0, 0)
  26670. return edges
  26671. }
  26672. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26673. // the given name in this mutation.
  26674. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  26675. return nil
  26676. }
  26677. // ClearedEdges returns all edge names that were cleared in this mutation.
  26678. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  26679. edges := make([]string, 0, 0)
  26680. return edges
  26681. }
  26682. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26683. // was cleared in this mutation.
  26684. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  26685. return false
  26686. }
  26687. // ClearEdge clears the value of the edge with the given name. It returns an error
  26688. // if that edge is not defined in the schema.
  26689. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  26690. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  26691. }
  26692. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26693. // It returns an error if the edge is not defined in the schema.
  26694. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  26695. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  26696. }
  26697. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  26698. type UsageStatisticMonthMutation struct {
  26699. config
  26700. op Op
  26701. typ string
  26702. id *uint64
  26703. created_at *time.Time
  26704. updated_at *time.Time
  26705. status *uint8
  26706. addstatus *int8
  26707. deleted_at *time.Time
  26708. addtime *uint64
  26709. addaddtime *int64
  26710. _type *int
  26711. add_type *int
  26712. bot_id *string
  26713. organization_id *uint64
  26714. addorganization_id *int64
  26715. ai_response *uint64
  26716. addai_response *int64
  26717. sop_run *uint64
  26718. addsop_run *int64
  26719. total_friend *uint64
  26720. addtotal_friend *int64
  26721. total_group *uint64
  26722. addtotal_group *int64
  26723. account_balance *uint64
  26724. addaccount_balance *int64
  26725. consume_token *uint64
  26726. addconsume_token *int64
  26727. active_user *uint64
  26728. addactive_user *int64
  26729. new_user *int64
  26730. addnew_user *int64
  26731. label_dist *[]custom_types.LabelDist
  26732. appendlabel_dist []custom_types.LabelDist
  26733. clearedFields map[string]struct{}
  26734. done bool
  26735. oldValue func(context.Context) (*UsageStatisticMonth, error)
  26736. predicates []predicate.UsageStatisticMonth
  26737. }
  26738. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  26739. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  26740. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  26741. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  26742. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  26743. m := &UsageStatisticMonthMutation{
  26744. config: c,
  26745. op: op,
  26746. typ: TypeUsageStatisticMonth,
  26747. clearedFields: make(map[string]struct{}),
  26748. }
  26749. for _, opt := range opts {
  26750. opt(m)
  26751. }
  26752. return m
  26753. }
  26754. // withUsageStatisticMonthID sets the ID field of the mutation.
  26755. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  26756. return func(m *UsageStatisticMonthMutation) {
  26757. var (
  26758. err error
  26759. once sync.Once
  26760. value *UsageStatisticMonth
  26761. )
  26762. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  26763. once.Do(func() {
  26764. if m.done {
  26765. err = errors.New("querying old values post mutation is not allowed")
  26766. } else {
  26767. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  26768. }
  26769. })
  26770. return value, err
  26771. }
  26772. m.id = &id
  26773. }
  26774. }
  26775. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  26776. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  26777. return func(m *UsageStatisticMonthMutation) {
  26778. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  26779. return node, nil
  26780. }
  26781. m.id = &node.ID
  26782. }
  26783. }
  26784. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26785. // executed in a transaction (ent.Tx), a transactional client is returned.
  26786. func (m UsageStatisticMonthMutation) Client() *Client {
  26787. client := &Client{config: m.config}
  26788. client.init()
  26789. return client
  26790. }
  26791. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26792. // it returns an error otherwise.
  26793. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  26794. if _, ok := m.driver.(*txDriver); !ok {
  26795. return nil, errors.New("ent: mutation is not running in a transaction")
  26796. }
  26797. tx := &Tx{config: m.config}
  26798. tx.init()
  26799. return tx, nil
  26800. }
  26801. // SetID sets the value of the id field. Note that this
  26802. // operation is only accepted on creation of UsageStatisticMonth entities.
  26803. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  26804. m.id = &id
  26805. }
  26806. // ID returns the ID value in the mutation. Note that the ID is only available
  26807. // if it was provided to the builder or after it was returned from the database.
  26808. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  26809. if m.id == nil {
  26810. return
  26811. }
  26812. return *m.id, true
  26813. }
  26814. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26815. // That means, if the mutation is applied within a transaction with an isolation level such
  26816. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26817. // or updated by the mutation.
  26818. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  26819. switch {
  26820. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26821. id, exists := m.ID()
  26822. if exists {
  26823. return []uint64{id}, nil
  26824. }
  26825. fallthrough
  26826. case m.op.Is(OpUpdate | OpDelete):
  26827. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  26828. default:
  26829. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26830. }
  26831. }
  26832. // SetCreatedAt sets the "created_at" field.
  26833. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  26834. m.created_at = &t
  26835. }
  26836. // CreatedAt returns the value of the "created_at" field in the mutation.
  26837. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  26838. v := m.created_at
  26839. if v == nil {
  26840. return
  26841. }
  26842. return *v, true
  26843. }
  26844. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  26845. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  26846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26847. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26848. if !m.op.Is(OpUpdateOne) {
  26849. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26850. }
  26851. if m.id == nil || m.oldValue == nil {
  26852. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26853. }
  26854. oldValue, err := m.oldValue(ctx)
  26855. if err != nil {
  26856. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26857. }
  26858. return oldValue.CreatedAt, nil
  26859. }
  26860. // ResetCreatedAt resets all changes to the "created_at" field.
  26861. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  26862. m.created_at = nil
  26863. }
  26864. // SetUpdatedAt sets the "updated_at" field.
  26865. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  26866. m.updated_at = &t
  26867. }
  26868. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26869. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  26870. v := m.updated_at
  26871. if v == nil {
  26872. return
  26873. }
  26874. return *v, true
  26875. }
  26876. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  26877. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  26878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26879. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26880. if !m.op.Is(OpUpdateOne) {
  26881. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26882. }
  26883. if m.id == nil || m.oldValue == nil {
  26884. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26885. }
  26886. oldValue, err := m.oldValue(ctx)
  26887. if err != nil {
  26888. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26889. }
  26890. return oldValue.UpdatedAt, nil
  26891. }
  26892. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26893. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  26894. m.updated_at = nil
  26895. }
  26896. // SetStatus sets the "status" field.
  26897. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  26898. m.status = &u
  26899. m.addstatus = nil
  26900. }
  26901. // Status returns the value of the "status" field in the mutation.
  26902. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  26903. v := m.status
  26904. if v == nil {
  26905. return
  26906. }
  26907. return *v, true
  26908. }
  26909. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  26910. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  26911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26912. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26913. if !m.op.Is(OpUpdateOne) {
  26914. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26915. }
  26916. if m.id == nil || m.oldValue == nil {
  26917. return v, errors.New("OldStatus requires an ID field in the mutation")
  26918. }
  26919. oldValue, err := m.oldValue(ctx)
  26920. if err != nil {
  26921. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26922. }
  26923. return oldValue.Status, nil
  26924. }
  26925. // AddStatus adds u to the "status" field.
  26926. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  26927. if m.addstatus != nil {
  26928. *m.addstatus += u
  26929. } else {
  26930. m.addstatus = &u
  26931. }
  26932. }
  26933. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26934. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  26935. v := m.addstatus
  26936. if v == nil {
  26937. return
  26938. }
  26939. return *v, true
  26940. }
  26941. // ClearStatus clears the value of the "status" field.
  26942. func (m *UsageStatisticMonthMutation) ClearStatus() {
  26943. m.status = nil
  26944. m.addstatus = nil
  26945. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  26946. }
  26947. // StatusCleared returns if the "status" field was cleared in this mutation.
  26948. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  26949. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  26950. return ok
  26951. }
  26952. // ResetStatus resets all changes to the "status" field.
  26953. func (m *UsageStatisticMonthMutation) ResetStatus() {
  26954. m.status = nil
  26955. m.addstatus = nil
  26956. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  26957. }
  26958. // SetDeletedAt sets the "deleted_at" field.
  26959. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  26960. m.deleted_at = &t
  26961. }
  26962. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26963. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  26964. v := m.deleted_at
  26965. if v == nil {
  26966. return
  26967. }
  26968. return *v, true
  26969. }
  26970. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  26971. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  26972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26973. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26974. if !m.op.Is(OpUpdateOne) {
  26975. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26976. }
  26977. if m.id == nil || m.oldValue == nil {
  26978. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26979. }
  26980. oldValue, err := m.oldValue(ctx)
  26981. if err != nil {
  26982. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26983. }
  26984. return oldValue.DeletedAt, nil
  26985. }
  26986. // ClearDeletedAt clears the value of the "deleted_at" field.
  26987. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  26988. m.deleted_at = nil
  26989. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  26990. }
  26991. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26992. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  26993. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  26994. return ok
  26995. }
  26996. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26997. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  26998. m.deleted_at = nil
  26999. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  27000. }
  27001. // SetAddtime sets the "addtime" field.
  27002. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  27003. m.addtime = &u
  27004. m.addaddtime = nil
  27005. }
  27006. // Addtime returns the value of the "addtime" field in the mutation.
  27007. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  27008. v := m.addtime
  27009. if v == nil {
  27010. return
  27011. }
  27012. return *v, true
  27013. }
  27014. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  27015. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27017. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  27018. if !m.op.Is(OpUpdateOne) {
  27019. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  27020. }
  27021. if m.id == nil || m.oldValue == nil {
  27022. return v, errors.New("OldAddtime requires an ID field in the mutation")
  27023. }
  27024. oldValue, err := m.oldValue(ctx)
  27025. if err != nil {
  27026. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  27027. }
  27028. return oldValue.Addtime, nil
  27029. }
  27030. // AddAddtime adds u to the "addtime" field.
  27031. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  27032. if m.addaddtime != nil {
  27033. *m.addaddtime += u
  27034. } else {
  27035. m.addaddtime = &u
  27036. }
  27037. }
  27038. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  27039. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  27040. v := m.addaddtime
  27041. if v == nil {
  27042. return
  27043. }
  27044. return *v, true
  27045. }
  27046. // ResetAddtime resets all changes to the "addtime" field.
  27047. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  27048. m.addtime = nil
  27049. m.addaddtime = nil
  27050. }
  27051. // SetType sets the "type" field.
  27052. func (m *UsageStatisticMonthMutation) SetType(i int) {
  27053. m._type = &i
  27054. m.add_type = nil
  27055. }
  27056. // GetType returns the value of the "type" field in the mutation.
  27057. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  27058. v := m._type
  27059. if v == nil {
  27060. return
  27061. }
  27062. return *v, true
  27063. }
  27064. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  27065. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27067. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  27068. if !m.op.Is(OpUpdateOne) {
  27069. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27070. }
  27071. if m.id == nil || m.oldValue == nil {
  27072. return v, errors.New("OldType requires an ID field in the mutation")
  27073. }
  27074. oldValue, err := m.oldValue(ctx)
  27075. if err != nil {
  27076. return v, fmt.Errorf("querying old value for OldType: %w", err)
  27077. }
  27078. return oldValue.Type, nil
  27079. }
  27080. // AddType adds i to the "type" field.
  27081. func (m *UsageStatisticMonthMutation) AddType(i int) {
  27082. if m.add_type != nil {
  27083. *m.add_type += i
  27084. } else {
  27085. m.add_type = &i
  27086. }
  27087. }
  27088. // AddedType returns the value that was added to the "type" field in this mutation.
  27089. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  27090. v := m.add_type
  27091. if v == nil {
  27092. return
  27093. }
  27094. return *v, true
  27095. }
  27096. // ResetType resets all changes to the "type" field.
  27097. func (m *UsageStatisticMonthMutation) ResetType() {
  27098. m._type = nil
  27099. m.add_type = nil
  27100. }
  27101. // SetBotID sets the "bot_id" field.
  27102. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  27103. m.bot_id = &s
  27104. }
  27105. // BotID returns the value of the "bot_id" field in the mutation.
  27106. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  27107. v := m.bot_id
  27108. if v == nil {
  27109. return
  27110. }
  27111. return *v, true
  27112. }
  27113. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  27114. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27116. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  27117. if !m.op.Is(OpUpdateOne) {
  27118. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27119. }
  27120. if m.id == nil || m.oldValue == nil {
  27121. return v, errors.New("OldBotID requires an ID field in the mutation")
  27122. }
  27123. oldValue, err := m.oldValue(ctx)
  27124. if err != nil {
  27125. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27126. }
  27127. return oldValue.BotID, nil
  27128. }
  27129. // ClearBotID clears the value of the "bot_id" field.
  27130. func (m *UsageStatisticMonthMutation) ClearBotID() {
  27131. m.bot_id = nil
  27132. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  27133. }
  27134. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  27135. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  27136. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  27137. return ok
  27138. }
  27139. // ResetBotID resets all changes to the "bot_id" field.
  27140. func (m *UsageStatisticMonthMutation) ResetBotID() {
  27141. m.bot_id = nil
  27142. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  27143. }
  27144. // SetOrganizationID sets the "organization_id" field.
  27145. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  27146. m.organization_id = &u
  27147. m.addorganization_id = nil
  27148. }
  27149. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27150. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  27151. v := m.organization_id
  27152. if v == nil {
  27153. return
  27154. }
  27155. return *v, true
  27156. }
  27157. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  27158. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27160. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27161. if !m.op.Is(OpUpdateOne) {
  27162. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27163. }
  27164. if m.id == nil || m.oldValue == nil {
  27165. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27166. }
  27167. oldValue, err := m.oldValue(ctx)
  27168. if err != nil {
  27169. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27170. }
  27171. return oldValue.OrganizationID, nil
  27172. }
  27173. // AddOrganizationID adds u to the "organization_id" field.
  27174. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  27175. if m.addorganization_id != nil {
  27176. *m.addorganization_id += u
  27177. } else {
  27178. m.addorganization_id = &u
  27179. }
  27180. }
  27181. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27182. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  27183. v := m.addorganization_id
  27184. if v == nil {
  27185. return
  27186. }
  27187. return *v, true
  27188. }
  27189. // ClearOrganizationID clears the value of the "organization_id" field.
  27190. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  27191. m.organization_id = nil
  27192. m.addorganization_id = nil
  27193. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  27194. }
  27195. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27196. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  27197. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  27198. return ok
  27199. }
  27200. // ResetOrganizationID resets all changes to the "organization_id" field.
  27201. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  27202. m.organization_id = nil
  27203. m.addorganization_id = nil
  27204. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  27205. }
  27206. // SetAiResponse sets the "ai_response" field.
  27207. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  27208. m.ai_response = &u
  27209. m.addai_response = nil
  27210. }
  27211. // AiResponse returns the value of the "ai_response" field in the mutation.
  27212. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  27213. v := m.ai_response
  27214. if v == nil {
  27215. return
  27216. }
  27217. return *v, true
  27218. }
  27219. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  27220. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27222. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  27223. if !m.op.Is(OpUpdateOne) {
  27224. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  27225. }
  27226. if m.id == nil || m.oldValue == nil {
  27227. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  27228. }
  27229. oldValue, err := m.oldValue(ctx)
  27230. if err != nil {
  27231. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  27232. }
  27233. return oldValue.AiResponse, nil
  27234. }
  27235. // AddAiResponse adds u to the "ai_response" field.
  27236. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  27237. if m.addai_response != nil {
  27238. *m.addai_response += u
  27239. } else {
  27240. m.addai_response = &u
  27241. }
  27242. }
  27243. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  27244. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  27245. v := m.addai_response
  27246. if v == nil {
  27247. return
  27248. }
  27249. return *v, true
  27250. }
  27251. // ResetAiResponse resets all changes to the "ai_response" field.
  27252. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  27253. m.ai_response = nil
  27254. m.addai_response = nil
  27255. }
  27256. // SetSopRun sets the "sop_run" field.
  27257. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  27258. m.sop_run = &u
  27259. m.addsop_run = nil
  27260. }
  27261. // SopRun returns the value of the "sop_run" field in the mutation.
  27262. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  27263. v := m.sop_run
  27264. if v == nil {
  27265. return
  27266. }
  27267. return *v, true
  27268. }
  27269. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  27270. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27272. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  27273. if !m.op.Is(OpUpdateOne) {
  27274. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  27275. }
  27276. if m.id == nil || m.oldValue == nil {
  27277. return v, errors.New("OldSopRun requires an ID field in the mutation")
  27278. }
  27279. oldValue, err := m.oldValue(ctx)
  27280. if err != nil {
  27281. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  27282. }
  27283. return oldValue.SopRun, nil
  27284. }
  27285. // AddSopRun adds u to the "sop_run" field.
  27286. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  27287. if m.addsop_run != nil {
  27288. *m.addsop_run += u
  27289. } else {
  27290. m.addsop_run = &u
  27291. }
  27292. }
  27293. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  27294. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  27295. v := m.addsop_run
  27296. if v == nil {
  27297. return
  27298. }
  27299. return *v, true
  27300. }
  27301. // ResetSopRun resets all changes to the "sop_run" field.
  27302. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  27303. m.sop_run = nil
  27304. m.addsop_run = nil
  27305. }
  27306. // SetTotalFriend sets the "total_friend" field.
  27307. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  27308. m.total_friend = &u
  27309. m.addtotal_friend = nil
  27310. }
  27311. // TotalFriend returns the value of the "total_friend" field in the mutation.
  27312. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  27313. v := m.total_friend
  27314. if v == nil {
  27315. return
  27316. }
  27317. return *v, true
  27318. }
  27319. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  27320. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27322. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  27323. if !m.op.Is(OpUpdateOne) {
  27324. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  27325. }
  27326. if m.id == nil || m.oldValue == nil {
  27327. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  27328. }
  27329. oldValue, err := m.oldValue(ctx)
  27330. if err != nil {
  27331. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  27332. }
  27333. return oldValue.TotalFriend, nil
  27334. }
  27335. // AddTotalFriend adds u to the "total_friend" field.
  27336. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  27337. if m.addtotal_friend != nil {
  27338. *m.addtotal_friend += u
  27339. } else {
  27340. m.addtotal_friend = &u
  27341. }
  27342. }
  27343. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  27344. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  27345. v := m.addtotal_friend
  27346. if v == nil {
  27347. return
  27348. }
  27349. return *v, true
  27350. }
  27351. // ResetTotalFriend resets all changes to the "total_friend" field.
  27352. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  27353. m.total_friend = nil
  27354. m.addtotal_friend = nil
  27355. }
  27356. // SetTotalGroup sets the "total_group" field.
  27357. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  27358. m.total_group = &u
  27359. m.addtotal_group = nil
  27360. }
  27361. // TotalGroup returns the value of the "total_group" field in the mutation.
  27362. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  27363. v := m.total_group
  27364. if v == nil {
  27365. return
  27366. }
  27367. return *v, true
  27368. }
  27369. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  27370. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27372. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  27373. if !m.op.Is(OpUpdateOne) {
  27374. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  27375. }
  27376. if m.id == nil || m.oldValue == nil {
  27377. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  27378. }
  27379. oldValue, err := m.oldValue(ctx)
  27380. if err != nil {
  27381. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  27382. }
  27383. return oldValue.TotalGroup, nil
  27384. }
  27385. // AddTotalGroup adds u to the "total_group" field.
  27386. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  27387. if m.addtotal_group != nil {
  27388. *m.addtotal_group += u
  27389. } else {
  27390. m.addtotal_group = &u
  27391. }
  27392. }
  27393. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  27394. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  27395. v := m.addtotal_group
  27396. if v == nil {
  27397. return
  27398. }
  27399. return *v, true
  27400. }
  27401. // ResetTotalGroup resets all changes to the "total_group" field.
  27402. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  27403. m.total_group = nil
  27404. m.addtotal_group = nil
  27405. }
  27406. // SetAccountBalance sets the "account_balance" field.
  27407. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  27408. m.account_balance = &u
  27409. m.addaccount_balance = nil
  27410. }
  27411. // AccountBalance returns the value of the "account_balance" field in the mutation.
  27412. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  27413. v := m.account_balance
  27414. if v == nil {
  27415. return
  27416. }
  27417. return *v, true
  27418. }
  27419. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  27420. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27422. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  27423. if !m.op.Is(OpUpdateOne) {
  27424. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  27425. }
  27426. if m.id == nil || m.oldValue == nil {
  27427. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  27428. }
  27429. oldValue, err := m.oldValue(ctx)
  27430. if err != nil {
  27431. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  27432. }
  27433. return oldValue.AccountBalance, nil
  27434. }
  27435. // AddAccountBalance adds u to the "account_balance" field.
  27436. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  27437. if m.addaccount_balance != nil {
  27438. *m.addaccount_balance += u
  27439. } else {
  27440. m.addaccount_balance = &u
  27441. }
  27442. }
  27443. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  27444. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  27445. v := m.addaccount_balance
  27446. if v == nil {
  27447. return
  27448. }
  27449. return *v, true
  27450. }
  27451. // ResetAccountBalance resets all changes to the "account_balance" field.
  27452. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  27453. m.account_balance = nil
  27454. m.addaccount_balance = nil
  27455. }
  27456. // SetConsumeToken sets the "consume_token" field.
  27457. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  27458. m.consume_token = &u
  27459. m.addconsume_token = nil
  27460. }
  27461. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  27462. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  27463. v := m.consume_token
  27464. if v == nil {
  27465. return
  27466. }
  27467. return *v, true
  27468. }
  27469. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  27470. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27472. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  27473. if !m.op.Is(OpUpdateOne) {
  27474. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  27475. }
  27476. if m.id == nil || m.oldValue == nil {
  27477. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  27478. }
  27479. oldValue, err := m.oldValue(ctx)
  27480. if err != nil {
  27481. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  27482. }
  27483. return oldValue.ConsumeToken, nil
  27484. }
  27485. // AddConsumeToken adds u to the "consume_token" field.
  27486. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  27487. if m.addconsume_token != nil {
  27488. *m.addconsume_token += u
  27489. } else {
  27490. m.addconsume_token = &u
  27491. }
  27492. }
  27493. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  27494. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  27495. v := m.addconsume_token
  27496. if v == nil {
  27497. return
  27498. }
  27499. return *v, true
  27500. }
  27501. // ResetConsumeToken resets all changes to the "consume_token" field.
  27502. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  27503. m.consume_token = nil
  27504. m.addconsume_token = nil
  27505. }
  27506. // SetActiveUser sets the "active_user" field.
  27507. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  27508. m.active_user = &u
  27509. m.addactive_user = nil
  27510. }
  27511. // ActiveUser returns the value of the "active_user" field in the mutation.
  27512. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  27513. v := m.active_user
  27514. if v == nil {
  27515. return
  27516. }
  27517. return *v, true
  27518. }
  27519. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  27520. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27522. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  27523. if !m.op.Is(OpUpdateOne) {
  27524. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  27525. }
  27526. if m.id == nil || m.oldValue == nil {
  27527. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  27528. }
  27529. oldValue, err := m.oldValue(ctx)
  27530. if err != nil {
  27531. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  27532. }
  27533. return oldValue.ActiveUser, nil
  27534. }
  27535. // AddActiveUser adds u to the "active_user" field.
  27536. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  27537. if m.addactive_user != nil {
  27538. *m.addactive_user += u
  27539. } else {
  27540. m.addactive_user = &u
  27541. }
  27542. }
  27543. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  27544. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  27545. v := m.addactive_user
  27546. if v == nil {
  27547. return
  27548. }
  27549. return *v, true
  27550. }
  27551. // ResetActiveUser resets all changes to the "active_user" field.
  27552. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  27553. m.active_user = nil
  27554. m.addactive_user = nil
  27555. }
  27556. // SetNewUser sets the "new_user" field.
  27557. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  27558. m.new_user = &i
  27559. m.addnew_user = nil
  27560. }
  27561. // NewUser returns the value of the "new_user" field in the mutation.
  27562. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  27563. v := m.new_user
  27564. if v == nil {
  27565. return
  27566. }
  27567. return *v, true
  27568. }
  27569. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  27570. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27572. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  27573. if !m.op.Is(OpUpdateOne) {
  27574. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  27575. }
  27576. if m.id == nil || m.oldValue == nil {
  27577. return v, errors.New("OldNewUser requires an ID field in the mutation")
  27578. }
  27579. oldValue, err := m.oldValue(ctx)
  27580. if err != nil {
  27581. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  27582. }
  27583. return oldValue.NewUser, nil
  27584. }
  27585. // AddNewUser adds i to the "new_user" field.
  27586. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  27587. if m.addnew_user != nil {
  27588. *m.addnew_user += i
  27589. } else {
  27590. m.addnew_user = &i
  27591. }
  27592. }
  27593. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  27594. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  27595. v := m.addnew_user
  27596. if v == nil {
  27597. return
  27598. }
  27599. return *v, true
  27600. }
  27601. // ResetNewUser resets all changes to the "new_user" field.
  27602. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  27603. m.new_user = nil
  27604. m.addnew_user = nil
  27605. }
  27606. // SetLabelDist sets the "label_dist" field.
  27607. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  27608. m.label_dist = &ctd
  27609. m.appendlabel_dist = nil
  27610. }
  27611. // LabelDist returns the value of the "label_dist" field in the mutation.
  27612. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  27613. v := m.label_dist
  27614. if v == nil {
  27615. return
  27616. }
  27617. return *v, true
  27618. }
  27619. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  27620. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27622. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  27623. if !m.op.Is(OpUpdateOne) {
  27624. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  27625. }
  27626. if m.id == nil || m.oldValue == nil {
  27627. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  27628. }
  27629. oldValue, err := m.oldValue(ctx)
  27630. if err != nil {
  27631. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  27632. }
  27633. return oldValue.LabelDist, nil
  27634. }
  27635. // AppendLabelDist adds ctd to the "label_dist" field.
  27636. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  27637. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  27638. }
  27639. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  27640. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  27641. if len(m.appendlabel_dist) == 0 {
  27642. return nil, false
  27643. }
  27644. return m.appendlabel_dist, true
  27645. }
  27646. // ResetLabelDist resets all changes to the "label_dist" field.
  27647. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  27648. m.label_dist = nil
  27649. m.appendlabel_dist = nil
  27650. }
  27651. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  27652. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  27653. m.predicates = append(m.predicates, ps...)
  27654. }
  27655. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  27656. // users can use type-assertion to append predicates that do not depend on any generated package.
  27657. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  27658. p := make([]predicate.UsageStatisticMonth, len(ps))
  27659. for i := range ps {
  27660. p[i] = ps[i]
  27661. }
  27662. m.Where(p...)
  27663. }
  27664. // Op returns the operation name.
  27665. func (m *UsageStatisticMonthMutation) Op() Op {
  27666. return m.op
  27667. }
  27668. // SetOp allows setting the mutation operation.
  27669. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  27670. m.op = op
  27671. }
  27672. // Type returns the node type of this mutation (UsageStatisticMonth).
  27673. func (m *UsageStatisticMonthMutation) Type() string {
  27674. return m.typ
  27675. }
  27676. // Fields returns all fields that were changed during this mutation. Note that in
  27677. // order to get all numeric fields that were incremented/decremented, call
  27678. // AddedFields().
  27679. func (m *UsageStatisticMonthMutation) Fields() []string {
  27680. fields := make([]string, 0, 17)
  27681. if m.created_at != nil {
  27682. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  27683. }
  27684. if m.updated_at != nil {
  27685. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  27686. }
  27687. if m.status != nil {
  27688. fields = append(fields, usagestatisticmonth.FieldStatus)
  27689. }
  27690. if m.deleted_at != nil {
  27691. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  27692. }
  27693. if m.addtime != nil {
  27694. fields = append(fields, usagestatisticmonth.FieldAddtime)
  27695. }
  27696. if m._type != nil {
  27697. fields = append(fields, usagestatisticmonth.FieldType)
  27698. }
  27699. if m.bot_id != nil {
  27700. fields = append(fields, usagestatisticmonth.FieldBotID)
  27701. }
  27702. if m.organization_id != nil {
  27703. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  27704. }
  27705. if m.ai_response != nil {
  27706. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  27707. }
  27708. if m.sop_run != nil {
  27709. fields = append(fields, usagestatisticmonth.FieldSopRun)
  27710. }
  27711. if m.total_friend != nil {
  27712. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  27713. }
  27714. if m.total_group != nil {
  27715. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  27716. }
  27717. if m.account_balance != nil {
  27718. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  27719. }
  27720. if m.consume_token != nil {
  27721. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  27722. }
  27723. if m.active_user != nil {
  27724. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  27725. }
  27726. if m.new_user != nil {
  27727. fields = append(fields, usagestatisticmonth.FieldNewUser)
  27728. }
  27729. if m.label_dist != nil {
  27730. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  27731. }
  27732. return fields
  27733. }
  27734. // Field returns the value of a field with the given name. The second boolean
  27735. // return value indicates that this field was not set, or was not defined in the
  27736. // schema.
  27737. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  27738. switch name {
  27739. case usagestatisticmonth.FieldCreatedAt:
  27740. return m.CreatedAt()
  27741. case usagestatisticmonth.FieldUpdatedAt:
  27742. return m.UpdatedAt()
  27743. case usagestatisticmonth.FieldStatus:
  27744. return m.Status()
  27745. case usagestatisticmonth.FieldDeletedAt:
  27746. return m.DeletedAt()
  27747. case usagestatisticmonth.FieldAddtime:
  27748. return m.Addtime()
  27749. case usagestatisticmonth.FieldType:
  27750. return m.GetType()
  27751. case usagestatisticmonth.FieldBotID:
  27752. return m.BotID()
  27753. case usagestatisticmonth.FieldOrganizationID:
  27754. return m.OrganizationID()
  27755. case usagestatisticmonth.FieldAiResponse:
  27756. return m.AiResponse()
  27757. case usagestatisticmonth.FieldSopRun:
  27758. return m.SopRun()
  27759. case usagestatisticmonth.FieldTotalFriend:
  27760. return m.TotalFriend()
  27761. case usagestatisticmonth.FieldTotalGroup:
  27762. return m.TotalGroup()
  27763. case usagestatisticmonth.FieldAccountBalance:
  27764. return m.AccountBalance()
  27765. case usagestatisticmonth.FieldConsumeToken:
  27766. return m.ConsumeToken()
  27767. case usagestatisticmonth.FieldActiveUser:
  27768. return m.ActiveUser()
  27769. case usagestatisticmonth.FieldNewUser:
  27770. return m.NewUser()
  27771. case usagestatisticmonth.FieldLabelDist:
  27772. return m.LabelDist()
  27773. }
  27774. return nil, false
  27775. }
  27776. // OldField returns the old value of the field from the database. An error is
  27777. // returned if the mutation operation is not UpdateOne, or the query to the
  27778. // database failed.
  27779. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27780. switch name {
  27781. case usagestatisticmonth.FieldCreatedAt:
  27782. return m.OldCreatedAt(ctx)
  27783. case usagestatisticmonth.FieldUpdatedAt:
  27784. return m.OldUpdatedAt(ctx)
  27785. case usagestatisticmonth.FieldStatus:
  27786. return m.OldStatus(ctx)
  27787. case usagestatisticmonth.FieldDeletedAt:
  27788. return m.OldDeletedAt(ctx)
  27789. case usagestatisticmonth.FieldAddtime:
  27790. return m.OldAddtime(ctx)
  27791. case usagestatisticmonth.FieldType:
  27792. return m.OldType(ctx)
  27793. case usagestatisticmonth.FieldBotID:
  27794. return m.OldBotID(ctx)
  27795. case usagestatisticmonth.FieldOrganizationID:
  27796. return m.OldOrganizationID(ctx)
  27797. case usagestatisticmonth.FieldAiResponse:
  27798. return m.OldAiResponse(ctx)
  27799. case usagestatisticmonth.FieldSopRun:
  27800. return m.OldSopRun(ctx)
  27801. case usagestatisticmonth.FieldTotalFriend:
  27802. return m.OldTotalFriend(ctx)
  27803. case usagestatisticmonth.FieldTotalGroup:
  27804. return m.OldTotalGroup(ctx)
  27805. case usagestatisticmonth.FieldAccountBalance:
  27806. return m.OldAccountBalance(ctx)
  27807. case usagestatisticmonth.FieldConsumeToken:
  27808. return m.OldConsumeToken(ctx)
  27809. case usagestatisticmonth.FieldActiveUser:
  27810. return m.OldActiveUser(ctx)
  27811. case usagestatisticmonth.FieldNewUser:
  27812. return m.OldNewUser(ctx)
  27813. case usagestatisticmonth.FieldLabelDist:
  27814. return m.OldLabelDist(ctx)
  27815. }
  27816. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  27817. }
  27818. // SetField sets the value of a field with the given name. It returns an error if
  27819. // the field is not defined in the schema, or if the type mismatched the field
  27820. // type.
  27821. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  27822. switch name {
  27823. case usagestatisticmonth.FieldCreatedAt:
  27824. v, ok := value.(time.Time)
  27825. if !ok {
  27826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27827. }
  27828. m.SetCreatedAt(v)
  27829. return nil
  27830. case usagestatisticmonth.FieldUpdatedAt:
  27831. v, ok := value.(time.Time)
  27832. if !ok {
  27833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27834. }
  27835. m.SetUpdatedAt(v)
  27836. return nil
  27837. case usagestatisticmonth.FieldStatus:
  27838. v, ok := value.(uint8)
  27839. if !ok {
  27840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27841. }
  27842. m.SetStatus(v)
  27843. return nil
  27844. case usagestatisticmonth.FieldDeletedAt:
  27845. v, ok := value.(time.Time)
  27846. if !ok {
  27847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27848. }
  27849. m.SetDeletedAt(v)
  27850. return nil
  27851. case usagestatisticmonth.FieldAddtime:
  27852. v, ok := value.(uint64)
  27853. if !ok {
  27854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27855. }
  27856. m.SetAddtime(v)
  27857. return nil
  27858. case usagestatisticmonth.FieldType:
  27859. v, ok := value.(int)
  27860. if !ok {
  27861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27862. }
  27863. m.SetType(v)
  27864. return nil
  27865. case usagestatisticmonth.FieldBotID:
  27866. v, ok := value.(string)
  27867. if !ok {
  27868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27869. }
  27870. m.SetBotID(v)
  27871. return nil
  27872. case usagestatisticmonth.FieldOrganizationID:
  27873. v, ok := value.(uint64)
  27874. if !ok {
  27875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27876. }
  27877. m.SetOrganizationID(v)
  27878. return nil
  27879. case usagestatisticmonth.FieldAiResponse:
  27880. v, ok := value.(uint64)
  27881. if !ok {
  27882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27883. }
  27884. m.SetAiResponse(v)
  27885. return nil
  27886. case usagestatisticmonth.FieldSopRun:
  27887. v, ok := value.(uint64)
  27888. if !ok {
  27889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27890. }
  27891. m.SetSopRun(v)
  27892. return nil
  27893. case usagestatisticmonth.FieldTotalFriend:
  27894. v, ok := value.(uint64)
  27895. if !ok {
  27896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27897. }
  27898. m.SetTotalFriend(v)
  27899. return nil
  27900. case usagestatisticmonth.FieldTotalGroup:
  27901. v, ok := value.(uint64)
  27902. if !ok {
  27903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27904. }
  27905. m.SetTotalGroup(v)
  27906. return nil
  27907. case usagestatisticmonth.FieldAccountBalance:
  27908. v, ok := value.(uint64)
  27909. if !ok {
  27910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27911. }
  27912. m.SetAccountBalance(v)
  27913. return nil
  27914. case usagestatisticmonth.FieldConsumeToken:
  27915. v, ok := value.(uint64)
  27916. if !ok {
  27917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27918. }
  27919. m.SetConsumeToken(v)
  27920. return nil
  27921. case usagestatisticmonth.FieldActiveUser:
  27922. v, ok := value.(uint64)
  27923. if !ok {
  27924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27925. }
  27926. m.SetActiveUser(v)
  27927. return nil
  27928. case usagestatisticmonth.FieldNewUser:
  27929. v, ok := value.(int64)
  27930. if !ok {
  27931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27932. }
  27933. m.SetNewUser(v)
  27934. return nil
  27935. case usagestatisticmonth.FieldLabelDist:
  27936. v, ok := value.([]custom_types.LabelDist)
  27937. if !ok {
  27938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27939. }
  27940. m.SetLabelDist(v)
  27941. return nil
  27942. }
  27943. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  27944. }
  27945. // AddedFields returns all numeric fields that were incremented/decremented during
  27946. // this mutation.
  27947. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  27948. var fields []string
  27949. if m.addstatus != nil {
  27950. fields = append(fields, usagestatisticmonth.FieldStatus)
  27951. }
  27952. if m.addaddtime != nil {
  27953. fields = append(fields, usagestatisticmonth.FieldAddtime)
  27954. }
  27955. if m.add_type != nil {
  27956. fields = append(fields, usagestatisticmonth.FieldType)
  27957. }
  27958. if m.addorganization_id != nil {
  27959. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  27960. }
  27961. if m.addai_response != nil {
  27962. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  27963. }
  27964. if m.addsop_run != nil {
  27965. fields = append(fields, usagestatisticmonth.FieldSopRun)
  27966. }
  27967. if m.addtotal_friend != nil {
  27968. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  27969. }
  27970. if m.addtotal_group != nil {
  27971. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  27972. }
  27973. if m.addaccount_balance != nil {
  27974. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  27975. }
  27976. if m.addconsume_token != nil {
  27977. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  27978. }
  27979. if m.addactive_user != nil {
  27980. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  27981. }
  27982. if m.addnew_user != nil {
  27983. fields = append(fields, usagestatisticmonth.FieldNewUser)
  27984. }
  27985. return fields
  27986. }
  27987. // AddedField returns the numeric value that was incremented/decremented on a field
  27988. // with the given name. The second boolean return value indicates that this field
  27989. // was not set, or was not defined in the schema.
  27990. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  27991. switch name {
  27992. case usagestatisticmonth.FieldStatus:
  27993. return m.AddedStatus()
  27994. case usagestatisticmonth.FieldAddtime:
  27995. return m.AddedAddtime()
  27996. case usagestatisticmonth.FieldType:
  27997. return m.AddedType()
  27998. case usagestatisticmonth.FieldOrganizationID:
  27999. return m.AddedOrganizationID()
  28000. case usagestatisticmonth.FieldAiResponse:
  28001. return m.AddedAiResponse()
  28002. case usagestatisticmonth.FieldSopRun:
  28003. return m.AddedSopRun()
  28004. case usagestatisticmonth.FieldTotalFriend:
  28005. return m.AddedTotalFriend()
  28006. case usagestatisticmonth.FieldTotalGroup:
  28007. return m.AddedTotalGroup()
  28008. case usagestatisticmonth.FieldAccountBalance:
  28009. return m.AddedAccountBalance()
  28010. case usagestatisticmonth.FieldConsumeToken:
  28011. return m.AddedConsumeToken()
  28012. case usagestatisticmonth.FieldActiveUser:
  28013. return m.AddedActiveUser()
  28014. case usagestatisticmonth.FieldNewUser:
  28015. return m.AddedNewUser()
  28016. }
  28017. return nil, false
  28018. }
  28019. // AddField adds the value to the field with the given name. It returns an error if
  28020. // the field is not defined in the schema, or if the type mismatched the field
  28021. // type.
  28022. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  28023. switch name {
  28024. case usagestatisticmonth.FieldStatus:
  28025. v, ok := value.(int8)
  28026. if !ok {
  28027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28028. }
  28029. m.AddStatus(v)
  28030. return nil
  28031. case usagestatisticmonth.FieldAddtime:
  28032. v, ok := value.(int64)
  28033. if !ok {
  28034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28035. }
  28036. m.AddAddtime(v)
  28037. return nil
  28038. case usagestatisticmonth.FieldType:
  28039. v, ok := value.(int)
  28040. if !ok {
  28041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28042. }
  28043. m.AddType(v)
  28044. return nil
  28045. case usagestatisticmonth.FieldOrganizationID:
  28046. v, ok := value.(int64)
  28047. if !ok {
  28048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28049. }
  28050. m.AddOrganizationID(v)
  28051. return nil
  28052. case usagestatisticmonth.FieldAiResponse:
  28053. v, ok := value.(int64)
  28054. if !ok {
  28055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28056. }
  28057. m.AddAiResponse(v)
  28058. return nil
  28059. case usagestatisticmonth.FieldSopRun:
  28060. v, ok := value.(int64)
  28061. if !ok {
  28062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28063. }
  28064. m.AddSopRun(v)
  28065. return nil
  28066. case usagestatisticmonth.FieldTotalFriend:
  28067. v, ok := value.(int64)
  28068. if !ok {
  28069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28070. }
  28071. m.AddTotalFriend(v)
  28072. return nil
  28073. case usagestatisticmonth.FieldTotalGroup:
  28074. v, ok := value.(int64)
  28075. if !ok {
  28076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28077. }
  28078. m.AddTotalGroup(v)
  28079. return nil
  28080. case usagestatisticmonth.FieldAccountBalance:
  28081. v, ok := value.(int64)
  28082. if !ok {
  28083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28084. }
  28085. m.AddAccountBalance(v)
  28086. return nil
  28087. case usagestatisticmonth.FieldConsumeToken:
  28088. v, ok := value.(int64)
  28089. if !ok {
  28090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28091. }
  28092. m.AddConsumeToken(v)
  28093. return nil
  28094. case usagestatisticmonth.FieldActiveUser:
  28095. v, ok := value.(int64)
  28096. if !ok {
  28097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28098. }
  28099. m.AddActiveUser(v)
  28100. return nil
  28101. case usagestatisticmonth.FieldNewUser:
  28102. v, ok := value.(int64)
  28103. if !ok {
  28104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28105. }
  28106. m.AddNewUser(v)
  28107. return nil
  28108. }
  28109. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  28110. }
  28111. // ClearedFields returns all nullable fields that were cleared during this
  28112. // mutation.
  28113. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  28114. var fields []string
  28115. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  28116. fields = append(fields, usagestatisticmonth.FieldStatus)
  28117. }
  28118. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  28119. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  28120. }
  28121. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  28122. fields = append(fields, usagestatisticmonth.FieldBotID)
  28123. }
  28124. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  28125. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  28126. }
  28127. return fields
  28128. }
  28129. // FieldCleared returns a boolean indicating if a field with the given name was
  28130. // cleared in this mutation.
  28131. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  28132. _, ok := m.clearedFields[name]
  28133. return ok
  28134. }
  28135. // ClearField clears the value of the field with the given name. It returns an
  28136. // error if the field is not defined in the schema.
  28137. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  28138. switch name {
  28139. case usagestatisticmonth.FieldStatus:
  28140. m.ClearStatus()
  28141. return nil
  28142. case usagestatisticmonth.FieldDeletedAt:
  28143. m.ClearDeletedAt()
  28144. return nil
  28145. case usagestatisticmonth.FieldBotID:
  28146. m.ClearBotID()
  28147. return nil
  28148. case usagestatisticmonth.FieldOrganizationID:
  28149. m.ClearOrganizationID()
  28150. return nil
  28151. }
  28152. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  28153. }
  28154. // ResetField resets all changes in the mutation for the field with the given name.
  28155. // It returns an error if the field is not defined in the schema.
  28156. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  28157. switch name {
  28158. case usagestatisticmonth.FieldCreatedAt:
  28159. m.ResetCreatedAt()
  28160. return nil
  28161. case usagestatisticmonth.FieldUpdatedAt:
  28162. m.ResetUpdatedAt()
  28163. return nil
  28164. case usagestatisticmonth.FieldStatus:
  28165. m.ResetStatus()
  28166. return nil
  28167. case usagestatisticmonth.FieldDeletedAt:
  28168. m.ResetDeletedAt()
  28169. return nil
  28170. case usagestatisticmonth.FieldAddtime:
  28171. m.ResetAddtime()
  28172. return nil
  28173. case usagestatisticmonth.FieldType:
  28174. m.ResetType()
  28175. return nil
  28176. case usagestatisticmonth.FieldBotID:
  28177. m.ResetBotID()
  28178. return nil
  28179. case usagestatisticmonth.FieldOrganizationID:
  28180. m.ResetOrganizationID()
  28181. return nil
  28182. case usagestatisticmonth.FieldAiResponse:
  28183. m.ResetAiResponse()
  28184. return nil
  28185. case usagestatisticmonth.FieldSopRun:
  28186. m.ResetSopRun()
  28187. return nil
  28188. case usagestatisticmonth.FieldTotalFriend:
  28189. m.ResetTotalFriend()
  28190. return nil
  28191. case usagestatisticmonth.FieldTotalGroup:
  28192. m.ResetTotalGroup()
  28193. return nil
  28194. case usagestatisticmonth.FieldAccountBalance:
  28195. m.ResetAccountBalance()
  28196. return nil
  28197. case usagestatisticmonth.FieldConsumeToken:
  28198. m.ResetConsumeToken()
  28199. return nil
  28200. case usagestatisticmonth.FieldActiveUser:
  28201. m.ResetActiveUser()
  28202. return nil
  28203. case usagestatisticmonth.FieldNewUser:
  28204. m.ResetNewUser()
  28205. return nil
  28206. case usagestatisticmonth.FieldLabelDist:
  28207. m.ResetLabelDist()
  28208. return nil
  28209. }
  28210. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  28211. }
  28212. // AddedEdges returns all edge names that were set/added in this mutation.
  28213. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  28214. edges := make([]string, 0, 0)
  28215. return edges
  28216. }
  28217. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28218. // name in this mutation.
  28219. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  28220. return nil
  28221. }
  28222. // RemovedEdges returns all edge names that were removed in this mutation.
  28223. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  28224. edges := make([]string, 0, 0)
  28225. return edges
  28226. }
  28227. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28228. // the given name in this mutation.
  28229. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  28230. return nil
  28231. }
  28232. // ClearedEdges returns all edge names that were cleared in this mutation.
  28233. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  28234. edges := make([]string, 0, 0)
  28235. return edges
  28236. }
  28237. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28238. // was cleared in this mutation.
  28239. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  28240. return false
  28241. }
  28242. // ClearEdge clears the value of the edge with the given name. It returns an error
  28243. // if that edge is not defined in the schema.
  28244. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  28245. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  28246. }
  28247. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28248. // It returns an error if the edge is not defined in the schema.
  28249. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  28250. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  28251. }
  28252. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  28253. type UsageTotalMutation struct {
  28254. config
  28255. op Op
  28256. typ string
  28257. id *uint64
  28258. created_at *time.Time
  28259. updated_at *time.Time
  28260. status *uint8
  28261. addstatus *int8
  28262. _type *int
  28263. add_type *int
  28264. bot_id *string
  28265. total_tokens *uint64
  28266. addtotal_tokens *int64
  28267. start_index *uint64
  28268. addstart_index *int64
  28269. end_index *uint64
  28270. addend_index *int64
  28271. organization_id *uint64
  28272. addorganization_id *int64
  28273. clearedFields map[string]struct{}
  28274. done bool
  28275. oldValue func(context.Context) (*UsageTotal, error)
  28276. predicates []predicate.UsageTotal
  28277. }
  28278. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  28279. // usagetotalOption allows management of the mutation configuration using functional options.
  28280. type usagetotalOption func(*UsageTotalMutation)
  28281. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  28282. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  28283. m := &UsageTotalMutation{
  28284. config: c,
  28285. op: op,
  28286. typ: TypeUsageTotal,
  28287. clearedFields: make(map[string]struct{}),
  28288. }
  28289. for _, opt := range opts {
  28290. opt(m)
  28291. }
  28292. return m
  28293. }
  28294. // withUsageTotalID sets the ID field of the mutation.
  28295. func withUsageTotalID(id uint64) usagetotalOption {
  28296. return func(m *UsageTotalMutation) {
  28297. var (
  28298. err error
  28299. once sync.Once
  28300. value *UsageTotal
  28301. )
  28302. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  28303. once.Do(func() {
  28304. if m.done {
  28305. err = errors.New("querying old values post mutation is not allowed")
  28306. } else {
  28307. value, err = m.Client().UsageTotal.Get(ctx, id)
  28308. }
  28309. })
  28310. return value, err
  28311. }
  28312. m.id = &id
  28313. }
  28314. }
  28315. // withUsageTotal sets the old UsageTotal of the mutation.
  28316. func withUsageTotal(node *UsageTotal) usagetotalOption {
  28317. return func(m *UsageTotalMutation) {
  28318. m.oldValue = func(context.Context) (*UsageTotal, error) {
  28319. return node, nil
  28320. }
  28321. m.id = &node.ID
  28322. }
  28323. }
  28324. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28325. // executed in a transaction (ent.Tx), a transactional client is returned.
  28326. func (m UsageTotalMutation) Client() *Client {
  28327. client := &Client{config: m.config}
  28328. client.init()
  28329. return client
  28330. }
  28331. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28332. // it returns an error otherwise.
  28333. func (m UsageTotalMutation) Tx() (*Tx, error) {
  28334. if _, ok := m.driver.(*txDriver); !ok {
  28335. return nil, errors.New("ent: mutation is not running in a transaction")
  28336. }
  28337. tx := &Tx{config: m.config}
  28338. tx.init()
  28339. return tx, nil
  28340. }
  28341. // SetID sets the value of the id field. Note that this
  28342. // operation is only accepted on creation of UsageTotal entities.
  28343. func (m *UsageTotalMutation) SetID(id uint64) {
  28344. m.id = &id
  28345. }
  28346. // ID returns the ID value in the mutation. Note that the ID is only available
  28347. // if it was provided to the builder or after it was returned from the database.
  28348. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  28349. if m.id == nil {
  28350. return
  28351. }
  28352. return *m.id, true
  28353. }
  28354. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28355. // That means, if the mutation is applied within a transaction with an isolation level such
  28356. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28357. // or updated by the mutation.
  28358. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  28359. switch {
  28360. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28361. id, exists := m.ID()
  28362. if exists {
  28363. return []uint64{id}, nil
  28364. }
  28365. fallthrough
  28366. case m.op.Is(OpUpdate | OpDelete):
  28367. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  28368. default:
  28369. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28370. }
  28371. }
  28372. // SetCreatedAt sets the "created_at" field.
  28373. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  28374. m.created_at = &t
  28375. }
  28376. // CreatedAt returns the value of the "created_at" field in the mutation.
  28377. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  28378. v := m.created_at
  28379. if v == nil {
  28380. return
  28381. }
  28382. return *v, true
  28383. }
  28384. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  28385. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28387. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28388. if !m.op.Is(OpUpdateOne) {
  28389. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28390. }
  28391. if m.id == nil || m.oldValue == nil {
  28392. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28393. }
  28394. oldValue, err := m.oldValue(ctx)
  28395. if err != nil {
  28396. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28397. }
  28398. return oldValue.CreatedAt, nil
  28399. }
  28400. // ResetCreatedAt resets all changes to the "created_at" field.
  28401. func (m *UsageTotalMutation) ResetCreatedAt() {
  28402. m.created_at = nil
  28403. }
  28404. // SetUpdatedAt sets the "updated_at" field.
  28405. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  28406. m.updated_at = &t
  28407. }
  28408. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28409. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  28410. v := m.updated_at
  28411. if v == nil {
  28412. return
  28413. }
  28414. return *v, true
  28415. }
  28416. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  28417. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28419. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28420. if !m.op.Is(OpUpdateOne) {
  28421. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28422. }
  28423. if m.id == nil || m.oldValue == nil {
  28424. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28425. }
  28426. oldValue, err := m.oldValue(ctx)
  28427. if err != nil {
  28428. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28429. }
  28430. return oldValue.UpdatedAt, nil
  28431. }
  28432. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28433. func (m *UsageTotalMutation) ResetUpdatedAt() {
  28434. m.updated_at = nil
  28435. }
  28436. // SetStatus sets the "status" field.
  28437. func (m *UsageTotalMutation) SetStatus(u uint8) {
  28438. m.status = &u
  28439. m.addstatus = nil
  28440. }
  28441. // Status returns the value of the "status" field in the mutation.
  28442. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  28443. v := m.status
  28444. if v == nil {
  28445. return
  28446. }
  28447. return *v, true
  28448. }
  28449. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  28450. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28452. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28453. if !m.op.Is(OpUpdateOne) {
  28454. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28455. }
  28456. if m.id == nil || m.oldValue == nil {
  28457. return v, errors.New("OldStatus requires an ID field in the mutation")
  28458. }
  28459. oldValue, err := m.oldValue(ctx)
  28460. if err != nil {
  28461. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28462. }
  28463. return oldValue.Status, nil
  28464. }
  28465. // AddStatus adds u to the "status" field.
  28466. func (m *UsageTotalMutation) AddStatus(u int8) {
  28467. if m.addstatus != nil {
  28468. *m.addstatus += u
  28469. } else {
  28470. m.addstatus = &u
  28471. }
  28472. }
  28473. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28474. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  28475. v := m.addstatus
  28476. if v == nil {
  28477. return
  28478. }
  28479. return *v, true
  28480. }
  28481. // ClearStatus clears the value of the "status" field.
  28482. func (m *UsageTotalMutation) ClearStatus() {
  28483. m.status = nil
  28484. m.addstatus = nil
  28485. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  28486. }
  28487. // StatusCleared returns if the "status" field was cleared in this mutation.
  28488. func (m *UsageTotalMutation) StatusCleared() bool {
  28489. _, ok := m.clearedFields[usagetotal.FieldStatus]
  28490. return ok
  28491. }
  28492. // ResetStatus resets all changes to the "status" field.
  28493. func (m *UsageTotalMutation) ResetStatus() {
  28494. m.status = nil
  28495. m.addstatus = nil
  28496. delete(m.clearedFields, usagetotal.FieldStatus)
  28497. }
  28498. // SetType sets the "type" field.
  28499. func (m *UsageTotalMutation) SetType(i int) {
  28500. m._type = &i
  28501. m.add_type = nil
  28502. }
  28503. // GetType returns the value of the "type" field in the mutation.
  28504. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  28505. v := m._type
  28506. if v == nil {
  28507. return
  28508. }
  28509. return *v, true
  28510. }
  28511. // OldType returns the old "type" field's value of the UsageTotal entity.
  28512. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28514. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  28515. if !m.op.Is(OpUpdateOne) {
  28516. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28517. }
  28518. if m.id == nil || m.oldValue == nil {
  28519. return v, errors.New("OldType requires an ID field in the mutation")
  28520. }
  28521. oldValue, err := m.oldValue(ctx)
  28522. if err != nil {
  28523. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28524. }
  28525. return oldValue.Type, nil
  28526. }
  28527. // AddType adds i to the "type" field.
  28528. func (m *UsageTotalMutation) AddType(i int) {
  28529. if m.add_type != nil {
  28530. *m.add_type += i
  28531. } else {
  28532. m.add_type = &i
  28533. }
  28534. }
  28535. // AddedType returns the value that was added to the "type" field in this mutation.
  28536. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  28537. v := m.add_type
  28538. if v == nil {
  28539. return
  28540. }
  28541. return *v, true
  28542. }
  28543. // ClearType clears the value of the "type" field.
  28544. func (m *UsageTotalMutation) ClearType() {
  28545. m._type = nil
  28546. m.add_type = nil
  28547. m.clearedFields[usagetotal.FieldType] = struct{}{}
  28548. }
  28549. // TypeCleared returns if the "type" field was cleared in this mutation.
  28550. func (m *UsageTotalMutation) TypeCleared() bool {
  28551. _, ok := m.clearedFields[usagetotal.FieldType]
  28552. return ok
  28553. }
  28554. // ResetType resets all changes to the "type" field.
  28555. func (m *UsageTotalMutation) ResetType() {
  28556. m._type = nil
  28557. m.add_type = nil
  28558. delete(m.clearedFields, usagetotal.FieldType)
  28559. }
  28560. // SetBotID sets the "bot_id" field.
  28561. func (m *UsageTotalMutation) SetBotID(s string) {
  28562. m.bot_id = &s
  28563. }
  28564. // BotID returns the value of the "bot_id" field in the mutation.
  28565. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  28566. v := m.bot_id
  28567. if v == nil {
  28568. return
  28569. }
  28570. return *v, true
  28571. }
  28572. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  28573. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28575. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  28576. if !m.op.Is(OpUpdateOne) {
  28577. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28578. }
  28579. if m.id == nil || m.oldValue == nil {
  28580. return v, errors.New("OldBotID requires an ID field in the mutation")
  28581. }
  28582. oldValue, err := m.oldValue(ctx)
  28583. if err != nil {
  28584. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28585. }
  28586. return oldValue.BotID, nil
  28587. }
  28588. // ResetBotID resets all changes to the "bot_id" field.
  28589. func (m *UsageTotalMutation) ResetBotID() {
  28590. m.bot_id = nil
  28591. }
  28592. // SetTotalTokens sets the "total_tokens" field.
  28593. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  28594. m.total_tokens = &u
  28595. m.addtotal_tokens = nil
  28596. }
  28597. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  28598. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  28599. v := m.total_tokens
  28600. if v == nil {
  28601. return
  28602. }
  28603. return *v, true
  28604. }
  28605. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  28606. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28608. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  28609. if !m.op.Is(OpUpdateOne) {
  28610. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  28611. }
  28612. if m.id == nil || m.oldValue == nil {
  28613. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  28614. }
  28615. oldValue, err := m.oldValue(ctx)
  28616. if err != nil {
  28617. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  28618. }
  28619. return oldValue.TotalTokens, nil
  28620. }
  28621. // AddTotalTokens adds u to the "total_tokens" field.
  28622. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  28623. if m.addtotal_tokens != nil {
  28624. *m.addtotal_tokens += u
  28625. } else {
  28626. m.addtotal_tokens = &u
  28627. }
  28628. }
  28629. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  28630. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  28631. v := m.addtotal_tokens
  28632. if v == nil {
  28633. return
  28634. }
  28635. return *v, true
  28636. }
  28637. // ClearTotalTokens clears the value of the "total_tokens" field.
  28638. func (m *UsageTotalMutation) ClearTotalTokens() {
  28639. m.total_tokens = nil
  28640. m.addtotal_tokens = nil
  28641. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  28642. }
  28643. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  28644. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  28645. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  28646. return ok
  28647. }
  28648. // ResetTotalTokens resets all changes to the "total_tokens" field.
  28649. func (m *UsageTotalMutation) ResetTotalTokens() {
  28650. m.total_tokens = nil
  28651. m.addtotal_tokens = nil
  28652. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  28653. }
  28654. // SetStartIndex sets the "start_index" field.
  28655. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  28656. m.start_index = &u
  28657. m.addstart_index = nil
  28658. }
  28659. // StartIndex returns the value of the "start_index" field in the mutation.
  28660. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  28661. v := m.start_index
  28662. if v == nil {
  28663. return
  28664. }
  28665. return *v, true
  28666. }
  28667. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  28668. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28670. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  28671. if !m.op.Is(OpUpdateOne) {
  28672. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  28673. }
  28674. if m.id == nil || m.oldValue == nil {
  28675. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  28676. }
  28677. oldValue, err := m.oldValue(ctx)
  28678. if err != nil {
  28679. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  28680. }
  28681. return oldValue.StartIndex, nil
  28682. }
  28683. // AddStartIndex adds u to the "start_index" field.
  28684. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  28685. if m.addstart_index != nil {
  28686. *m.addstart_index += u
  28687. } else {
  28688. m.addstart_index = &u
  28689. }
  28690. }
  28691. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  28692. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  28693. v := m.addstart_index
  28694. if v == nil {
  28695. return
  28696. }
  28697. return *v, true
  28698. }
  28699. // ClearStartIndex clears the value of the "start_index" field.
  28700. func (m *UsageTotalMutation) ClearStartIndex() {
  28701. m.start_index = nil
  28702. m.addstart_index = nil
  28703. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  28704. }
  28705. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  28706. func (m *UsageTotalMutation) StartIndexCleared() bool {
  28707. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  28708. return ok
  28709. }
  28710. // ResetStartIndex resets all changes to the "start_index" field.
  28711. func (m *UsageTotalMutation) ResetStartIndex() {
  28712. m.start_index = nil
  28713. m.addstart_index = nil
  28714. delete(m.clearedFields, usagetotal.FieldStartIndex)
  28715. }
  28716. // SetEndIndex sets the "end_index" field.
  28717. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  28718. m.end_index = &u
  28719. m.addend_index = nil
  28720. }
  28721. // EndIndex returns the value of the "end_index" field in the mutation.
  28722. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  28723. v := m.end_index
  28724. if v == nil {
  28725. return
  28726. }
  28727. return *v, true
  28728. }
  28729. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  28730. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28732. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  28733. if !m.op.Is(OpUpdateOne) {
  28734. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  28735. }
  28736. if m.id == nil || m.oldValue == nil {
  28737. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  28738. }
  28739. oldValue, err := m.oldValue(ctx)
  28740. if err != nil {
  28741. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  28742. }
  28743. return oldValue.EndIndex, nil
  28744. }
  28745. // AddEndIndex adds u to the "end_index" field.
  28746. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  28747. if m.addend_index != nil {
  28748. *m.addend_index += u
  28749. } else {
  28750. m.addend_index = &u
  28751. }
  28752. }
  28753. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  28754. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  28755. v := m.addend_index
  28756. if v == nil {
  28757. return
  28758. }
  28759. return *v, true
  28760. }
  28761. // ClearEndIndex clears the value of the "end_index" field.
  28762. func (m *UsageTotalMutation) ClearEndIndex() {
  28763. m.end_index = nil
  28764. m.addend_index = nil
  28765. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  28766. }
  28767. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  28768. func (m *UsageTotalMutation) EndIndexCleared() bool {
  28769. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  28770. return ok
  28771. }
  28772. // ResetEndIndex resets all changes to the "end_index" field.
  28773. func (m *UsageTotalMutation) ResetEndIndex() {
  28774. m.end_index = nil
  28775. m.addend_index = nil
  28776. delete(m.clearedFields, usagetotal.FieldEndIndex)
  28777. }
  28778. // SetOrganizationID sets the "organization_id" field.
  28779. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  28780. m.organization_id = &u
  28781. m.addorganization_id = nil
  28782. }
  28783. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28784. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  28785. v := m.organization_id
  28786. if v == nil {
  28787. return
  28788. }
  28789. return *v, true
  28790. }
  28791. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  28792. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28794. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28795. if !m.op.Is(OpUpdateOne) {
  28796. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28797. }
  28798. if m.id == nil || m.oldValue == nil {
  28799. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28800. }
  28801. oldValue, err := m.oldValue(ctx)
  28802. if err != nil {
  28803. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28804. }
  28805. return oldValue.OrganizationID, nil
  28806. }
  28807. // AddOrganizationID adds u to the "organization_id" field.
  28808. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  28809. if m.addorganization_id != nil {
  28810. *m.addorganization_id += u
  28811. } else {
  28812. m.addorganization_id = &u
  28813. }
  28814. }
  28815. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28816. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  28817. v := m.addorganization_id
  28818. if v == nil {
  28819. return
  28820. }
  28821. return *v, true
  28822. }
  28823. // ClearOrganizationID clears the value of the "organization_id" field.
  28824. func (m *UsageTotalMutation) ClearOrganizationID() {
  28825. m.organization_id = nil
  28826. m.addorganization_id = nil
  28827. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  28828. }
  28829. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28830. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  28831. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  28832. return ok
  28833. }
  28834. // ResetOrganizationID resets all changes to the "organization_id" field.
  28835. func (m *UsageTotalMutation) ResetOrganizationID() {
  28836. m.organization_id = nil
  28837. m.addorganization_id = nil
  28838. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  28839. }
  28840. // Where appends a list predicates to the UsageTotalMutation builder.
  28841. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  28842. m.predicates = append(m.predicates, ps...)
  28843. }
  28844. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  28845. // users can use type-assertion to append predicates that do not depend on any generated package.
  28846. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  28847. p := make([]predicate.UsageTotal, len(ps))
  28848. for i := range ps {
  28849. p[i] = ps[i]
  28850. }
  28851. m.Where(p...)
  28852. }
  28853. // Op returns the operation name.
  28854. func (m *UsageTotalMutation) Op() Op {
  28855. return m.op
  28856. }
  28857. // SetOp allows setting the mutation operation.
  28858. func (m *UsageTotalMutation) SetOp(op Op) {
  28859. m.op = op
  28860. }
  28861. // Type returns the node type of this mutation (UsageTotal).
  28862. func (m *UsageTotalMutation) Type() string {
  28863. return m.typ
  28864. }
  28865. // Fields returns all fields that were changed during this mutation. Note that in
  28866. // order to get all numeric fields that were incremented/decremented, call
  28867. // AddedFields().
  28868. func (m *UsageTotalMutation) Fields() []string {
  28869. fields := make([]string, 0, 9)
  28870. if m.created_at != nil {
  28871. fields = append(fields, usagetotal.FieldCreatedAt)
  28872. }
  28873. if m.updated_at != nil {
  28874. fields = append(fields, usagetotal.FieldUpdatedAt)
  28875. }
  28876. if m.status != nil {
  28877. fields = append(fields, usagetotal.FieldStatus)
  28878. }
  28879. if m._type != nil {
  28880. fields = append(fields, usagetotal.FieldType)
  28881. }
  28882. if m.bot_id != nil {
  28883. fields = append(fields, usagetotal.FieldBotID)
  28884. }
  28885. if m.total_tokens != nil {
  28886. fields = append(fields, usagetotal.FieldTotalTokens)
  28887. }
  28888. if m.start_index != nil {
  28889. fields = append(fields, usagetotal.FieldStartIndex)
  28890. }
  28891. if m.end_index != nil {
  28892. fields = append(fields, usagetotal.FieldEndIndex)
  28893. }
  28894. if m.organization_id != nil {
  28895. fields = append(fields, usagetotal.FieldOrganizationID)
  28896. }
  28897. return fields
  28898. }
  28899. // Field returns the value of a field with the given name. The second boolean
  28900. // return value indicates that this field was not set, or was not defined in the
  28901. // schema.
  28902. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  28903. switch name {
  28904. case usagetotal.FieldCreatedAt:
  28905. return m.CreatedAt()
  28906. case usagetotal.FieldUpdatedAt:
  28907. return m.UpdatedAt()
  28908. case usagetotal.FieldStatus:
  28909. return m.Status()
  28910. case usagetotal.FieldType:
  28911. return m.GetType()
  28912. case usagetotal.FieldBotID:
  28913. return m.BotID()
  28914. case usagetotal.FieldTotalTokens:
  28915. return m.TotalTokens()
  28916. case usagetotal.FieldStartIndex:
  28917. return m.StartIndex()
  28918. case usagetotal.FieldEndIndex:
  28919. return m.EndIndex()
  28920. case usagetotal.FieldOrganizationID:
  28921. return m.OrganizationID()
  28922. }
  28923. return nil, false
  28924. }
  28925. // OldField returns the old value of the field from the database. An error is
  28926. // returned if the mutation operation is not UpdateOne, or the query to the
  28927. // database failed.
  28928. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28929. switch name {
  28930. case usagetotal.FieldCreatedAt:
  28931. return m.OldCreatedAt(ctx)
  28932. case usagetotal.FieldUpdatedAt:
  28933. return m.OldUpdatedAt(ctx)
  28934. case usagetotal.FieldStatus:
  28935. return m.OldStatus(ctx)
  28936. case usagetotal.FieldType:
  28937. return m.OldType(ctx)
  28938. case usagetotal.FieldBotID:
  28939. return m.OldBotID(ctx)
  28940. case usagetotal.FieldTotalTokens:
  28941. return m.OldTotalTokens(ctx)
  28942. case usagetotal.FieldStartIndex:
  28943. return m.OldStartIndex(ctx)
  28944. case usagetotal.FieldEndIndex:
  28945. return m.OldEndIndex(ctx)
  28946. case usagetotal.FieldOrganizationID:
  28947. return m.OldOrganizationID(ctx)
  28948. }
  28949. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  28950. }
  28951. // SetField sets the value of a field with the given name. It returns an error if
  28952. // the field is not defined in the schema, or if the type mismatched the field
  28953. // type.
  28954. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  28955. switch name {
  28956. case usagetotal.FieldCreatedAt:
  28957. v, ok := value.(time.Time)
  28958. if !ok {
  28959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28960. }
  28961. m.SetCreatedAt(v)
  28962. return nil
  28963. case usagetotal.FieldUpdatedAt:
  28964. v, ok := value.(time.Time)
  28965. if !ok {
  28966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28967. }
  28968. m.SetUpdatedAt(v)
  28969. return nil
  28970. case usagetotal.FieldStatus:
  28971. v, ok := value.(uint8)
  28972. if !ok {
  28973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28974. }
  28975. m.SetStatus(v)
  28976. return nil
  28977. case usagetotal.FieldType:
  28978. v, ok := value.(int)
  28979. if !ok {
  28980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28981. }
  28982. m.SetType(v)
  28983. return nil
  28984. case usagetotal.FieldBotID:
  28985. v, ok := value.(string)
  28986. if !ok {
  28987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28988. }
  28989. m.SetBotID(v)
  28990. return nil
  28991. case usagetotal.FieldTotalTokens:
  28992. v, ok := value.(uint64)
  28993. if !ok {
  28994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28995. }
  28996. m.SetTotalTokens(v)
  28997. return nil
  28998. case usagetotal.FieldStartIndex:
  28999. v, ok := value.(uint64)
  29000. if !ok {
  29001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29002. }
  29003. m.SetStartIndex(v)
  29004. return nil
  29005. case usagetotal.FieldEndIndex:
  29006. v, ok := value.(uint64)
  29007. if !ok {
  29008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29009. }
  29010. m.SetEndIndex(v)
  29011. return nil
  29012. case usagetotal.FieldOrganizationID:
  29013. v, ok := value.(uint64)
  29014. if !ok {
  29015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29016. }
  29017. m.SetOrganizationID(v)
  29018. return nil
  29019. }
  29020. return fmt.Errorf("unknown UsageTotal field %s", name)
  29021. }
  29022. // AddedFields returns all numeric fields that were incremented/decremented during
  29023. // this mutation.
  29024. func (m *UsageTotalMutation) AddedFields() []string {
  29025. var fields []string
  29026. if m.addstatus != nil {
  29027. fields = append(fields, usagetotal.FieldStatus)
  29028. }
  29029. if m.add_type != nil {
  29030. fields = append(fields, usagetotal.FieldType)
  29031. }
  29032. if m.addtotal_tokens != nil {
  29033. fields = append(fields, usagetotal.FieldTotalTokens)
  29034. }
  29035. if m.addstart_index != nil {
  29036. fields = append(fields, usagetotal.FieldStartIndex)
  29037. }
  29038. if m.addend_index != nil {
  29039. fields = append(fields, usagetotal.FieldEndIndex)
  29040. }
  29041. if m.addorganization_id != nil {
  29042. fields = append(fields, usagetotal.FieldOrganizationID)
  29043. }
  29044. return fields
  29045. }
  29046. // AddedField returns the numeric value that was incremented/decremented on a field
  29047. // with the given name. The second boolean return value indicates that this field
  29048. // was not set, or was not defined in the schema.
  29049. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  29050. switch name {
  29051. case usagetotal.FieldStatus:
  29052. return m.AddedStatus()
  29053. case usagetotal.FieldType:
  29054. return m.AddedType()
  29055. case usagetotal.FieldTotalTokens:
  29056. return m.AddedTotalTokens()
  29057. case usagetotal.FieldStartIndex:
  29058. return m.AddedStartIndex()
  29059. case usagetotal.FieldEndIndex:
  29060. return m.AddedEndIndex()
  29061. case usagetotal.FieldOrganizationID:
  29062. return m.AddedOrganizationID()
  29063. }
  29064. return nil, false
  29065. }
  29066. // AddField adds the value to the field with the given name. It returns an error if
  29067. // the field is not defined in the schema, or if the type mismatched the field
  29068. // type.
  29069. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  29070. switch name {
  29071. case usagetotal.FieldStatus:
  29072. v, ok := value.(int8)
  29073. if !ok {
  29074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29075. }
  29076. m.AddStatus(v)
  29077. return nil
  29078. case usagetotal.FieldType:
  29079. v, ok := value.(int)
  29080. if !ok {
  29081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29082. }
  29083. m.AddType(v)
  29084. return nil
  29085. case usagetotal.FieldTotalTokens:
  29086. v, ok := value.(int64)
  29087. if !ok {
  29088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29089. }
  29090. m.AddTotalTokens(v)
  29091. return nil
  29092. case usagetotal.FieldStartIndex:
  29093. v, ok := value.(int64)
  29094. if !ok {
  29095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29096. }
  29097. m.AddStartIndex(v)
  29098. return nil
  29099. case usagetotal.FieldEndIndex:
  29100. v, ok := value.(int64)
  29101. if !ok {
  29102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29103. }
  29104. m.AddEndIndex(v)
  29105. return nil
  29106. case usagetotal.FieldOrganizationID:
  29107. v, ok := value.(int64)
  29108. if !ok {
  29109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29110. }
  29111. m.AddOrganizationID(v)
  29112. return nil
  29113. }
  29114. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  29115. }
  29116. // ClearedFields returns all nullable fields that were cleared during this
  29117. // mutation.
  29118. func (m *UsageTotalMutation) ClearedFields() []string {
  29119. var fields []string
  29120. if m.FieldCleared(usagetotal.FieldStatus) {
  29121. fields = append(fields, usagetotal.FieldStatus)
  29122. }
  29123. if m.FieldCleared(usagetotal.FieldType) {
  29124. fields = append(fields, usagetotal.FieldType)
  29125. }
  29126. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  29127. fields = append(fields, usagetotal.FieldTotalTokens)
  29128. }
  29129. if m.FieldCleared(usagetotal.FieldStartIndex) {
  29130. fields = append(fields, usagetotal.FieldStartIndex)
  29131. }
  29132. if m.FieldCleared(usagetotal.FieldEndIndex) {
  29133. fields = append(fields, usagetotal.FieldEndIndex)
  29134. }
  29135. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  29136. fields = append(fields, usagetotal.FieldOrganizationID)
  29137. }
  29138. return fields
  29139. }
  29140. // FieldCleared returns a boolean indicating if a field with the given name was
  29141. // cleared in this mutation.
  29142. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  29143. _, ok := m.clearedFields[name]
  29144. return ok
  29145. }
  29146. // ClearField clears the value of the field with the given name. It returns an
  29147. // error if the field is not defined in the schema.
  29148. func (m *UsageTotalMutation) ClearField(name string) error {
  29149. switch name {
  29150. case usagetotal.FieldStatus:
  29151. m.ClearStatus()
  29152. return nil
  29153. case usagetotal.FieldType:
  29154. m.ClearType()
  29155. return nil
  29156. case usagetotal.FieldTotalTokens:
  29157. m.ClearTotalTokens()
  29158. return nil
  29159. case usagetotal.FieldStartIndex:
  29160. m.ClearStartIndex()
  29161. return nil
  29162. case usagetotal.FieldEndIndex:
  29163. m.ClearEndIndex()
  29164. return nil
  29165. case usagetotal.FieldOrganizationID:
  29166. m.ClearOrganizationID()
  29167. return nil
  29168. }
  29169. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  29170. }
  29171. // ResetField resets all changes in the mutation for the field with the given name.
  29172. // It returns an error if the field is not defined in the schema.
  29173. func (m *UsageTotalMutation) ResetField(name string) error {
  29174. switch name {
  29175. case usagetotal.FieldCreatedAt:
  29176. m.ResetCreatedAt()
  29177. return nil
  29178. case usagetotal.FieldUpdatedAt:
  29179. m.ResetUpdatedAt()
  29180. return nil
  29181. case usagetotal.FieldStatus:
  29182. m.ResetStatus()
  29183. return nil
  29184. case usagetotal.FieldType:
  29185. m.ResetType()
  29186. return nil
  29187. case usagetotal.FieldBotID:
  29188. m.ResetBotID()
  29189. return nil
  29190. case usagetotal.FieldTotalTokens:
  29191. m.ResetTotalTokens()
  29192. return nil
  29193. case usagetotal.FieldStartIndex:
  29194. m.ResetStartIndex()
  29195. return nil
  29196. case usagetotal.FieldEndIndex:
  29197. m.ResetEndIndex()
  29198. return nil
  29199. case usagetotal.FieldOrganizationID:
  29200. m.ResetOrganizationID()
  29201. return nil
  29202. }
  29203. return fmt.Errorf("unknown UsageTotal field %s", name)
  29204. }
  29205. // AddedEdges returns all edge names that were set/added in this mutation.
  29206. func (m *UsageTotalMutation) AddedEdges() []string {
  29207. edges := make([]string, 0, 0)
  29208. return edges
  29209. }
  29210. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29211. // name in this mutation.
  29212. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  29213. return nil
  29214. }
  29215. // RemovedEdges returns all edge names that were removed in this mutation.
  29216. func (m *UsageTotalMutation) RemovedEdges() []string {
  29217. edges := make([]string, 0, 0)
  29218. return edges
  29219. }
  29220. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29221. // the given name in this mutation.
  29222. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  29223. return nil
  29224. }
  29225. // ClearedEdges returns all edge names that were cleared in this mutation.
  29226. func (m *UsageTotalMutation) ClearedEdges() []string {
  29227. edges := make([]string, 0, 0)
  29228. return edges
  29229. }
  29230. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29231. // was cleared in this mutation.
  29232. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  29233. return false
  29234. }
  29235. // ClearEdge clears the value of the edge with the given name. It returns an error
  29236. // if that edge is not defined in the schema.
  29237. func (m *UsageTotalMutation) ClearEdge(name string) error {
  29238. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  29239. }
  29240. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29241. // It returns an error if the edge is not defined in the schema.
  29242. func (m *UsageTotalMutation) ResetEdge(name string) error {
  29243. return fmt.Errorf("unknown UsageTotal edge %s", name)
  29244. }
  29245. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  29246. type WorkExperienceMutation struct {
  29247. config
  29248. op Op
  29249. typ string
  29250. id *uint64
  29251. created_at *time.Time
  29252. updated_at *time.Time
  29253. deleted_at *time.Time
  29254. start_date *time.Time
  29255. end_date *time.Time
  29256. company *string
  29257. experience *string
  29258. organization_id *uint64
  29259. addorganization_id *int64
  29260. clearedFields map[string]struct{}
  29261. employee *uint64
  29262. clearedemployee bool
  29263. done bool
  29264. oldValue func(context.Context) (*WorkExperience, error)
  29265. predicates []predicate.WorkExperience
  29266. }
  29267. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  29268. // workexperienceOption allows management of the mutation configuration using functional options.
  29269. type workexperienceOption func(*WorkExperienceMutation)
  29270. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  29271. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  29272. m := &WorkExperienceMutation{
  29273. config: c,
  29274. op: op,
  29275. typ: TypeWorkExperience,
  29276. clearedFields: make(map[string]struct{}),
  29277. }
  29278. for _, opt := range opts {
  29279. opt(m)
  29280. }
  29281. return m
  29282. }
  29283. // withWorkExperienceID sets the ID field of the mutation.
  29284. func withWorkExperienceID(id uint64) workexperienceOption {
  29285. return func(m *WorkExperienceMutation) {
  29286. var (
  29287. err error
  29288. once sync.Once
  29289. value *WorkExperience
  29290. )
  29291. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  29292. once.Do(func() {
  29293. if m.done {
  29294. err = errors.New("querying old values post mutation is not allowed")
  29295. } else {
  29296. value, err = m.Client().WorkExperience.Get(ctx, id)
  29297. }
  29298. })
  29299. return value, err
  29300. }
  29301. m.id = &id
  29302. }
  29303. }
  29304. // withWorkExperience sets the old WorkExperience of the mutation.
  29305. func withWorkExperience(node *WorkExperience) workexperienceOption {
  29306. return func(m *WorkExperienceMutation) {
  29307. m.oldValue = func(context.Context) (*WorkExperience, error) {
  29308. return node, nil
  29309. }
  29310. m.id = &node.ID
  29311. }
  29312. }
  29313. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29314. // executed in a transaction (ent.Tx), a transactional client is returned.
  29315. func (m WorkExperienceMutation) Client() *Client {
  29316. client := &Client{config: m.config}
  29317. client.init()
  29318. return client
  29319. }
  29320. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29321. // it returns an error otherwise.
  29322. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  29323. if _, ok := m.driver.(*txDriver); !ok {
  29324. return nil, errors.New("ent: mutation is not running in a transaction")
  29325. }
  29326. tx := &Tx{config: m.config}
  29327. tx.init()
  29328. return tx, nil
  29329. }
  29330. // SetID sets the value of the id field. Note that this
  29331. // operation is only accepted on creation of WorkExperience entities.
  29332. func (m *WorkExperienceMutation) SetID(id uint64) {
  29333. m.id = &id
  29334. }
  29335. // ID returns the ID value in the mutation. Note that the ID is only available
  29336. // if it was provided to the builder or after it was returned from the database.
  29337. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  29338. if m.id == nil {
  29339. return
  29340. }
  29341. return *m.id, true
  29342. }
  29343. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29344. // That means, if the mutation is applied within a transaction with an isolation level such
  29345. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29346. // or updated by the mutation.
  29347. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  29348. switch {
  29349. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29350. id, exists := m.ID()
  29351. if exists {
  29352. return []uint64{id}, nil
  29353. }
  29354. fallthrough
  29355. case m.op.Is(OpUpdate | OpDelete):
  29356. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  29357. default:
  29358. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29359. }
  29360. }
  29361. // SetCreatedAt sets the "created_at" field.
  29362. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  29363. m.created_at = &t
  29364. }
  29365. // CreatedAt returns the value of the "created_at" field in the mutation.
  29366. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  29367. v := m.created_at
  29368. if v == nil {
  29369. return
  29370. }
  29371. return *v, true
  29372. }
  29373. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  29374. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29376. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29377. if !m.op.Is(OpUpdateOne) {
  29378. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29379. }
  29380. if m.id == nil || m.oldValue == nil {
  29381. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29382. }
  29383. oldValue, err := m.oldValue(ctx)
  29384. if err != nil {
  29385. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29386. }
  29387. return oldValue.CreatedAt, nil
  29388. }
  29389. // ResetCreatedAt resets all changes to the "created_at" field.
  29390. func (m *WorkExperienceMutation) ResetCreatedAt() {
  29391. m.created_at = nil
  29392. }
  29393. // SetUpdatedAt sets the "updated_at" field.
  29394. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  29395. m.updated_at = &t
  29396. }
  29397. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29398. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  29399. v := m.updated_at
  29400. if v == nil {
  29401. return
  29402. }
  29403. return *v, true
  29404. }
  29405. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  29406. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29408. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29409. if !m.op.Is(OpUpdateOne) {
  29410. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29411. }
  29412. if m.id == nil || m.oldValue == nil {
  29413. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29414. }
  29415. oldValue, err := m.oldValue(ctx)
  29416. if err != nil {
  29417. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29418. }
  29419. return oldValue.UpdatedAt, nil
  29420. }
  29421. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29422. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  29423. m.updated_at = nil
  29424. }
  29425. // SetDeletedAt sets the "deleted_at" field.
  29426. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  29427. m.deleted_at = &t
  29428. }
  29429. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29430. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  29431. v := m.deleted_at
  29432. if v == nil {
  29433. return
  29434. }
  29435. return *v, true
  29436. }
  29437. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  29438. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29440. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29441. if !m.op.Is(OpUpdateOne) {
  29442. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29443. }
  29444. if m.id == nil || m.oldValue == nil {
  29445. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29446. }
  29447. oldValue, err := m.oldValue(ctx)
  29448. if err != nil {
  29449. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29450. }
  29451. return oldValue.DeletedAt, nil
  29452. }
  29453. // ClearDeletedAt clears the value of the "deleted_at" field.
  29454. func (m *WorkExperienceMutation) ClearDeletedAt() {
  29455. m.deleted_at = nil
  29456. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  29457. }
  29458. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29459. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  29460. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  29461. return ok
  29462. }
  29463. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29464. func (m *WorkExperienceMutation) ResetDeletedAt() {
  29465. m.deleted_at = nil
  29466. delete(m.clearedFields, workexperience.FieldDeletedAt)
  29467. }
  29468. // SetEmployeeID sets the "employee_id" field.
  29469. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  29470. m.employee = &u
  29471. }
  29472. // EmployeeID returns the value of the "employee_id" field in the mutation.
  29473. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  29474. v := m.employee
  29475. if v == nil {
  29476. return
  29477. }
  29478. return *v, true
  29479. }
  29480. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  29481. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29483. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  29484. if !m.op.Is(OpUpdateOne) {
  29485. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  29486. }
  29487. if m.id == nil || m.oldValue == nil {
  29488. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  29489. }
  29490. oldValue, err := m.oldValue(ctx)
  29491. if err != nil {
  29492. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  29493. }
  29494. return oldValue.EmployeeID, nil
  29495. }
  29496. // ResetEmployeeID resets all changes to the "employee_id" field.
  29497. func (m *WorkExperienceMutation) ResetEmployeeID() {
  29498. m.employee = nil
  29499. }
  29500. // SetStartDate sets the "start_date" field.
  29501. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  29502. m.start_date = &t
  29503. }
  29504. // StartDate returns the value of the "start_date" field in the mutation.
  29505. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  29506. v := m.start_date
  29507. if v == nil {
  29508. return
  29509. }
  29510. return *v, true
  29511. }
  29512. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  29513. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29515. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  29516. if !m.op.Is(OpUpdateOne) {
  29517. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  29518. }
  29519. if m.id == nil || m.oldValue == nil {
  29520. return v, errors.New("OldStartDate requires an ID field in the mutation")
  29521. }
  29522. oldValue, err := m.oldValue(ctx)
  29523. if err != nil {
  29524. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  29525. }
  29526. return oldValue.StartDate, nil
  29527. }
  29528. // ResetStartDate resets all changes to the "start_date" field.
  29529. func (m *WorkExperienceMutation) ResetStartDate() {
  29530. m.start_date = nil
  29531. }
  29532. // SetEndDate sets the "end_date" field.
  29533. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  29534. m.end_date = &t
  29535. }
  29536. // EndDate returns the value of the "end_date" field in the mutation.
  29537. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  29538. v := m.end_date
  29539. if v == nil {
  29540. return
  29541. }
  29542. return *v, true
  29543. }
  29544. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  29545. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29547. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  29548. if !m.op.Is(OpUpdateOne) {
  29549. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  29550. }
  29551. if m.id == nil || m.oldValue == nil {
  29552. return v, errors.New("OldEndDate requires an ID field in the mutation")
  29553. }
  29554. oldValue, err := m.oldValue(ctx)
  29555. if err != nil {
  29556. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  29557. }
  29558. return oldValue.EndDate, nil
  29559. }
  29560. // ResetEndDate resets all changes to the "end_date" field.
  29561. func (m *WorkExperienceMutation) ResetEndDate() {
  29562. m.end_date = nil
  29563. }
  29564. // SetCompany sets the "company" field.
  29565. func (m *WorkExperienceMutation) SetCompany(s string) {
  29566. m.company = &s
  29567. }
  29568. // Company returns the value of the "company" field in the mutation.
  29569. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  29570. v := m.company
  29571. if v == nil {
  29572. return
  29573. }
  29574. return *v, true
  29575. }
  29576. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  29577. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29579. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  29580. if !m.op.Is(OpUpdateOne) {
  29581. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  29582. }
  29583. if m.id == nil || m.oldValue == nil {
  29584. return v, errors.New("OldCompany requires an ID field in the mutation")
  29585. }
  29586. oldValue, err := m.oldValue(ctx)
  29587. if err != nil {
  29588. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  29589. }
  29590. return oldValue.Company, nil
  29591. }
  29592. // ResetCompany resets all changes to the "company" field.
  29593. func (m *WorkExperienceMutation) ResetCompany() {
  29594. m.company = nil
  29595. }
  29596. // SetExperience sets the "experience" field.
  29597. func (m *WorkExperienceMutation) SetExperience(s string) {
  29598. m.experience = &s
  29599. }
  29600. // Experience returns the value of the "experience" field in the mutation.
  29601. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  29602. v := m.experience
  29603. if v == nil {
  29604. return
  29605. }
  29606. return *v, true
  29607. }
  29608. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  29609. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29611. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  29612. if !m.op.Is(OpUpdateOne) {
  29613. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  29614. }
  29615. if m.id == nil || m.oldValue == nil {
  29616. return v, errors.New("OldExperience requires an ID field in the mutation")
  29617. }
  29618. oldValue, err := m.oldValue(ctx)
  29619. if err != nil {
  29620. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  29621. }
  29622. return oldValue.Experience, nil
  29623. }
  29624. // ResetExperience resets all changes to the "experience" field.
  29625. func (m *WorkExperienceMutation) ResetExperience() {
  29626. m.experience = nil
  29627. }
  29628. // SetOrganizationID sets the "organization_id" field.
  29629. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  29630. m.organization_id = &u
  29631. m.addorganization_id = nil
  29632. }
  29633. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29634. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  29635. v := m.organization_id
  29636. if v == nil {
  29637. return
  29638. }
  29639. return *v, true
  29640. }
  29641. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  29642. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29644. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29645. if !m.op.Is(OpUpdateOne) {
  29646. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29647. }
  29648. if m.id == nil || m.oldValue == nil {
  29649. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29650. }
  29651. oldValue, err := m.oldValue(ctx)
  29652. if err != nil {
  29653. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29654. }
  29655. return oldValue.OrganizationID, nil
  29656. }
  29657. // AddOrganizationID adds u to the "organization_id" field.
  29658. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  29659. if m.addorganization_id != nil {
  29660. *m.addorganization_id += u
  29661. } else {
  29662. m.addorganization_id = &u
  29663. }
  29664. }
  29665. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29666. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  29667. v := m.addorganization_id
  29668. if v == nil {
  29669. return
  29670. }
  29671. return *v, true
  29672. }
  29673. // ResetOrganizationID resets all changes to the "organization_id" field.
  29674. func (m *WorkExperienceMutation) ResetOrganizationID() {
  29675. m.organization_id = nil
  29676. m.addorganization_id = nil
  29677. }
  29678. // ClearEmployee clears the "employee" edge to the Employee entity.
  29679. func (m *WorkExperienceMutation) ClearEmployee() {
  29680. m.clearedemployee = true
  29681. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  29682. }
  29683. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  29684. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  29685. return m.clearedemployee
  29686. }
  29687. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  29688. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29689. // EmployeeID instead. It exists only for internal usage by the builders.
  29690. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  29691. if id := m.employee; id != nil {
  29692. ids = append(ids, *id)
  29693. }
  29694. return
  29695. }
  29696. // ResetEmployee resets all changes to the "employee" edge.
  29697. func (m *WorkExperienceMutation) ResetEmployee() {
  29698. m.employee = nil
  29699. m.clearedemployee = false
  29700. }
  29701. // Where appends a list predicates to the WorkExperienceMutation builder.
  29702. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  29703. m.predicates = append(m.predicates, ps...)
  29704. }
  29705. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  29706. // users can use type-assertion to append predicates that do not depend on any generated package.
  29707. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  29708. p := make([]predicate.WorkExperience, len(ps))
  29709. for i := range ps {
  29710. p[i] = ps[i]
  29711. }
  29712. m.Where(p...)
  29713. }
  29714. // Op returns the operation name.
  29715. func (m *WorkExperienceMutation) Op() Op {
  29716. return m.op
  29717. }
  29718. // SetOp allows setting the mutation operation.
  29719. func (m *WorkExperienceMutation) SetOp(op Op) {
  29720. m.op = op
  29721. }
  29722. // Type returns the node type of this mutation (WorkExperience).
  29723. func (m *WorkExperienceMutation) Type() string {
  29724. return m.typ
  29725. }
  29726. // Fields returns all fields that were changed during this mutation. Note that in
  29727. // order to get all numeric fields that were incremented/decremented, call
  29728. // AddedFields().
  29729. func (m *WorkExperienceMutation) Fields() []string {
  29730. fields := make([]string, 0, 9)
  29731. if m.created_at != nil {
  29732. fields = append(fields, workexperience.FieldCreatedAt)
  29733. }
  29734. if m.updated_at != nil {
  29735. fields = append(fields, workexperience.FieldUpdatedAt)
  29736. }
  29737. if m.deleted_at != nil {
  29738. fields = append(fields, workexperience.FieldDeletedAt)
  29739. }
  29740. if m.employee != nil {
  29741. fields = append(fields, workexperience.FieldEmployeeID)
  29742. }
  29743. if m.start_date != nil {
  29744. fields = append(fields, workexperience.FieldStartDate)
  29745. }
  29746. if m.end_date != nil {
  29747. fields = append(fields, workexperience.FieldEndDate)
  29748. }
  29749. if m.company != nil {
  29750. fields = append(fields, workexperience.FieldCompany)
  29751. }
  29752. if m.experience != nil {
  29753. fields = append(fields, workexperience.FieldExperience)
  29754. }
  29755. if m.organization_id != nil {
  29756. fields = append(fields, workexperience.FieldOrganizationID)
  29757. }
  29758. return fields
  29759. }
  29760. // Field returns the value of a field with the given name. The second boolean
  29761. // return value indicates that this field was not set, or was not defined in the
  29762. // schema.
  29763. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  29764. switch name {
  29765. case workexperience.FieldCreatedAt:
  29766. return m.CreatedAt()
  29767. case workexperience.FieldUpdatedAt:
  29768. return m.UpdatedAt()
  29769. case workexperience.FieldDeletedAt:
  29770. return m.DeletedAt()
  29771. case workexperience.FieldEmployeeID:
  29772. return m.EmployeeID()
  29773. case workexperience.FieldStartDate:
  29774. return m.StartDate()
  29775. case workexperience.FieldEndDate:
  29776. return m.EndDate()
  29777. case workexperience.FieldCompany:
  29778. return m.Company()
  29779. case workexperience.FieldExperience:
  29780. return m.Experience()
  29781. case workexperience.FieldOrganizationID:
  29782. return m.OrganizationID()
  29783. }
  29784. return nil, false
  29785. }
  29786. // OldField returns the old value of the field from the database. An error is
  29787. // returned if the mutation operation is not UpdateOne, or the query to the
  29788. // database failed.
  29789. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29790. switch name {
  29791. case workexperience.FieldCreatedAt:
  29792. return m.OldCreatedAt(ctx)
  29793. case workexperience.FieldUpdatedAt:
  29794. return m.OldUpdatedAt(ctx)
  29795. case workexperience.FieldDeletedAt:
  29796. return m.OldDeletedAt(ctx)
  29797. case workexperience.FieldEmployeeID:
  29798. return m.OldEmployeeID(ctx)
  29799. case workexperience.FieldStartDate:
  29800. return m.OldStartDate(ctx)
  29801. case workexperience.FieldEndDate:
  29802. return m.OldEndDate(ctx)
  29803. case workexperience.FieldCompany:
  29804. return m.OldCompany(ctx)
  29805. case workexperience.FieldExperience:
  29806. return m.OldExperience(ctx)
  29807. case workexperience.FieldOrganizationID:
  29808. return m.OldOrganizationID(ctx)
  29809. }
  29810. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  29811. }
  29812. // SetField sets the value of a field with the given name. It returns an error if
  29813. // the field is not defined in the schema, or if the type mismatched the field
  29814. // type.
  29815. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  29816. switch name {
  29817. case workexperience.FieldCreatedAt:
  29818. v, ok := value.(time.Time)
  29819. if !ok {
  29820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29821. }
  29822. m.SetCreatedAt(v)
  29823. return nil
  29824. case workexperience.FieldUpdatedAt:
  29825. v, ok := value.(time.Time)
  29826. if !ok {
  29827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29828. }
  29829. m.SetUpdatedAt(v)
  29830. return nil
  29831. case workexperience.FieldDeletedAt:
  29832. v, ok := value.(time.Time)
  29833. if !ok {
  29834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29835. }
  29836. m.SetDeletedAt(v)
  29837. return nil
  29838. case workexperience.FieldEmployeeID:
  29839. v, ok := value.(uint64)
  29840. if !ok {
  29841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29842. }
  29843. m.SetEmployeeID(v)
  29844. return nil
  29845. case workexperience.FieldStartDate:
  29846. v, ok := value.(time.Time)
  29847. if !ok {
  29848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29849. }
  29850. m.SetStartDate(v)
  29851. return nil
  29852. case workexperience.FieldEndDate:
  29853. v, ok := value.(time.Time)
  29854. if !ok {
  29855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29856. }
  29857. m.SetEndDate(v)
  29858. return nil
  29859. case workexperience.FieldCompany:
  29860. v, ok := value.(string)
  29861. if !ok {
  29862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29863. }
  29864. m.SetCompany(v)
  29865. return nil
  29866. case workexperience.FieldExperience:
  29867. v, ok := value.(string)
  29868. if !ok {
  29869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29870. }
  29871. m.SetExperience(v)
  29872. return nil
  29873. case workexperience.FieldOrganizationID:
  29874. v, ok := value.(uint64)
  29875. if !ok {
  29876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29877. }
  29878. m.SetOrganizationID(v)
  29879. return nil
  29880. }
  29881. return fmt.Errorf("unknown WorkExperience field %s", name)
  29882. }
  29883. // AddedFields returns all numeric fields that were incremented/decremented during
  29884. // this mutation.
  29885. func (m *WorkExperienceMutation) AddedFields() []string {
  29886. var fields []string
  29887. if m.addorganization_id != nil {
  29888. fields = append(fields, workexperience.FieldOrganizationID)
  29889. }
  29890. return fields
  29891. }
  29892. // AddedField returns the numeric value that was incremented/decremented on a field
  29893. // with the given name. The second boolean return value indicates that this field
  29894. // was not set, or was not defined in the schema.
  29895. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  29896. switch name {
  29897. case workexperience.FieldOrganizationID:
  29898. return m.AddedOrganizationID()
  29899. }
  29900. return nil, false
  29901. }
  29902. // AddField adds the value to the field with the given name. It returns an error if
  29903. // the field is not defined in the schema, or if the type mismatched the field
  29904. // type.
  29905. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  29906. switch name {
  29907. case workexperience.FieldOrganizationID:
  29908. v, ok := value.(int64)
  29909. if !ok {
  29910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29911. }
  29912. m.AddOrganizationID(v)
  29913. return nil
  29914. }
  29915. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  29916. }
  29917. // ClearedFields returns all nullable fields that were cleared during this
  29918. // mutation.
  29919. func (m *WorkExperienceMutation) ClearedFields() []string {
  29920. var fields []string
  29921. if m.FieldCleared(workexperience.FieldDeletedAt) {
  29922. fields = append(fields, workexperience.FieldDeletedAt)
  29923. }
  29924. return fields
  29925. }
  29926. // FieldCleared returns a boolean indicating if a field with the given name was
  29927. // cleared in this mutation.
  29928. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  29929. _, ok := m.clearedFields[name]
  29930. return ok
  29931. }
  29932. // ClearField clears the value of the field with the given name. It returns an
  29933. // error if the field is not defined in the schema.
  29934. func (m *WorkExperienceMutation) ClearField(name string) error {
  29935. switch name {
  29936. case workexperience.FieldDeletedAt:
  29937. m.ClearDeletedAt()
  29938. return nil
  29939. }
  29940. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  29941. }
  29942. // ResetField resets all changes in the mutation for the field with the given name.
  29943. // It returns an error if the field is not defined in the schema.
  29944. func (m *WorkExperienceMutation) ResetField(name string) error {
  29945. switch name {
  29946. case workexperience.FieldCreatedAt:
  29947. m.ResetCreatedAt()
  29948. return nil
  29949. case workexperience.FieldUpdatedAt:
  29950. m.ResetUpdatedAt()
  29951. return nil
  29952. case workexperience.FieldDeletedAt:
  29953. m.ResetDeletedAt()
  29954. return nil
  29955. case workexperience.FieldEmployeeID:
  29956. m.ResetEmployeeID()
  29957. return nil
  29958. case workexperience.FieldStartDate:
  29959. m.ResetStartDate()
  29960. return nil
  29961. case workexperience.FieldEndDate:
  29962. m.ResetEndDate()
  29963. return nil
  29964. case workexperience.FieldCompany:
  29965. m.ResetCompany()
  29966. return nil
  29967. case workexperience.FieldExperience:
  29968. m.ResetExperience()
  29969. return nil
  29970. case workexperience.FieldOrganizationID:
  29971. m.ResetOrganizationID()
  29972. return nil
  29973. }
  29974. return fmt.Errorf("unknown WorkExperience field %s", name)
  29975. }
  29976. // AddedEdges returns all edge names that were set/added in this mutation.
  29977. func (m *WorkExperienceMutation) AddedEdges() []string {
  29978. edges := make([]string, 0, 1)
  29979. if m.employee != nil {
  29980. edges = append(edges, workexperience.EdgeEmployee)
  29981. }
  29982. return edges
  29983. }
  29984. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29985. // name in this mutation.
  29986. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  29987. switch name {
  29988. case workexperience.EdgeEmployee:
  29989. if id := m.employee; id != nil {
  29990. return []ent.Value{*id}
  29991. }
  29992. }
  29993. return nil
  29994. }
  29995. // RemovedEdges returns all edge names that were removed in this mutation.
  29996. func (m *WorkExperienceMutation) RemovedEdges() []string {
  29997. edges := make([]string, 0, 1)
  29998. return edges
  29999. }
  30000. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30001. // the given name in this mutation.
  30002. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  30003. return nil
  30004. }
  30005. // ClearedEdges returns all edge names that were cleared in this mutation.
  30006. func (m *WorkExperienceMutation) ClearedEdges() []string {
  30007. edges := make([]string, 0, 1)
  30008. if m.clearedemployee {
  30009. edges = append(edges, workexperience.EdgeEmployee)
  30010. }
  30011. return edges
  30012. }
  30013. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30014. // was cleared in this mutation.
  30015. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  30016. switch name {
  30017. case workexperience.EdgeEmployee:
  30018. return m.clearedemployee
  30019. }
  30020. return false
  30021. }
  30022. // ClearEdge clears the value of the edge with the given name. It returns an error
  30023. // if that edge is not defined in the schema.
  30024. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  30025. switch name {
  30026. case workexperience.EdgeEmployee:
  30027. m.ClearEmployee()
  30028. return nil
  30029. }
  30030. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  30031. }
  30032. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30033. // It returns an error if the edge is not defined in the schema.
  30034. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  30035. switch name {
  30036. case workexperience.EdgeEmployee:
  30037. m.ResetEmployee()
  30038. return nil
  30039. }
  30040. return fmt.Errorf("unknown WorkExperience edge %s", name)
  30041. }
  30042. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  30043. type WpChatroomMutation struct {
  30044. config
  30045. op Op
  30046. typ string
  30047. id *uint64
  30048. created_at *time.Time
  30049. updated_at *time.Time
  30050. status *uint8
  30051. addstatus *int8
  30052. wx_wxid *string
  30053. chatroom_id *string
  30054. nickname *string
  30055. owner *string
  30056. avatar *string
  30057. member_list *[]string
  30058. appendmember_list []string
  30059. clearedFields map[string]struct{}
  30060. done bool
  30061. oldValue func(context.Context) (*WpChatroom, error)
  30062. predicates []predicate.WpChatroom
  30063. }
  30064. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  30065. // wpchatroomOption allows management of the mutation configuration using functional options.
  30066. type wpchatroomOption func(*WpChatroomMutation)
  30067. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  30068. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  30069. m := &WpChatroomMutation{
  30070. config: c,
  30071. op: op,
  30072. typ: TypeWpChatroom,
  30073. clearedFields: make(map[string]struct{}),
  30074. }
  30075. for _, opt := range opts {
  30076. opt(m)
  30077. }
  30078. return m
  30079. }
  30080. // withWpChatroomID sets the ID field of the mutation.
  30081. func withWpChatroomID(id uint64) wpchatroomOption {
  30082. return func(m *WpChatroomMutation) {
  30083. var (
  30084. err error
  30085. once sync.Once
  30086. value *WpChatroom
  30087. )
  30088. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  30089. once.Do(func() {
  30090. if m.done {
  30091. err = errors.New("querying old values post mutation is not allowed")
  30092. } else {
  30093. value, err = m.Client().WpChatroom.Get(ctx, id)
  30094. }
  30095. })
  30096. return value, err
  30097. }
  30098. m.id = &id
  30099. }
  30100. }
  30101. // withWpChatroom sets the old WpChatroom of the mutation.
  30102. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  30103. return func(m *WpChatroomMutation) {
  30104. m.oldValue = func(context.Context) (*WpChatroom, error) {
  30105. return node, nil
  30106. }
  30107. m.id = &node.ID
  30108. }
  30109. }
  30110. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30111. // executed in a transaction (ent.Tx), a transactional client is returned.
  30112. func (m WpChatroomMutation) Client() *Client {
  30113. client := &Client{config: m.config}
  30114. client.init()
  30115. return client
  30116. }
  30117. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30118. // it returns an error otherwise.
  30119. func (m WpChatroomMutation) Tx() (*Tx, error) {
  30120. if _, ok := m.driver.(*txDriver); !ok {
  30121. return nil, errors.New("ent: mutation is not running in a transaction")
  30122. }
  30123. tx := &Tx{config: m.config}
  30124. tx.init()
  30125. return tx, nil
  30126. }
  30127. // SetID sets the value of the id field. Note that this
  30128. // operation is only accepted on creation of WpChatroom entities.
  30129. func (m *WpChatroomMutation) SetID(id uint64) {
  30130. m.id = &id
  30131. }
  30132. // ID returns the ID value in the mutation. Note that the ID is only available
  30133. // if it was provided to the builder or after it was returned from the database.
  30134. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  30135. if m.id == nil {
  30136. return
  30137. }
  30138. return *m.id, true
  30139. }
  30140. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30141. // That means, if the mutation is applied within a transaction with an isolation level such
  30142. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30143. // or updated by the mutation.
  30144. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  30145. switch {
  30146. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30147. id, exists := m.ID()
  30148. if exists {
  30149. return []uint64{id}, nil
  30150. }
  30151. fallthrough
  30152. case m.op.Is(OpUpdate | OpDelete):
  30153. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  30154. default:
  30155. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30156. }
  30157. }
  30158. // SetCreatedAt sets the "created_at" field.
  30159. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  30160. m.created_at = &t
  30161. }
  30162. // CreatedAt returns the value of the "created_at" field in the mutation.
  30163. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  30164. v := m.created_at
  30165. if v == nil {
  30166. return
  30167. }
  30168. return *v, true
  30169. }
  30170. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  30171. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30173. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30174. if !m.op.Is(OpUpdateOne) {
  30175. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30176. }
  30177. if m.id == nil || m.oldValue == nil {
  30178. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30179. }
  30180. oldValue, err := m.oldValue(ctx)
  30181. if err != nil {
  30182. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30183. }
  30184. return oldValue.CreatedAt, nil
  30185. }
  30186. // ResetCreatedAt resets all changes to the "created_at" field.
  30187. func (m *WpChatroomMutation) ResetCreatedAt() {
  30188. m.created_at = nil
  30189. }
  30190. // SetUpdatedAt sets the "updated_at" field.
  30191. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  30192. m.updated_at = &t
  30193. }
  30194. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30195. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  30196. v := m.updated_at
  30197. if v == nil {
  30198. return
  30199. }
  30200. return *v, true
  30201. }
  30202. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  30203. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30205. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30206. if !m.op.Is(OpUpdateOne) {
  30207. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30208. }
  30209. if m.id == nil || m.oldValue == nil {
  30210. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30211. }
  30212. oldValue, err := m.oldValue(ctx)
  30213. if err != nil {
  30214. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30215. }
  30216. return oldValue.UpdatedAt, nil
  30217. }
  30218. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30219. func (m *WpChatroomMutation) ResetUpdatedAt() {
  30220. m.updated_at = nil
  30221. }
  30222. // SetStatus sets the "status" field.
  30223. func (m *WpChatroomMutation) SetStatus(u uint8) {
  30224. m.status = &u
  30225. m.addstatus = nil
  30226. }
  30227. // Status returns the value of the "status" field in the mutation.
  30228. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  30229. v := m.status
  30230. if v == nil {
  30231. return
  30232. }
  30233. return *v, true
  30234. }
  30235. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  30236. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30238. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30239. if !m.op.Is(OpUpdateOne) {
  30240. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30241. }
  30242. if m.id == nil || m.oldValue == nil {
  30243. return v, errors.New("OldStatus requires an ID field in the mutation")
  30244. }
  30245. oldValue, err := m.oldValue(ctx)
  30246. if err != nil {
  30247. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30248. }
  30249. return oldValue.Status, nil
  30250. }
  30251. // AddStatus adds u to the "status" field.
  30252. func (m *WpChatroomMutation) AddStatus(u int8) {
  30253. if m.addstatus != nil {
  30254. *m.addstatus += u
  30255. } else {
  30256. m.addstatus = &u
  30257. }
  30258. }
  30259. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30260. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  30261. v := m.addstatus
  30262. if v == nil {
  30263. return
  30264. }
  30265. return *v, true
  30266. }
  30267. // ClearStatus clears the value of the "status" field.
  30268. func (m *WpChatroomMutation) ClearStatus() {
  30269. m.status = nil
  30270. m.addstatus = nil
  30271. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  30272. }
  30273. // StatusCleared returns if the "status" field was cleared in this mutation.
  30274. func (m *WpChatroomMutation) StatusCleared() bool {
  30275. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  30276. return ok
  30277. }
  30278. // ResetStatus resets all changes to the "status" field.
  30279. func (m *WpChatroomMutation) ResetStatus() {
  30280. m.status = nil
  30281. m.addstatus = nil
  30282. delete(m.clearedFields, wpchatroom.FieldStatus)
  30283. }
  30284. // SetWxWxid sets the "wx_wxid" field.
  30285. func (m *WpChatroomMutation) SetWxWxid(s string) {
  30286. m.wx_wxid = &s
  30287. }
  30288. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  30289. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  30290. v := m.wx_wxid
  30291. if v == nil {
  30292. return
  30293. }
  30294. return *v, true
  30295. }
  30296. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  30297. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30299. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  30300. if !m.op.Is(OpUpdateOne) {
  30301. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  30302. }
  30303. if m.id == nil || m.oldValue == nil {
  30304. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  30305. }
  30306. oldValue, err := m.oldValue(ctx)
  30307. if err != nil {
  30308. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  30309. }
  30310. return oldValue.WxWxid, nil
  30311. }
  30312. // ResetWxWxid resets all changes to the "wx_wxid" field.
  30313. func (m *WpChatroomMutation) ResetWxWxid() {
  30314. m.wx_wxid = nil
  30315. }
  30316. // SetChatroomID sets the "chatroom_id" field.
  30317. func (m *WpChatroomMutation) SetChatroomID(s string) {
  30318. m.chatroom_id = &s
  30319. }
  30320. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  30321. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  30322. v := m.chatroom_id
  30323. if v == nil {
  30324. return
  30325. }
  30326. return *v, true
  30327. }
  30328. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  30329. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30331. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  30332. if !m.op.Is(OpUpdateOne) {
  30333. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  30334. }
  30335. if m.id == nil || m.oldValue == nil {
  30336. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  30337. }
  30338. oldValue, err := m.oldValue(ctx)
  30339. if err != nil {
  30340. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  30341. }
  30342. return oldValue.ChatroomID, nil
  30343. }
  30344. // ResetChatroomID resets all changes to the "chatroom_id" field.
  30345. func (m *WpChatroomMutation) ResetChatroomID() {
  30346. m.chatroom_id = nil
  30347. }
  30348. // SetNickname sets the "nickname" field.
  30349. func (m *WpChatroomMutation) SetNickname(s string) {
  30350. m.nickname = &s
  30351. }
  30352. // Nickname returns the value of the "nickname" field in the mutation.
  30353. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  30354. v := m.nickname
  30355. if v == nil {
  30356. return
  30357. }
  30358. return *v, true
  30359. }
  30360. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  30361. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30363. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  30364. if !m.op.Is(OpUpdateOne) {
  30365. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  30366. }
  30367. if m.id == nil || m.oldValue == nil {
  30368. return v, errors.New("OldNickname requires an ID field in the mutation")
  30369. }
  30370. oldValue, err := m.oldValue(ctx)
  30371. if err != nil {
  30372. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  30373. }
  30374. return oldValue.Nickname, nil
  30375. }
  30376. // ResetNickname resets all changes to the "nickname" field.
  30377. func (m *WpChatroomMutation) ResetNickname() {
  30378. m.nickname = nil
  30379. }
  30380. // SetOwner sets the "owner" field.
  30381. func (m *WpChatroomMutation) SetOwner(s string) {
  30382. m.owner = &s
  30383. }
  30384. // Owner returns the value of the "owner" field in the mutation.
  30385. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  30386. v := m.owner
  30387. if v == nil {
  30388. return
  30389. }
  30390. return *v, true
  30391. }
  30392. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  30393. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30395. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  30396. if !m.op.Is(OpUpdateOne) {
  30397. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  30398. }
  30399. if m.id == nil || m.oldValue == nil {
  30400. return v, errors.New("OldOwner requires an ID field in the mutation")
  30401. }
  30402. oldValue, err := m.oldValue(ctx)
  30403. if err != nil {
  30404. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  30405. }
  30406. return oldValue.Owner, nil
  30407. }
  30408. // ResetOwner resets all changes to the "owner" field.
  30409. func (m *WpChatroomMutation) ResetOwner() {
  30410. m.owner = nil
  30411. }
  30412. // SetAvatar sets the "avatar" field.
  30413. func (m *WpChatroomMutation) SetAvatar(s string) {
  30414. m.avatar = &s
  30415. }
  30416. // Avatar returns the value of the "avatar" field in the mutation.
  30417. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  30418. v := m.avatar
  30419. if v == nil {
  30420. return
  30421. }
  30422. return *v, true
  30423. }
  30424. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  30425. // If the WpChatroom 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 *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  30428. if !m.op.Is(OpUpdateOne) {
  30429. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  30430. }
  30431. if m.id == nil || m.oldValue == nil {
  30432. return v, errors.New("OldAvatar 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 OldAvatar: %w", err)
  30437. }
  30438. return oldValue.Avatar, nil
  30439. }
  30440. // ResetAvatar resets all changes to the "avatar" field.
  30441. func (m *WpChatroomMutation) ResetAvatar() {
  30442. m.avatar = nil
  30443. }
  30444. // SetMemberList sets the "member_list" field.
  30445. func (m *WpChatroomMutation) SetMemberList(s []string) {
  30446. m.member_list = &s
  30447. m.appendmember_list = nil
  30448. }
  30449. // MemberList returns the value of the "member_list" field in the mutation.
  30450. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  30451. v := m.member_list
  30452. if v == nil {
  30453. return
  30454. }
  30455. return *v, true
  30456. }
  30457. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  30458. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30460. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  30461. if !m.op.Is(OpUpdateOne) {
  30462. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  30463. }
  30464. if m.id == nil || m.oldValue == nil {
  30465. return v, errors.New("OldMemberList requires an ID field in the mutation")
  30466. }
  30467. oldValue, err := m.oldValue(ctx)
  30468. if err != nil {
  30469. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  30470. }
  30471. return oldValue.MemberList, nil
  30472. }
  30473. // AppendMemberList adds s to the "member_list" field.
  30474. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  30475. m.appendmember_list = append(m.appendmember_list, s...)
  30476. }
  30477. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  30478. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  30479. if len(m.appendmember_list) == 0 {
  30480. return nil, false
  30481. }
  30482. return m.appendmember_list, true
  30483. }
  30484. // ResetMemberList resets all changes to the "member_list" field.
  30485. func (m *WpChatroomMutation) ResetMemberList() {
  30486. m.member_list = nil
  30487. m.appendmember_list = nil
  30488. }
  30489. // Where appends a list predicates to the WpChatroomMutation builder.
  30490. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  30491. m.predicates = append(m.predicates, ps...)
  30492. }
  30493. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  30494. // users can use type-assertion to append predicates that do not depend on any generated package.
  30495. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  30496. p := make([]predicate.WpChatroom, len(ps))
  30497. for i := range ps {
  30498. p[i] = ps[i]
  30499. }
  30500. m.Where(p...)
  30501. }
  30502. // Op returns the operation name.
  30503. func (m *WpChatroomMutation) Op() Op {
  30504. return m.op
  30505. }
  30506. // SetOp allows setting the mutation operation.
  30507. func (m *WpChatroomMutation) SetOp(op Op) {
  30508. m.op = op
  30509. }
  30510. // Type returns the node type of this mutation (WpChatroom).
  30511. func (m *WpChatroomMutation) Type() string {
  30512. return m.typ
  30513. }
  30514. // Fields returns all fields that were changed during this mutation. Note that in
  30515. // order to get all numeric fields that were incremented/decremented, call
  30516. // AddedFields().
  30517. func (m *WpChatroomMutation) Fields() []string {
  30518. fields := make([]string, 0, 9)
  30519. if m.created_at != nil {
  30520. fields = append(fields, wpchatroom.FieldCreatedAt)
  30521. }
  30522. if m.updated_at != nil {
  30523. fields = append(fields, wpchatroom.FieldUpdatedAt)
  30524. }
  30525. if m.status != nil {
  30526. fields = append(fields, wpchatroom.FieldStatus)
  30527. }
  30528. if m.wx_wxid != nil {
  30529. fields = append(fields, wpchatroom.FieldWxWxid)
  30530. }
  30531. if m.chatroom_id != nil {
  30532. fields = append(fields, wpchatroom.FieldChatroomID)
  30533. }
  30534. if m.nickname != nil {
  30535. fields = append(fields, wpchatroom.FieldNickname)
  30536. }
  30537. if m.owner != nil {
  30538. fields = append(fields, wpchatroom.FieldOwner)
  30539. }
  30540. if m.avatar != nil {
  30541. fields = append(fields, wpchatroom.FieldAvatar)
  30542. }
  30543. if m.member_list != nil {
  30544. fields = append(fields, wpchatroom.FieldMemberList)
  30545. }
  30546. return fields
  30547. }
  30548. // Field returns the value of a field with the given name. The second boolean
  30549. // return value indicates that this field was not set, or was not defined in the
  30550. // schema.
  30551. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  30552. switch name {
  30553. case wpchatroom.FieldCreatedAt:
  30554. return m.CreatedAt()
  30555. case wpchatroom.FieldUpdatedAt:
  30556. return m.UpdatedAt()
  30557. case wpchatroom.FieldStatus:
  30558. return m.Status()
  30559. case wpchatroom.FieldWxWxid:
  30560. return m.WxWxid()
  30561. case wpchatroom.FieldChatroomID:
  30562. return m.ChatroomID()
  30563. case wpchatroom.FieldNickname:
  30564. return m.Nickname()
  30565. case wpchatroom.FieldOwner:
  30566. return m.Owner()
  30567. case wpchatroom.FieldAvatar:
  30568. return m.Avatar()
  30569. case wpchatroom.FieldMemberList:
  30570. return m.MemberList()
  30571. }
  30572. return nil, false
  30573. }
  30574. // OldField returns the old value of the field from the database. An error is
  30575. // returned if the mutation operation is not UpdateOne, or the query to the
  30576. // database failed.
  30577. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30578. switch name {
  30579. case wpchatroom.FieldCreatedAt:
  30580. return m.OldCreatedAt(ctx)
  30581. case wpchatroom.FieldUpdatedAt:
  30582. return m.OldUpdatedAt(ctx)
  30583. case wpchatroom.FieldStatus:
  30584. return m.OldStatus(ctx)
  30585. case wpchatroom.FieldWxWxid:
  30586. return m.OldWxWxid(ctx)
  30587. case wpchatroom.FieldChatroomID:
  30588. return m.OldChatroomID(ctx)
  30589. case wpchatroom.FieldNickname:
  30590. return m.OldNickname(ctx)
  30591. case wpchatroom.FieldOwner:
  30592. return m.OldOwner(ctx)
  30593. case wpchatroom.FieldAvatar:
  30594. return m.OldAvatar(ctx)
  30595. case wpchatroom.FieldMemberList:
  30596. return m.OldMemberList(ctx)
  30597. }
  30598. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  30599. }
  30600. // SetField sets the value of a field with the given name. It returns an error if
  30601. // the field is not defined in the schema, or if the type mismatched the field
  30602. // type.
  30603. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  30604. switch name {
  30605. case wpchatroom.FieldCreatedAt:
  30606. v, ok := value.(time.Time)
  30607. if !ok {
  30608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30609. }
  30610. m.SetCreatedAt(v)
  30611. return nil
  30612. case wpchatroom.FieldUpdatedAt:
  30613. v, ok := value.(time.Time)
  30614. if !ok {
  30615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30616. }
  30617. m.SetUpdatedAt(v)
  30618. return nil
  30619. case wpchatroom.FieldStatus:
  30620. v, ok := value.(uint8)
  30621. if !ok {
  30622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30623. }
  30624. m.SetStatus(v)
  30625. return nil
  30626. case wpchatroom.FieldWxWxid:
  30627. v, ok := value.(string)
  30628. if !ok {
  30629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30630. }
  30631. m.SetWxWxid(v)
  30632. return nil
  30633. case wpchatroom.FieldChatroomID:
  30634. v, ok := value.(string)
  30635. if !ok {
  30636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30637. }
  30638. m.SetChatroomID(v)
  30639. return nil
  30640. case wpchatroom.FieldNickname:
  30641. v, ok := value.(string)
  30642. if !ok {
  30643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30644. }
  30645. m.SetNickname(v)
  30646. return nil
  30647. case wpchatroom.FieldOwner:
  30648. v, ok := value.(string)
  30649. if !ok {
  30650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30651. }
  30652. m.SetOwner(v)
  30653. return nil
  30654. case wpchatroom.FieldAvatar:
  30655. v, ok := value.(string)
  30656. if !ok {
  30657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30658. }
  30659. m.SetAvatar(v)
  30660. return nil
  30661. case wpchatroom.FieldMemberList:
  30662. v, ok := value.([]string)
  30663. if !ok {
  30664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30665. }
  30666. m.SetMemberList(v)
  30667. return nil
  30668. }
  30669. return fmt.Errorf("unknown WpChatroom field %s", name)
  30670. }
  30671. // AddedFields returns all numeric fields that were incremented/decremented during
  30672. // this mutation.
  30673. func (m *WpChatroomMutation) AddedFields() []string {
  30674. var fields []string
  30675. if m.addstatus != nil {
  30676. fields = append(fields, wpchatroom.FieldStatus)
  30677. }
  30678. return fields
  30679. }
  30680. // AddedField returns the numeric value that was incremented/decremented on a field
  30681. // with the given name. The second boolean return value indicates that this field
  30682. // was not set, or was not defined in the schema.
  30683. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  30684. switch name {
  30685. case wpchatroom.FieldStatus:
  30686. return m.AddedStatus()
  30687. }
  30688. return nil, false
  30689. }
  30690. // AddField adds the value to the field with the given name. It returns an error if
  30691. // the field is not defined in the schema, or if the type mismatched the field
  30692. // type.
  30693. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  30694. switch name {
  30695. case wpchatroom.FieldStatus:
  30696. v, ok := value.(int8)
  30697. if !ok {
  30698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30699. }
  30700. m.AddStatus(v)
  30701. return nil
  30702. }
  30703. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  30704. }
  30705. // ClearedFields returns all nullable fields that were cleared during this
  30706. // mutation.
  30707. func (m *WpChatroomMutation) ClearedFields() []string {
  30708. var fields []string
  30709. if m.FieldCleared(wpchatroom.FieldStatus) {
  30710. fields = append(fields, wpchatroom.FieldStatus)
  30711. }
  30712. return fields
  30713. }
  30714. // FieldCleared returns a boolean indicating if a field with the given name was
  30715. // cleared in this mutation.
  30716. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  30717. _, ok := m.clearedFields[name]
  30718. return ok
  30719. }
  30720. // ClearField clears the value of the field with the given name. It returns an
  30721. // error if the field is not defined in the schema.
  30722. func (m *WpChatroomMutation) ClearField(name string) error {
  30723. switch name {
  30724. case wpchatroom.FieldStatus:
  30725. m.ClearStatus()
  30726. return nil
  30727. }
  30728. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  30729. }
  30730. // ResetField resets all changes in the mutation for the field with the given name.
  30731. // It returns an error if the field is not defined in the schema.
  30732. func (m *WpChatroomMutation) ResetField(name string) error {
  30733. switch name {
  30734. case wpchatroom.FieldCreatedAt:
  30735. m.ResetCreatedAt()
  30736. return nil
  30737. case wpchatroom.FieldUpdatedAt:
  30738. m.ResetUpdatedAt()
  30739. return nil
  30740. case wpchatroom.FieldStatus:
  30741. m.ResetStatus()
  30742. return nil
  30743. case wpchatroom.FieldWxWxid:
  30744. m.ResetWxWxid()
  30745. return nil
  30746. case wpchatroom.FieldChatroomID:
  30747. m.ResetChatroomID()
  30748. return nil
  30749. case wpchatroom.FieldNickname:
  30750. m.ResetNickname()
  30751. return nil
  30752. case wpchatroom.FieldOwner:
  30753. m.ResetOwner()
  30754. return nil
  30755. case wpchatroom.FieldAvatar:
  30756. m.ResetAvatar()
  30757. return nil
  30758. case wpchatroom.FieldMemberList:
  30759. m.ResetMemberList()
  30760. return nil
  30761. }
  30762. return fmt.Errorf("unknown WpChatroom field %s", name)
  30763. }
  30764. // AddedEdges returns all edge names that were set/added in this mutation.
  30765. func (m *WpChatroomMutation) AddedEdges() []string {
  30766. edges := make([]string, 0, 0)
  30767. return edges
  30768. }
  30769. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30770. // name in this mutation.
  30771. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  30772. return nil
  30773. }
  30774. // RemovedEdges returns all edge names that were removed in this mutation.
  30775. func (m *WpChatroomMutation) RemovedEdges() []string {
  30776. edges := make([]string, 0, 0)
  30777. return edges
  30778. }
  30779. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30780. // the given name in this mutation.
  30781. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  30782. return nil
  30783. }
  30784. // ClearedEdges returns all edge names that were cleared in this mutation.
  30785. func (m *WpChatroomMutation) ClearedEdges() []string {
  30786. edges := make([]string, 0, 0)
  30787. return edges
  30788. }
  30789. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30790. // was cleared in this mutation.
  30791. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  30792. return false
  30793. }
  30794. // ClearEdge clears the value of the edge with the given name. It returns an error
  30795. // if that edge is not defined in the schema.
  30796. func (m *WpChatroomMutation) ClearEdge(name string) error {
  30797. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  30798. }
  30799. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30800. // It returns an error if the edge is not defined in the schema.
  30801. func (m *WpChatroomMutation) ResetEdge(name string) error {
  30802. return fmt.Errorf("unknown WpChatroom edge %s", name)
  30803. }
  30804. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  30805. type WpChatroomMemberMutation struct {
  30806. config
  30807. op Op
  30808. typ string
  30809. id *uint64
  30810. created_at *time.Time
  30811. updated_at *time.Time
  30812. status *uint8
  30813. addstatus *int8
  30814. wx_wxid *string
  30815. wxid *string
  30816. nickname *string
  30817. avatar *string
  30818. clearedFields map[string]struct{}
  30819. done bool
  30820. oldValue func(context.Context) (*WpChatroomMember, error)
  30821. predicates []predicate.WpChatroomMember
  30822. }
  30823. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  30824. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  30825. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  30826. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  30827. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  30828. m := &WpChatroomMemberMutation{
  30829. config: c,
  30830. op: op,
  30831. typ: TypeWpChatroomMember,
  30832. clearedFields: make(map[string]struct{}),
  30833. }
  30834. for _, opt := range opts {
  30835. opt(m)
  30836. }
  30837. return m
  30838. }
  30839. // withWpChatroomMemberID sets the ID field of the mutation.
  30840. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  30841. return func(m *WpChatroomMemberMutation) {
  30842. var (
  30843. err error
  30844. once sync.Once
  30845. value *WpChatroomMember
  30846. )
  30847. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  30848. once.Do(func() {
  30849. if m.done {
  30850. err = errors.New("querying old values post mutation is not allowed")
  30851. } else {
  30852. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  30853. }
  30854. })
  30855. return value, err
  30856. }
  30857. m.id = &id
  30858. }
  30859. }
  30860. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  30861. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  30862. return func(m *WpChatroomMemberMutation) {
  30863. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  30864. return node, nil
  30865. }
  30866. m.id = &node.ID
  30867. }
  30868. }
  30869. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30870. // executed in a transaction (ent.Tx), a transactional client is returned.
  30871. func (m WpChatroomMemberMutation) Client() *Client {
  30872. client := &Client{config: m.config}
  30873. client.init()
  30874. return client
  30875. }
  30876. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30877. // it returns an error otherwise.
  30878. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  30879. if _, ok := m.driver.(*txDriver); !ok {
  30880. return nil, errors.New("ent: mutation is not running in a transaction")
  30881. }
  30882. tx := &Tx{config: m.config}
  30883. tx.init()
  30884. return tx, nil
  30885. }
  30886. // SetID sets the value of the id field. Note that this
  30887. // operation is only accepted on creation of WpChatroomMember entities.
  30888. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  30889. m.id = &id
  30890. }
  30891. // ID returns the ID value in the mutation. Note that the ID is only available
  30892. // if it was provided to the builder or after it was returned from the database.
  30893. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  30894. if m.id == nil {
  30895. return
  30896. }
  30897. return *m.id, true
  30898. }
  30899. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30900. // That means, if the mutation is applied within a transaction with an isolation level such
  30901. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30902. // or updated by the mutation.
  30903. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  30904. switch {
  30905. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30906. id, exists := m.ID()
  30907. if exists {
  30908. return []uint64{id}, nil
  30909. }
  30910. fallthrough
  30911. case m.op.Is(OpUpdate | OpDelete):
  30912. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  30913. default:
  30914. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30915. }
  30916. }
  30917. // SetCreatedAt sets the "created_at" field.
  30918. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  30919. m.created_at = &t
  30920. }
  30921. // CreatedAt returns the value of the "created_at" field in the mutation.
  30922. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  30923. v := m.created_at
  30924. if v == nil {
  30925. return
  30926. }
  30927. return *v, true
  30928. }
  30929. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  30930. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  30931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30932. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30933. if !m.op.Is(OpUpdateOne) {
  30934. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30935. }
  30936. if m.id == nil || m.oldValue == nil {
  30937. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30938. }
  30939. oldValue, err := m.oldValue(ctx)
  30940. if err != nil {
  30941. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30942. }
  30943. return oldValue.CreatedAt, nil
  30944. }
  30945. // ResetCreatedAt resets all changes to the "created_at" field.
  30946. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  30947. m.created_at = nil
  30948. }
  30949. // SetUpdatedAt sets the "updated_at" field.
  30950. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  30951. m.updated_at = &t
  30952. }
  30953. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30954. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  30955. v := m.updated_at
  30956. if v == nil {
  30957. return
  30958. }
  30959. return *v, true
  30960. }
  30961. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  30962. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  30963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30964. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30965. if !m.op.Is(OpUpdateOne) {
  30966. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30967. }
  30968. if m.id == nil || m.oldValue == nil {
  30969. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30970. }
  30971. oldValue, err := m.oldValue(ctx)
  30972. if err != nil {
  30973. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30974. }
  30975. return oldValue.UpdatedAt, nil
  30976. }
  30977. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30978. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  30979. m.updated_at = nil
  30980. }
  30981. // SetStatus sets the "status" field.
  30982. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  30983. m.status = &u
  30984. m.addstatus = nil
  30985. }
  30986. // Status returns the value of the "status" field in the mutation.
  30987. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  30988. v := m.status
  30989. if v == nil {
  30990. return
  30991. }
  30992. return *v, true
  30993. }
  30994. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  30995. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  30996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30997. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30998. if !m.op.Is(OpUpdateOne) {
  30999. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31000. }
  31001. if m.id == nil || m.oldValue == nil {
  31002. return v, errors.New("OldStatus requires an ID field in the mutation")
  31003. }
  31004. oldValue, err := m.oldValue(ctx)
  31005. if err != nil {
  31006. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31007. }
  31008. return oldValue.Status, nil
  31009. }
  31010. // AddStatus adds u to the "status" field.
  31011. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  31012. if m.addstatus != nil {
  31013. *m.addstatus += u
  31014. } else {
  31015. m.addstatus = &u
  31016. }
  31017. }
  31018. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31019. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  31020. v := m.addstatus
  31021. if v == nil {
  31022. return
  31023. }
  31024. return *v, true
  31025. }
  31026. // ClearStatus clears the value of the "status" field.
  31027. func (m *WpChatroomMemberMutation) ClearStatus() {
  31028. m.status = nil
  31029. m.addstatus = nil
  31030. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  31031. }
  31032. // StatusCleared returns if the "status" field was cleared in this mutation.
  31033. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  31034. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  31035. return ok
  31036. }
  31037. // ResetStatus resets all changes to the "status" field.
  31038. func (m *WpChatroomMemberMutation) ResetStatus() {
  31039. m.status = nil
  31040. m.addstatus = nil
  31041. delete(m.clearedFields, wpchatroommember.FieldStatus)
  31042. }
  31043. // SetWxWxid sets the "wx_wxid" field.
  31044. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  31045. m.wx_wxid = &s
  31046. }
  31047. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  31048. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  31049. v := m.wx_wxid
  31050. if v == nil {
  31051. return
  31052. }
  31053. return *v, true
  31054. }
  31055. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  31056. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31058. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  31059. if !m.op.Is(OpUpdateOne) {
  31060. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  31061. }
  31062. if m.id == nil || m.oldValue == nil {
  31063. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  31064. }
  31065. oldValue, err := m.oldValue(ctx)
  31066. if err != nil {
  31067. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  31068. }
  31069. return oldValue.WxWxid, nil
  31070. }
  31071. // ResetWxWxid resets all changes to the "wx_wxid" field.
  31072. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  31073. m.wx_wxid = nil
  31074. }
  31075. // SetWxid sets the "wxid" field.
  31076. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  31077. m.wxid = &s
  31078. }
  31079. // Wxid returns the value of the "wxid" field in the mutation.
  31080. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  31081. v := m.wxid
  31082. if v == nil {
  31083. return
  31084. }
  31085. return *v, true
  31086. }
  31087. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  31088. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31090. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  31091. if !m.op.Is(OpUpdateOne) {
  31092. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  31093. }
  31094. if m.id == nil || m.oldValue == nil {
  31095. return v, errors.New("OldWxid requires an ID field in the mutation")
  31096. }
  31097. oldValue, err := m.oldValue(ctx)
  31098. if err != nil {
  31099. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  31100. }
  31101. return oldValue.Wxid, nil
  31102. }
  31103. // ResetWxid resets all changes to the "wxid" field.
  31104. func (m *WpChatroomMemberMutation) ResetWxid() {
  31105. m.wxid = nil
  31106. }
  31107. // SetNickname sets the "nickname" field.
  31108. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  31109. m.nickname = &s
  31110. }
  31111. // Nickname returns the value of the "nickname" field in the mutation.
  31112. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  31113. v := m.nickname
  31114. if v == nil {
  31115. return
  31116. }
  31117. return *v, true
  31118. }
  31119. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  31120. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31122. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  31123. if !m.op.Is(OpUpdateOne) {
  31124. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  31125. }
  31126. if m.id == nil || m.oldValue == nil {
  31127. return v, errors.New("OldNickname requires an ID field in the mutation")
  31128. }
  31129. oldValue, err := m.oldValue(ctx)
  31130. if err != nil {
  31131. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  31132. }
  31133. return oldValue.Nickname, nil
  31134. }
  31135. // ResetNickname resets all changes to the "nickname" field.
  31136. func (m *WpChatroomMemberMutation) ResetNickname() {
  31137. m.nickname = nil
  31138. }
  31139. // SetAvatar sets the "avatar" field.
  31140. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  31141. m.avatar = &s
  31142. }
  31143. // Avatar returns the value of the "avatar" field in the mutation.
  31144. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  31145. v := m.avatar
  31146. if v == nil {
  31147. return
  31148. }
  31149. return *v, true
  31150. }
  31151. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  31152. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31154. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  31155. if !m.op.Is(OpUpdateOne) {
  31156. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  31157. }
  31158. if m.id == nil || m.oldValue == nil {
  31159. return v, errors.New("OldAvatar requires an ID field in the mutation")
  31160. }
  31161. oldValue, err := m.oldValue(ctx)
  31162. if err != nil {
  31163. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  31164. }
  31165. return oldValue.Avatar, nil
  31166. }
  31167. // ResetAvatar resets all changes to the "avatar" field.
  31168. func (m *WpChatroomMemberMutation) ResetAvatar() {
  31169. m.avatar = nil
  31170. }
  31171. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  31172. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  31173. m.predicates = append(m.predicates, ps...)
  31174. }
  31175. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  31176. // users can use type-assertion to append predicates that do not depend on any generated package.
  31177. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  31178. p := make([]predicate.WpChatroomMember, len(ps))
  31179. for i := range ps {
  31180. p[i] = ps[i]
  31181. }
  31182. m.Where(p...)
  31183. }
  31184. // Op returns the operation name.
  31185. func (m *WpChatroomMemberMutation) Op() Op {
  31186. return m.op
  31187. }
  31188. // SetOp allows setting the mutation operation.
  31189. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  31190. m.op = op
  31191. }
  31192. // Type returns the node type of this mutation (WpChatroomMember).
  31193. func (m *WpChatroomMemberMutation) Type() string {
  31194. return m.typ
  31195. }
  31196. // Fields returns all fields that were changed during this mutation. Note that in
  31197. // order to get all numeric fields that were incremented/decremented, call
  31198. // AddedFields().
  31199. func (m *WpChatroomMemberMutation) Fields() []string {
  31200. fields := make([]string, 0, 7)
  31201. if m.created_at != nil {
  31202. fields = append(fields, wpchatroommember.FieldCreatedAt)
  31203. }
  31204. if m.updated_at != nil {
  31205. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  31206. }
  31207. if m.status != nil {
  31208. fields = append(fields, wpchatroommember.FieldStatus)
  31209. }
  31210. if m.wx_wxid != nil {
  31211. fields = append(fields, wpchatroommember.FieldWxWxid)
  31212. }
  31213. if m.wxid != nil {
  31214. fields = append(fields, wpchatroommember.FieldWxid)
  31215. }
  31216. if m.nickname != nil {
  31217. fields = append(fields, wpchatroommember.FieldNickname)
  31218. }
  31219. if m.avatar != nil {
  31220. fields = append(fields, wpchatroommember.FieldAvatar)
  31221. }
  31222. return fields
  31223. }
  31224. // Field returns the value of a field with the given name. The second boolean
  31225. // return value indicates that this field was not set, or was not defined in the
  31226. // schema.
  31227. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  31228. switch name {
  31229. case wpchatroommember.FieldCreatedAt:
  31230. return m.CreatedAt()
  31231. case wpchatroommember.FieldUpdatedAt:
  31232. return m.UpdatedAt()
  31233. case wpchatroommember.FieldStatus:
  31234. return m.Status()
  31235. case wpchatroommember.FieldWxWxid:
  31236. return m.WxWxid()
  31237. case wpchatroommember.FieldWxid:
  31238. return m.Wxid()
  31239. case wpchatroommember.FieldNickname:
  31240. return m.Nickname()
  31241. case wpchatroommember.FieldAvatar:
  31242. return m.Avatar()
  31243. }
  31244. return nil, false
  31245. }
  31246. // OldField returns the old value of the field from the database. An error is
  31247. // returned if the mutation operation is not UpdateOne, or the query to the
  31248. // database failed.
  31249. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31250. switch name {
  31251. case wpchatroommember.FieldCreatedAt:
  31252. return m.OldCreatedAt(ctx)
  31253. case wpchatroommember.FieldUpdatedAt:
  31254. return m.OldUpdatedAt(ctx)
  31255. case wpchatroommember.FieldStatus:
  31256. return m.OldStatus(ctx)
  31257. case wpchatroommember.FieldWxWxid:
  31258. return m.OldWxWxid(ctx)
  31259. case wpchatroommember.FieldWxid:
  31260. return m.OldWxid(ctx)
  31261. case wpchatroommember.FieldNickname:
  31262. return m.OldNickname(ctx)
  31263. case wpchatroommember.FieldAvatar:
  31264. return m.OldAvatar(ctx)
  31265. }
  31266. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  31267. }
  31268. // SetField sets the value of a field with the given name. It returns an error if
  31269. // the field is not defined in the schema, or if the type mismatched the field
  31270. // type.
  31271. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  31272. switch name {
  31273. case wpchatroommember.FieldCreatedAt:
  31274. v, ok := value.(time.Time)
  31275. if !ok {
  31276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31277. }
  31278. m.SetCreatedAt(v)
  31279. return nil
  31280. case wpchatroommember.FieldUpdatedAt:
  31281. v, ok := value.(time.Time)
  31282. if !ok {
  31283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31284. }
  31285. m.SetUpdatedAt(v)
  31286. return nil
  31287. case wpchatroommember.FieldStatus:
  31288. v, ok := value.(uint8)
  31289. if !ok {
  31290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31291. }
  31292. m.SetStatus(v)
  31293. return nil
  31294. case wpchatroommember.FieldWxWxid:
  31295. v, ok := value.(string)
  31296. if !ok {
  31297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31298. }
  31299. m.SetWxWxid(v)
  31300. return nil
  31301. case wpchatroommember.FieldWxid:
  31302. v, ok := value.(string)
  31303. if !ok {
  31304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31305. }
  31306. m.SetWxid(v)
  31307. return nil
  31308. case wpchatroommember.FieldNickname:
  31309. v, ok := value.(string)
  31310. if !ok {
  31311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31312. }
  31313. m.SetNickname(v)
  31314. return nil
  31315. case wpchatroommember.FieldAvatar:
  31316. v, ok := value.(string)
  31317. if !ok {
  31318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31319. }
  31320. m.SetAvatar(v)
  31321. return nil
  31322. }
  31323. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  31324. }
  31325. // AddedFields returns all numeric fields that were incremented/decremented during
  31326. // this mutation.
  31327. func (m *WpChatroomMemberMutation) AddedFields() []string {
  31328. var fields []string
  31329. if m.addstatus != nil {
  31330. fields = append(fields, wpchatroommember.FieldStatus)
  31331. }
  31332. return fields
  31333. }
  31334. // AddedField returns the numeric value that was incremented/decremented on a field
  31335. // with the given name. The second boolean return value indicates that this field
  31336. // was not set, or was not defined in the schema.
  31337. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  31338. switch name {
  31339. case wpchatroommember.FieldStatus:
  31340. return m.AddedStatus()
  31341. }
  31342. return nil, false
  31343. }
  31344. // AddField adds the value to the field with the given name. It returns an error if
  31345. // the field is not defined in the schema, or if the type mismatched the field
  31346. // type.
  31347. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  31348. switch name {
  31349. case wpchatroommember.FieldStatus:
  31350. v, ok := value.(int8)
  31351. if !ok {
  31352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31353. }
  31354. m.AddStatus(v)
  31355. return nil
  31356. }
  31357. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  31358. }
  31359. // ClearedFields returns all nullable fields that were cleared during this
  31360. // mutation.
  31361. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  31362. var fields []string
  31363. if m.FieldCleared(wpchatroommember.FieldStatus) {
  31364. fields = append(fields, wpchatroommember.FieldStatus)
  31365. }
  31366. return fields
  31367. }
  31368. // FieldCleared returns a boolean indicating if a field with the given name was
  31369. // cleared in this mutation.
  31370. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  31371. _, ok := m.clearedFields[name]
  31372. return ok
  31373. }
  31374. // ClearField clears the value of the field with the given name. It returns an
  31375. // error if the field is not defined in the schema.
  31376. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  31377. switch name {
  31378. case wpchatroommember.FieldStatus:
  31379. m.ClearStatus()
  31380. return nil
  31381. }
  31382. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  31383. }
  31384. // ResetField resets all changes in the mutation for the field with the given name.
  31385. // It returns an error if the field is not defined in the schema.
  31386. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  31387. switch name {
  31388. case wpchatroommember.FieldCreatedAt:
  31389. m.ResetCreatedAt()
  31390. return nil
  31391. case wpchatroommember.FieldUpdatedAt:
  31392. m.ResetUpdatedAt()
  31393. return nil
  31394. case wpchatroommember.FieldStatus:
  31395. m.ResetStatus()
  31396. return nil
  31397. case wpchatroommember.FieldWxWxid:
  31398. m.ResetWxWxid()
  31399. return nil
  31400. case wpchatroommember.FieldWxid:
  31401. m.ResetWxid()
  31402. return nil
  31403. case wpchatroommember.FieldNickname:
  31404. m.ResetNickname()
  31405. return nil
  31406. case wpchatroommember.FieldAvatar:
  31407. m.ResetAvatar()
  31408. return nil
  31409. }
  31410. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  31411. }
  31412. // AddedEdges returns all edge names that were set/added in this mutation.
  31413. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  31414. edges := make([]string, 0, 0)
  31415. return edges
  31416. }
  31417. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31418. // name in this mutation.
  31419. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  31420. return nil
  31421. }
  31422. // RemovedEdges returns all edge names that were removed in this mutation.
  31423. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  31424. edges := make([]string, 0, 0)
  31425. return edges
  31426. }
  31427. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31428. // the given name in this mutation.
  31429. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  31430. return nil
  31431. }
  31432. // ClearedEdges returns all edge names that were cleared in this mutation.
  31433. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  31434. edges := make([]string, 0, 0)
  31435. return edges
  31436. }
  31437. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31438. // was cleared in this mutation.
  31439. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  31440. return false
  31441. }
  31442. // ClearEdge clears the value of the edge with the given name. It returns an error
  31443. // if that edge is not defined in the schema.
  31444. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  31445. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  31446. }
  31447. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31448. // It returns an error if the edge is not defined in the schema.
  31449. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  31450. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  31451. }
  31452. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  31453. type WxMutation struct {
  31454. config
  31455. op Op
  31456. typ string
  31457. id *uint64
  31458. created_at *time.Time
  31459. updated_at *time.Time
  31460. status *uint8
  31461. addstatus *int8
  31462. deleted_at *time.Time
  31463. port *string
  31464. process_id *string
  31465. callback *string
  31466. wxid *string
  31467. account *string
  31468. nickname *string
  31469. tel *string
  31470. head_big *string
  31471. organization_id *uint64
  31472. addorganization_id *int64
  31473. api_base *string
  31474. api_key *string
  31475. allow_list *[]string
  31476. appendallow_list []string
  31477. group_allow_list *[]string
  31478. appendgroup_allow_list []string
  31479. block_list *[]string
  31480. appendblock_list []string
  31481. group_block_list *[]string
  31482. appendgroup_block_list []string
  31483. clearedFields map[string]struct{}
  31484. server *uint64
  31485. clearedserver bool
  31486. agent *uint64
  31487. clearedagent bool
  31488. done bool
  31489. oldValue func(context.Context) (*Wx, error)
  31490. predicates []predicate.Wx
  31491. }
  31492. var _ ent.Mutation = (*WxMutation)(nil)
  31493. // wxOption allows management of the mutation configuration using functional options.
  31494. type wxOption func(*WxMutation)
  31495. // newWxMutation creates new mutation for the Wx entity.
  31496. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  31497. m := &WxMutation{
  31498. config: c,
  31499. op: op,
  31500. typ: TypeWx,
  31501. clearedFields: make(map[string]struct{}),
  31502. }
  31503. for _, opt := range opts {
  31504. opt(m)
  31505. }
  31506. return m
  31507. }
  31508. // withWxID sets the ID field of the mutation.
  31509. func withWxID(id uint64) wxOption {
  31510. return func(m *WxMutation) {
  31511. var (
  31512. err error
  31513. once sync.Once
  31514. value *Wx
  31515. )
  31516. m.oldValue = func(ctx context.Context) (*Wx, error) {
  31517. once.Do(func() {
  31518. if m.done {
  31519. err = errors.New("querying old values post mutation is not allowed")
  31520. } else {
  31521. value, err = m.Client().Wx.Get(ctx, id)
  31522. }
  31523. })
  31524. return value, err
  31525. }
  31526. m.id = &id
  31527. }
  31528. }
  31529. // withWx sets the old Wx of the mutation.
  31530. func withWx(node *Wx) wxOption {
  31531. return func(m *WxMutation) {
  31532. m.oldValue = func(context.Context) (*Wx, error) {
  31533. return node, nil
  31534. }
  31535. m.id = &node.ID
  31536. }
  31537. }
  31538. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31539. // executed in a transaction (ent.Tx), a transactional client is returned.
  31540. func (m WxMutation) Client() *Client {
  31541. client := &Client{config: m.config}
  31542. client.init()
  31543. return client
  31544. }
  31545. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31546. // it returns an error otherwise.
  31547. func (m WxMutation) Tx() (*Tx, error) {
  31548. if _, ok := m.driver.(*txDriver); !ok {
  31549. return nil, errors.New("ent: mutation is not running in a transaction")
  31550. }
  31551. tx := &Tx{config: m.config}
  31552. tx.init()
  31553. return tx, nil
  31554. }
  31555. // SetID sets the value of the id field. Note that this
  31556. // operation is only accepted on creation of Wx entities.
  31557. func (m *WxMutation) SetID(id uint64) {
  31558. m.id = &id
  31559. }
  31560. // ID returns the ID value in the mutation. Note that the ID is only available
  31561. // if it was provided to the builder or after it was returned from the database.
  31562. func (m *WxMutation) ID() (id uint64, exists bool) {
  31563. if m.id == nil {
  31564. return
  31565. }
  31566. return *m.id, true
  31567. }
  31568. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31569. // That means, if the mutation is applied within a transaction with an isolation level such
  31570. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31571. // or updated by the mutation.
  31572. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  31573. switch {
  31574. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31575. id, exists := m.ID()
  31576. if exists {
  31577. return []uint64{id}, nil
  31578. }
  31579. fallthrough
  31580. case m.op.Is(OpUpdate | OpDelete):
  31581. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  31582. default:
  31583. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31584. }
  31585. }
  31586. // SetCreatedAt sets the "created_at" field.
  31587. func (m *WxMutation) SetCreatedAt(t time.Time) {
  31588. m.created_at = &t
  31589. }
  31590. // CreatedAt returns the value of the "created_at" field in the mutation.
  31591. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  31592. v := m.created_at
  31593. if v == nil {
  31594. return
  31595. }
  31596. return *v, true
  31597. }
  31598. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  31599. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31601. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31602. if !m.op.Is(OpUpdateOne) {
  31603. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31604. }
  31605. if m.id == nil || m.oldValue == nil {
  31606. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31607. }
  31608. oldValue, err := m.oldValue(ctx)
  31609. if err != nil {
  31610. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31611. }
  31612. return oldValue.CreatedAt, nil
  31613. }
  31614. // ResetCreatedAt resets all changes to the "created_at" field.
  31615. func (m *WxMutation) ResetCreatedAt() {
  31616. m.created_at = nil
  31617. }
  31618. // SetUpdatedAt sets the "updated_at" field.
  31619. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  31620. m.updated_at = &t
  31621. }
  31622. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31623. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  31624. v := m.updated_at
  31625. if v == nil {
  31626. return
  31627. }
  31628. return *v, true
  31629. }
  31630. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  31631. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31633. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31634. if !m.op.Is(OpUpdateOne) {
  31635. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31636. }
  31637. if m.id == nil || m.oldValue == nil {
  31638. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31639. }
  31640. oldValue, err := m.oldValue(ctx)
  31641. if err != nil {
  31642. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31643. }
  31644. return oldValue.UpdatedAt, nil
  31645. }
  31646. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31647. func (m *WxMutation) ResetUpdatedAt() {
  31648. m.updated_at = nil
  31649. }
  31650. // SetStatus sets the "status" field.
  31651. func (m *WxMutation) SetStatus(u uint8) {
  31652. m.status = &u
  31653. m.addstatus = nil
  31654. }
  31655. // Status returns the value of the "status" field in the mutation.
  31656. func (m *WxMutation) Status() (r uint8, exists bool) {
  31657. v := m.status
  31658. if v == nil {
  31659. return
  31660. }
  31661. return *v, true
  31662. }
  31663. // OldStatus returns the old "status" field's value of the Wx entity.
  31664. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31666. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31667. if !m.op.Is(OpUpdateOne) {
  31668. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31669. }
  31670. if m.id == nil || m.oldValue == nil {
  31671. return v, errors.New("OldStatus requires an ID field in the mutation")
  31672. }
  31673. oldValue, err := m.oldValue(ctx)
  31674. if err != nil {
  31675. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31676. }
  31677. return oldValue.Status, nil
  31678. }
  31679. // AddStatus adds u to the "status" field.
  31680. func (m *WxMutation) AddStatus(u int8) {
  31681. if m.addstatus != nil {
  31682. *m.addstatus += u
  31683. } else {
  31684. m.addstatus = &u
  31685. }
  31686. }
  31687. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31688. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  31689. v := m.addstatus
  31690. if v == nil {
  31691. return
  31692. }
  31693. return *v, true
  31694. }
  31695. // ClearStatus clears the value of the "status" field.
  31696. func (m *WxMutation) ClearStatus() {
  31697. m.status = nil
  31698. m.addstatus = nil
  31699. m.clearedFields[wx.FieldStatus] = struct{}{}
  31700. }
  31701. // StatusCleared returns if the "status" field was cleared in this mutation.
  31702. func (m *WxMutation) StatusCleared() bool {
  31703. _, ok := m.clearedFields[wx.FieldStatus]
  31704. return ok
  31705. }
  31706. // ResetStatus resets all changes to the "status" field.
  31707. func (m *WxMutation) ResetStatus() {
  31708. m.status = nil
  31709. m.addstatus = nil
  31710. delete(m.clearedFields, wx.FieldStatus)
  31711. }
  31712. // SetDeletedAt sets the "deleted_at" field.
  31713. func (m *WxMutation) SetDeletedAt(t time.Time) {
  31714. m.deleted_at = &t
  31715. }
  31716. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31717. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  31718. v := m.deleted_at
  31719. if v == nil {
  31720. return
  31721. }
  31722. return *v, true
  31723. }
  31724. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  31725. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31727. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31728. if !m.op.Is(OpUpdateOne) {
  31729. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31730. }
  31731. if m.id == nil || m.oldValue == nil {
  31732. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31733. }
  31734. oldValue, err := m.oldValue(ctx)
  31735. if err != nil {
  31736. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31737. }
  31738. return oldValue.DeletedAt, nil
  31739. }
  31740. // ClearDeletedAt clears the value of the "deleted_at" field.
  31741. func (m *WxMutation) ClearDeletedAt() {
  31742. m.deleted_at = nil
  31743. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  31744. }
  31745. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31746. func (m *WxMutation) DeletedAtCleared() bool {
  31747. _, ok := m.clearedFields[wx.FieldDeletedAt]
  31748. return ok
  31749. }
  31750. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31751. func (m *WxMutation) ResetDeletedAt() {
  31752. m.deleted_at = nil
  31753. delete(m.clearedFields, wx.FieldDeletedAt)
  31754. }
  31755. // SetServerID sets the "server_id" field.
  31756. func (m *WxMutation) SetServerID(u uint64) {
  31757. m.server = &u
  31758. }
  31759. // ServerID returns the value of the "server_id" field in the mutation.
  31760. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  31761. v := m.server
  31762. if v == nil {
  31763. return
  31764. }
  31765. return *v, true
  31766. }
  31767. // OldServerID returns the old "server_id" field's value of the Wx entity.
  31768. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31770. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  31771. if !m.op.Is(OpUpdateOne) {
  31772. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  31773. }
  31774. if m.id == nil || m.oldValue == nil {
  31775. return v, errors.New("OldServerID requires an ID field in the mutation")
  31776. }
  31777. oldValue, err := m.oldValue(ctx)
  31778. if err != nil {
  31779. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  31780. }
  31781. return oldValue.ServerID, nil
  31782. }
  31783. // ClearServerID clears the value of the "server_id" field.
  31784. func (m *WxMutation) ClearServerID() {
  31785. m.server = nil
  31786. m.clearedFields[wx.FieldServerID] = struct{}{}
  31787. }
  31788. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  31789. func (m *WxMutation) ServerIDCleared() bool {
  31790. _, ok := m.clearedFields[wx.FieldServerID]
  31791. return ok
  31792. }
  31793. // ResetServerID resets all changes to the "server_id" field.
  31794. func (m *WxMutation) ResetServerID() {
  31795. m.server = nil
  31796. delete(m.clearedFields, wx.FieldServerID)
  31797. }
  31798. // SetPort sets the "port" field.
  31799. func (m *WxMutation) SetPort(s string) {
  31800. m.port = &s
  31801. }
  31802. // Port returns the value of the "port" field in the mutation.
  31803. func (m *WxMutation) Port() (r string, exists bool) {
  31804. v := m.port
  31805. if v == nil {
  31806. return
  31807. }
  31808. return *v, true
  31809. }
  31810. // OldPort returns the old "port" field's value of the Wx entity.
  31811. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31813. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  31814. if !m.op.Is(OpUpdateOne) {
  31815. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  31816. }
  31817. if m.id == nil || m.oldValue == nil {
  31818. return v, errors.New("OldPort requires an ID field in the mutation")
  31819. }
  31820. oldValue, err := m.oldValue(ctx)
  31821. if err != nil {
  31822. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  31823. }
  31824. return oldValue.Port, nil
  31825. }
  31826. // ResetPort resets all changes to the "port" field.
  31827. func (m *WxMutation) ResetPort() {
  31828. m.port = nil
  31829. }
  31830. // SetProcessID sets the "process_id" field.
  31831. func (m *WxMutation) SetProcessID(s string) {
  31832. m.process_id = &s
  31833. }
  31834. // ProcessID returns the value of the "process_id" field in the mutation.
  31835. func (m *WxMutation) ProcessID() (r string, exists bool) {
  31836. v := m.process_id
  31837. if v == nil {
  31838. return
  31839. }
  31840. return *v, true
  31841. }
  31842. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  31843. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31845. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  31846. if !m.op.Is(OpUpdateOne) {
  31847. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  31848. }
  31849. if m.id == nil || m.oldValue == nil {
  31850. return v, errors.New("OldProcessID requires an ID field in the mutation")
  31851. }
  31852. oldValue, err := m.oldValue(ctx)
  31853. if err != nil {
  31854. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  31855. }
  31856. return oldValue.ProcessID, nil
  31857. }
  31858. // ResetProcessID resets all changes to the "process_id" field.
  31859. func (m *WxMutation) ResetProcessID() {
  31860. m.process_id = nil
  31861. }
  31862. // SetCallback sets the "callback" field.
  31863. func (m *WxMutation) SetCallback(s string) {
  31864. m.callback = &s
  31865. }
  31866. // Callback returns the value of the "callback" field in the mutation.
  31867. func (m *WxMutation) Callback() (r string, exists bool) {
  31868. v := m.callback
  31869. if v == nil {
  31870. return
  31871. }
  31872. return *v, true
  31873. }
  31874. // OldCallback returns the old "callback" field's value of the Wx entity.
  31875. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31877. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  31878. if !m.op.Is(OpUpdateOne) {
  31879. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  31880. }
  31881. if m.id == nil || m.oldValue == nil {
  31882. return v, errors.New("OldCallback requires an ID field in the mutation")
  31883. }
  31884. oldValue, err := m.oldValue(ctx)
  31885. if err != nil {
  31886. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  31887. }
  31888. return oldValue.Callback, nil
  31889. }
  31890. // ResetCallback resets all changes to the "callback" field.
  31891. func (m *WxMutation) ResetCallback() {
  31892. m.callback = nil
  31893. }
  31894. // SetWxid sets the "wxid" field.
  31895. func (m *WxMutation) SetWxid(s string) {
  31896. m.wxid = &s
  31897. }
  31898. // Wxid returns the value of the "wxid" field in the mutation.
  31899. func (m *WxMutation) Wxid() (r string, exists bool) {
  31900. v := m.wxid
  31901. if v == nil {
  31902. return
  31903. }
  31904. return *v, true
  31905. }
  31906. // OldWxid returns the old "wxid" field's value of the Wx entity.
  31907. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31909. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  31910. if !m.op.Is(OpUpdateOne) {
  31911. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  31912. }
  31913. if m.id == nil || m.oldValue == nil {
  31914. return v, errors.New("OldWxid requires an ID field in the mutation")
  31915. }
  31916. oldValue, err := m.oldValue(ctx)
  31917. if err != nil {
  31918. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  31919. }
  31920. return oldValue.Wxid, nil
  31921. }
  31922. // ResetWxid resets all changes to the "wxid" field.
  31923. func (m *WxMutation) ResetWxid() {
  31924. m.wxid = nil
  31925. }
  31926. // SetAccount sets the "account" field.
  31927. func (m *WxMutation) SetAccount(s string) {
  31928. m.account = &s
  31929. }
  31930. // Account returns the value of the "account" field in the mutation.
  31931. func (m *WxMutation) Account() (r string, exists bool) {
  31932. v := m.account
  31933. if v == nil {
  31934. return
  31935. }
  31936. return *v, true
  31937. }
  31938. // OldAccount returns the old "account" field's value of the Wx entity.
  31939. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31941. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  31942. if !m.op.Is(OpUpdateOne) {
  31943. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  31944. }
  31945. if m.id == nil || m.oldValue == nil {
  31946. return v, errors.New("OldAccount requires an ID field in the mutation")
  31947. }
  31948. oldValue, err := m.oldValue(ctx)
  31949. if err != nil {
  31950. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  31951. }
  31952. return oldValue.Account, nil
  31953. }
  31954. // ResetAccount resets all changes to the "account" field.
  31955. func (m *WxMutation) ResetAccount() {
  31956. m.account = nil
  31957. }
  31958. // SetNickname sets the "nickname" field.
  31959. func (m *WxMutation) SetNickname(s string) {
  31960. m.nickname = &s
  31961. }
  31962. // Nickname returns the value of the "nickname" field in the mutation.
  31963. func (m *WxMutation) Nickname() (r string, exists bool) {
  31964. v := m.nickname
  31965. if v == nil {
  31966. return
  31967. }
  31968. return *v, true
  31969. }
  31970. // OldNickname returns the old "nickname" field's value of the Wx entity.
  31971. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31973. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  31974. if !m.op.Is(OpUpdateOne) {
  31975. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  31976. }
  31977. if m.id == nil || m.oldValue == nil {
  31978. return v, errors.New("OldNickname requires an ID field in the mutation")
  31979. }
  31980. oldValue, err := m.oldValue(ctx)
  31981. if err != nil {
  31982. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  31983. }
  31984. return oldValue.Nickname, nil
  31985. }
  31986. // ResetNickname resets all changes to the "nickname" field.
  31987. func (m *WxMutation) ResetNickname() {
  31988. m.nickname = nil
  31989. }
  31990. // SetTel sets the "tel" field.
  31991. func (m *WxMutation) SetTel(s string) {
  31992. m.tel = &s
  31993. }
  31994. // Tel returns the value of the "tel" field in the mutation.
  31995. func (m *WxMutation) Tel() (r string, exists bool) {
  31996. v := m.tel
  31997. if v == nil {
  31998. return
  31999. }
  32000. return *v, true
  32001. }
  32002. // OldTel returns the old "tel" field's value of the Wx entity.
  32003. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32005. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  32006. if !m.op.Is(OpUpdateOne) {
  32007. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  32008. }
  32009. if m.id == nil || m.oldValue == nil {
  32010. return v, errors.New("OldTel requires an ID field in the mutation")
  32011. }
  32012. oldValue, err := m.oldValue(ctx)
  32013. if err != nil {
  32014. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  32015. }
  32016. return oldValue.Tel, nil
  32017. }
  32018. // ResetTel resets all changes to the "tel" field.
  32019. func (m *WxMutation) ResetTel() {
  32020. m.tel = nil
  32021. }
  32022. // SetHeadBig sets the "head_big" field.
  32023. func (m *WxMutation) SetHeadBig(s string) {
  32024. m.head_big = &s
  32025. }
  32026. // HeadBig returns the value of the "head_big" field in the mutation.
  32027. func (m *WxMutation) HeadBig() (r string, exists bool) {
  32028. v := m.head_big
  32029. if v == nil {
  32030. return
  32031. }
  32032. return *v, true
  32033. }
  32034. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  32035. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32037. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  32038. if !m.op.Is(OpUpdateOne) {
  32039. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  32040. }
  32041. if m.id == nil || m.oldValue == nil {
  32042. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  32043. }
  32044. oldValue, err := m.oldValue(ctx)
  32045. if err != nil {
  32046. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  32047. }
  32048. return oldValue.HeadBig, nil
  32049. }
  32050. // ResetHeadBig resets all changes to the "head_big" field.
  32051. func (m *WxMutation) ResetHeadBig() {
  32052. m.head_big = nil
  32053. }
  32054. // SetOrganizationID sets the "organization_id" field.
  32055. func (m *WxMutation) SetOrganizationID(u uint64) {
  32056. m.organization_id = &u
  32057. m.addorganization_id = nil
  32058. }
  32059. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32060. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  32061. v := m.organization_id
  32062. if v == nil {
  32063. return
  32064. }
  32065. return *v, true
  32066. }
  32067. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  32068. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32070. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32071. if !m.op.Is(OpUpdateOne) {
  32072. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32073. }
  32074. if m.id == nil || m.oldValue == nil {
  32075. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32076. }
  32077. oldValue, err := m.oldValue(ctx)
  32078. if err != nil {
  32079. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32080. }
  32081. return oldValue.OrganizationID, nil
  32082. }
  32083. // AddOrganizationID adds u to the "organization_id" field.
  32084. func (m *WxMutation) AddOrganizationID(u int64) {
  32085. if m.addorganization_id != nil {
  32086. *m.addorganization_id += u
  32087. } else {
  32088. m.addorganization_id = &u
  32089. }
  32090. }
  32091. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32092. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  32093. v := m.addorganization_id
  32094. if v == nil {
  32095. return
  32096. }
  32097. return *v, true
  32098. }
  32099. // ClearOrganizationID clears the value of the "organization_id" field.
  32100. func (m *WxMutation) ClearOrganizationID() {
  32101. m.organization_id = nil
  32102. m.addorganization_id = nil
  32103. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  32104. }
  32105. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32106. func (m *WxMutation) OrganizationIDCleared() bool {
  32107. _, ok := m.clearedFields[wx.FieldOrganizationID]
  32108. return ok
  32109. }
  32110. // ResetOrganizationID resets all changes to the "organization_id" field.
  32111. func (m *WxMutation) ResetOrganizationID() {
  32112. m.organization_id = nil
  32113. m.addorganization_id = nil
  32114. delete(m.clearedFields, wx.FieldOrganizationID)
  32115. }
  32116. // SetAgentID sets the "agent_id" field.
  32117. func (m *WxMutation) SetAgentID(u uint64) {
  32118. m.agent = &u
  32119. }
  32120. // AgentID returns the value of the "agent_id" field in the mutation.
  32121. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  32122. v := m.agent
  32123. if v == nil {
  32124. return
  32125. }
  32126. return *v, true
  32127. }
  32128. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  32129. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32131. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  32132. if !m.op.Is(OpUpdateOne) {
  32133. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  32134. }
  32135. if m.id == nil || m.oldValue == nil {
  32136. return v, errors.New("OldAgentID requires an ID field in the mutation")
  32137. }
  32138. oldValue, err := m.oldValue(ctx)
  32139. if err != nil {
  32140. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  32141. }
  32142. return oldValue.AgentID, nil
  32143. }
  32144. // ResetAgentID resets all changes to the "agent_id" field.
  32145. func (m *WxMutation) ResetAgentID() {
  32146. m.agent = nil
  32147. }
  32148. // SetAPIBase sets the "api_base" field.
  32149. func (m *WxMutation) SetAPIBase(s string) {
  32150. m.api_base = &s
  32151. }
  32152. // APIBase returns the value of the "api_base" field in the mutation.
  32153. func (m *WxMutation) APIBase() (r string, exists bool) {
  32154. v := m.api_base
  32155. if v == nil {
  32156. return
  32157. }
  32158. return *v, true
  32159. }
  32160. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  32161. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32163. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  32164. if !m.op.Is(OpUpdateOne) {
  32165. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  32166. }
  32167. if m.id == nil || m.oldValue == nil {
  32168. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  32169. }
  32170. oldValue, err := m.oldValue(ctx)
  32171. if err != nil {
  32172. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  32173. }
  32174. return oldValue.APIBase, nil
  32175. }
  32176. // ClearAPIBase clears the value of the "api_base" field.
  32177. func (m *WxMutation) ClearAPIBase() {
  32178. m.api_base = nil
  32179. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  32180. }
  32181. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  32182. func (m *WxMutation) APIBaseCleared() bool {
  32183. _, ok := m.clearedFields[wx.FieldAPIBase]
  32184. return ok
  32185. }
  32186. // ResetAPIBase resets all changes to the "api_base" field.
  32187. func (m *WxMutation) ResetAPIBase() {
  32188. m.api_base = nil
  32189. delete(m.clearedFields, wx.FieldAPIBase)
  32190. }
  32191. // SetAPIKey sets the "api_key" field.
  32192. func (m *WxMutation) SetAPIKey(s string) {
  32193. m.api_key = &s
  32194. }
  32195. // APIKey returns the value of the "api_key" field in the mutation.
  32196. func (m *WxMutation) APIKey() (r string, exists bool) {
  32197. v := m.api_key
  32198. if v == nil {
  32199. return
  32200. }
  32201. return *v, true
  32202. }
  32203. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  32204. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32206. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  32207. if !m.op.Is(OpUpdateOne) {
  32208. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  32209. }
  32210. if m.id == nil || m.oldValue == nil {
  32211. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  32212. }
  32213. oldValue, err := m.oldValue(ctx)
  32214. if err != nil {
  32215. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  32216. }
  32217. return oldValue.APIKey, nil
  32218. }
  32219. // ClearAPIKey clears the value of the "api_key" field.
  32220. func (m *WxMutation) ClearAPIKey() {
  32221. m.api_key = nil
  32222. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  32223. }
  32224. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  32225. func (m *WxMutation) APIKeyCleared() bool {
  32226. _, ok := m.clearedFields[wx.FieldAPIKey]
  32227. return ok
  32228. }
  32229. // ResetAPIKey resets all changes to the "api_key" field.
  32230. func (m *WxMutation) ResetAPIKey() {
  32231. m.api_key = nil
  32232. delete(m.clearedFields, wx.FieldAPIKey)
  32233. }
  32234. // SetAllowList sets the "allow_list" field.
  32235. func (m *WxMutation) SetAllowList(s []string) {
  32236. m.allow_list = &s
  32237. m.appendallow_list = nil
  32238. }
  32239. // AllowList returns the value of the "allow_list" field in the mutation.
  32240. func (m *WxMutation) AllowList() (r []string, exists bool) {
  32241. v := m.allow_list
  32242. if v == nil {
  32243. return
  32244. }
  32245. return *v, true
  32246. }
  32247. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  32248. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32250. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  32251. if !m.op.Is(OpUpdateOne) {
  32252. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  32253. }
  32254. if m.id == nil || m.oldValue == nil {
  32255. return v, errors.New("OldAllowList requires an ID field in the mutation")
  32256. }
  32257. oldValue, err := m.oldValue(ctx)
  32258. if err != nil {
  32259. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  32260. }
  32261. return oldValue.AllowList, nil
  32262. }
  32263. // AppendAllowList adds s to the "allow_list" field.
  32264. func (m *WxMutation) AppendAllowList(s []string) {
  32265. m.appendallow_list = append(m.appendallow_list, s...)
  32266. }
  32267. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  32268. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  32269. if len(m.appendallow_list) == 0 {
  32270. return nil, false
  32271. }
  32272. return m.appendallow_list, true
  32273. }
  32274. // ResetAllowList resets all changes to the "allow_list" field.
  32275. func (m *WxMutation) ResetAllowList() {
  32276. m.allow_list = nil
  32277. m.appendallow_list = nil
  32278. }
  32279. // SetGroupAllowList sets the "group_allow_list" field.
  32280. func (m *WxMutation) SetGroupAllowList(s []string) {
  32281. m.group_allow_list = &s
  32282. m.appendgroup_allow_list = nil
  32283. }
  32284. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  32285. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  32286. v := m.group_allow_list
  32287. if v == nil {
  32288. return
  32289. }
  32290. return *v, true
  32291. }
  32292. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  32293. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32295. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  32296. if !m.op.Is(OpUpdateOne) {
  32297. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  32298. }
  32299. if m.id == nil || m.oldValue == nil {
  32300. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  32301. }
  32302. oldValue, err := m.oldValue(ctx)
  32303. if err != nil {
  32304. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  32305. }
  32306. return oldValue.GroupAllowList, nil
  32307. }
  32308. // AppendGroupAllowList adds s to the "group_allow_list" field.
  32309. func (m *WxMutation) AppendGroupAllowList(s []string) {
  32310. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  32311. }
  32312. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  32313. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  32314. if len(m.appendgroup_allow_list) == 0 {
  32315. return nil, false
  32316. }
  32317. return m.appendgroup_allow_list, true
  32318. }
  32319. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  32320. func (m *WxMutation) ResetGroupAllowList() {
  32321. m.group_allow_list = nil
  32322. m.appendgroup_allow_list = nil
  32323. }
  32324. // SetBlockList sets the "block_list" field.
  32325. func (m *WxMutation) SetBlockList(s []string) {
  32326. m.block_list = &s
  32327. m.appendblock_list = nil
  32328. }
  32329. // BlockList returns the value of the "block_list" field in the mutation.
  32330. func (m *WxMutation) BlockList() (r []string, exists bool) {
  32331. v := m.block_list
  32332. if v == nil {
  32333. return
  32334. }
  32335. return *v, true
  32336. }
  32337. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  32338. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32340. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  32341. if !m.op.Is(OpUpdateOne) {
  32342. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  32343. }
  32344. if m.id == nil || m.oldValue == nil {
  32345. return v, errors.New("OldBlockList requires an ID field in the mutation")
  32346. }
  32347. oldValue, err := m.oldValue(ctx)
  32348. if err != nil {
  32349. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  32350. }
  32351. return oldValue.BlockList, nil
  32352. }
  32353. // AppendBlockList adds s to the "block_list" field.
  32354. func (m *WxMutation) AppendBlockList(s []string) {
  32355. m.appendblock_list = append(m.appendblock_list, s...)
  32356. }
  32357. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  32358. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  32359. if len(m.appendblock_list) == 0 {
  32360. return nil, false
  32361. }
  32362. return m.appendblock_list, true
  32363. }
  32364. // ResetBlockList resets all changes to the "block_list" field.
  32365. func (m *WxMutation) ResetBlockList() {
  32366. m.block_list = nil
  32367. m.appendblock_list = nil
  32368. }
  32369. // SetGroupBlockList sets the "group_block_list" field.
  32370. func (m *WxMutation) SetGroupBlockList(s []string) {
  32371. m.group_block_list = &s
  32372. m.appendgroup_block_list = nil
  32373. }
  32374. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  32375. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  32376. v := m.group_block_list
  32377. if v == nil {
  32378. return
  32379. }
  32380. return *v, true
  32381. }
  32382. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  32383. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32385. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  32386. if !m.op.Is(OpUpdateOne) {
  32387. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  32388. }
  32389. if m.id == nil || m.oldValue == nil {
  32390. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  32391. }
  32392. oldValue, err := m.oldValue(ctx)
  32393. if err != nil {
  32394. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  32395. }
  32396. return oldValue.GroupBlockList, nil
  32397. }
  32398. // AppendGroupBlockList adds s to the "group_block_list" field.
  32399. func (m *WxMutation) AppendGroupBlockList(s []string) {
  32400. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  32401. }
  32402. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  32403. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  32404. if len(m.appendgroup_block_list) == 0 {
  32405. return nil, false
  32406. }
  32407. return m.appendgroup_block_list, true
  32408. }
  32409. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  32410. func (m *WxMutation) ResetGroupBlockList() {
  32411. m.group_block_list = nil
  32412. m.appendgroup_block_list = nil
  32413. }
  32414. // ClearServer clears the "server" edge to the Server entity.
  32415. func (m *WxMutation) ClearServer() {
  32416. m.clearedserver = true
  32417. m.clearedFields[wx.FieldServerID] = struct{}{}
  32418. }
  32419. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  32420. func (m *WxMutation) ServerCleared() bool {
  32421. return m.ServerIDCleared() || m.clearedserver
  32422. }
  32423. // ServerIDs returns the "server" edge IDs in the mutation.
  32424. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32425. // ServerID instead. It exists only for internal usage by the builders.
  32426. func (m *WxMutation) ServerIDs() (ids []uint64) {
  32427. if id := m.server; id != nil {
  32428. ids = append(ids, *id)
  32429. }
  32430. return
  32431. }
  32432. // ResetServer resets all changes to the "server" edge.
  32433. func (m *WxMutation) ResetServer() {
  32434. m.server = nil
  32435. m.clearedserver = false
  32436. }
  32437. // ClearAgent clears the "agent" edge to the Agent entity.
  32438. func (m *WxMutation) ClearAgent() {
  32439. m.clearedagent = true
  32440. m.clearedFields[wx.FieldAgentID] = struct{}{}
  32441. }
  32442. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  32443. func (m *WxMutation) AgentCleared() bool {
  32444. return m.clearedagent
  32445. }
  32446. // AgentIDs returns the "agent" edge IDs in the mutation.
  32447. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32448. // AgentID instead. It exists only for internal usage by the builders.
  32449. func (m *WxMutation) AgentIDs() (ids []uint64) {
  32450. if id := m.agent; id != nil {
  32451. ids = append(ids, *id)
  32452. }
  32453. return
  32454. }
  32455. // ResetAgent resets all changes to the "agent" edge.
  32456. func (m *WxMutation) ResetAgent() {
  32457. m.agent = nil
  32458. m.clearedagent = false
  32459. }
  32460. // Where appends a list predicates to the WxMutation builder.
  32461. func (m *WxMutation) Where(ps ...predicate.Wx) {
  32462. m.predicates = append(m.predicates, ps...)
  32463. }
  32464. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  32465. // users can use type-assertion to append predicates that do not depend on any generated package.
  32466. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  32467. p := make([]predicate.Wx, len(ps))
  32468. for i := range ps {
  32469. p[i] = ps[i]
  32470. }
  32471. m.Where(p...)
  32472. }
  32473. // Op returns the operation name.
  32474. func (m *WxMutation) Op() Op {
  32475. return m.op
  32476. }
  32477. // SetOp allows setting the mutation operation.
  32478. func (m *WxMutation) SetOp(op Op) {
  32479. m.op = op
  32480. }
  32481. // Type returns the node type of this mutation (Wx).
  32482. func (m *WxMutation) Type() string {
  32483. return m.typ
  32484. }
  32485. // Fields returns all fields that were changed during this mutation. Note that in
  32486. // order to get all numeric fields that were incremented/decremented, call
  32487. // AddedFields().
  32488. func (m *WxMutation) Fields() []string {
  32489. fields := make([]string, 0, 21)
  32490. if m.created_at != nil {
  32491. fields = append(fields, wx.FieldCreatedAt)
  32492. }
  32493. if m.updated_at != nil {
  32494. fields = append(fields, wx.FieldUpdatedAt)
  32495. }
  32496. if m.status != nil {
  32497. fields = append(fields, wx.FieldStatus)
  32498. }
  32499. if m.deleted_at != nil {
  32500. fields = append(fields, wx.FieldDeletedAt)
  32501. }
  32502. if m.server != nil {
  32503. fields = append(fields, wx.FieldServerID)
  32504. }
  32505. if m.port != nil {
  32506. fields = append(fields, wx.FieldPort)
  32507. }
  32508. if m.process_id != nil {
  32509. fields = append(fields, wx.FieldProcessID)
  32510. }
  32511. if m.callback != nil {
  32512. fields = append(fields, wx.FieldCallback)
  32513. }
  32514. if m.wxid != nil {
  32515. fields = append(fields, wx.FieldWxid)
  32516. }
  32517. if m.account != nil {
  32518. fields = append(fields, wx.FieldAccount)
  32519. }
  32520. if m.nickname != nil {
  32521. fields = append(fields, wx.FieldNickname)
  32522. }
  32523. if m.tel != nil {
  32524. fields = append(fields, wx.FieldTel)
  32525. }
  32526. if m.head_big != nil {
  32527. fields = append(fields, wx.FieldHeadBig)
  32528. }
  32529. if m.organization_id != nil {
  32530. fields = append(fields, wx.FieldOrganizationID)
  32531. }
  32532. if m.agent != nil {
  32533. fields = append(fields, wx.FieldAgentID)
  32534. }
  32535. if m.api_base != nil {
  32536. fields = append(fields, wx.FieldAPIBase)
  32537. }
  32538. if m.api_key != nil {
  32539. fields = append(fields, wx.FieldAPIKey)
  32540. }
  32541. if m.allow_list != nil {
  32542. fields = append(fields, wx.FieldAllowList)
  32543. }
  32544. if m.group_allow_list != nil {
  32545. fields = append(fields, wx.FieldGroupAllowList)
  32546. }
  32547. if m.block_list != nil {
  32548. fields = append(fields, wx.FieldBlockList)
  32549. }
  32550. if m.group_block_list != nil {
  32551. fields = append(fields, wx.FieldGroupBlockList)
  32552. }
  32553. return fields
  32554. }
  32555. // Field returns the value of a field with the given name. The second boolean
  32556. // return value indicates that this field was not set, or was not defined in the
  32557. // schema.
  32558. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  32559. switch name {
  32560. case wx.FieldCreatedAt:
  32561. return m.CreatedAt()
  32562. case wx.FieldUpdatedAt:
  32563. return m.UpdatedAt()
  32564. case wx.FieldStatus:
  32565. return m.Status()
  32566. case wx.FieldDeletedAt:
  32567. return m.DeletedAt()
  32568. case wx.FieldServerID:
  32569. return m.ServerID()
  32570. case wx.FieldPort:
  32571. return m.Port()
  32572. case wx.FieldProcessID:
  32573. return m.ProcessID()
  32574. case wx.FieldCallback:
  32575. return m.Callback()
  32576. case wx.FieldWxid:
  32577. return m.Wxid()
  32578. case wx.FieldAccount:
  32579. return m.Account()
  32580. case wx.FieldNickname:
  32581. return m.Nickname()
  32582. case wx.FieldTel:
  32583. return m.Tel()
  32584. case wx.FieldHeadBig:
  32585. return m.HeadBig()
  32586. case wx.FieldOrganizationID:
  32587. return m.OrganizationID()
  32588. case wx.FieldAgentID:
  32589. return m.AgentID()
  32590. case wx.FieldAPIBase:
  32591. return m.APIBase()
  32592. case wx.FieldAPIKey:
  32593. return m.APIKey()
  32594. case wx.FieldAllowList:
  32595. return m.AllowList()
  32596. case wx.FieldGroupAllowList:
  32597. return m.GroupAllowList()
  32598. case wx.FieldBlockList:
  32599. return m.BlockList()
  32600. case wx.FieldGroupBlockList:
  32601. return m.GroupBlockList()
  32602. }
  32603. return nil, false
  32604. }
  32605. // OldField returns the old value of the field from the database. An error is
  32606. // returned if the mutation operation is not UpdateOne, or the query to the
  32607. // database failed.
  32608. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32609. switch name {
  32610. case wx.FieldCreatedAt:
  32611. return m.OldCreatedAt(ctx)
  32612. case wx.FieldUpdatedAt:
  32613. return m.OldUpdatedAt(ctx)
  32614. case wx.FieldStatus:
  32615. return m.OldStatus(ctx)
  32616. case wx.FieldDeletedAt:
  32617. return m.OldDeletedAt(ctx)
  32618. case wx.FieldServerID:
  32619. return m.OldServerID(ctx)
  32620. case wx.FieldPort:
  32621. return m.OldPort(ctx)
  32622. case wx.FieldProcessID:
  32623. return m.OldProcessID(ctx)
  32624. case wx.FieldCallback:
  32625. return m.OldCallback(ctx)
  32626. case wx.FieldWxid:
  32627. return m.OldWxid(ctx)
  32628. case wx.FieldAccount:
  32629. return m.OldAccount(ctx)
  32630. case wx.FieldNickname:
  32631. return m.OldNickname(ctx)
  32632. case wx.FieldTel:
  32633. return m.OldTel(ctx)
  32634. case wx.FieldHeadBig:
  32635. return m.OldHeadBig(ctx)
  32636. case wx.FieldOrganizationID:
  32637. return m.OldOrganizationID(ctx)
  32638. case wx.FieldAgentID:
  32639. return m.OldAgentID(ctx)
  32640. case wx.FieldAPIBase:
  32641. return m.OldAPIBase(ctx)
  32642. case wx.FieldAPIKey:
  32643. return m.OldAPIKey(ctx)
  32644. case wx.FieldAllowList:
  32645. return m.OldAllowList(ctx)
  32646. case wx.FieldGroupAllowList:
  32647. return m.OldGroupAllowList(ctx)
  32648. case wx.FieldBlockList:
  32649. return m.OldBlockList(ctx)
  32650. case wx.FieldGroupBlockList:
  32651. return m.OldGroupBlockList(ctx)
  32652. }
  32653. return nil, fmt.Errorf("unknown Wx field %s", name)
  32654. }
  32655. // SetField sets the value of a field with the given name. It returns an error if
  32656. // the field is not defined in the schema, or if the type mismatched the field
  32657. // type.
  32658. func (m *WxMutation) SetField(name string, value ent.Value) error {
  32659. switch name {
  32660. case wx.FieldCreatedAt:
  32661. v, ok := value.(time.Time)
  32662. if !ok {
  32663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32664. }
  32665. m.SetCreatedAt(v)
  32666. return nil
  32667. case wx.FieldUpdatedAt:
  32668. v, ok := value.(time.Time)
  32669. if !ok {
  32670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32671. }
  32672. m.SetUpdatedAt(v)
  32673. return nil
  32674. case wx.FieldStatus:
  32675. v, ok := value.(uint8)
  32676. if !ok {
  32677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32678. }
  32679. m.SetStatus(v)
  32680. return nil
  32681. case wx.FieldDeletedAt:
  32682. v, ok := value.(time.Time)
  32683. if !ok {
  32684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32685. }
  32686. m.SetDeletedAt(v)
  32687. return nil
  32688. case wx.FieldServerID:
  32689. v, ok := value.(uint64)
  32690. if !ok {
  32691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32692. }
  32693. m.SetServerID(v)
  32694. return nil
  32695. case wx.FieldPort:
  32696. v, ok := value.(string)
  32697. if !ok {
  32698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32699. }
  32700. m.SetPort(v)
  32701. return nil
  32702. case wx.FieldProcessID:
  32703. v, ok := value.(string)
  32704. if !ok {
  32705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32706. }
  32707. m.SetProcessID(v)
  32708. return nil
  32709. case wx.FieldCallback:
  32710. v, ok := value.(string)
  32711. if !ok {
  32712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32713. }
  32714. m.SetCallback(v)
  32715. return nil
  32716. case wx.FieldWxid:
  32717. v, ok := value.(string)
  32718. if !ok {
  32719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32720. }
  32721. m.SetWxid(v)
  32722. return nil
  32723. case wx.FieldAccount:
  32724. v, ok := value.(string)
  32725. if !ok {
  32726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32727. }
  32728. m.SetAccount(v)
  32729. return nil
  32730. case wx.FieldNickname:
  32731. v, ok := value.(string)
  32732. if !ok {
  32733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32734. }
  32735. m.SetNickname(v)
  32736. return nil
  32737. case wx.FieldTel:
  32738. v, ok := value.(string)
  32739. if !ok {
  32740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32741. }
  32742. m.SetTel(v)
  32743. return nil
  32744. case wx.FieldHeadBig:
  32745. v, ok := value.(string)
  32746. if !ok {
  32747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32748. }
  32749. m.SetHeadBig(v)
  32750. return nil
  32751. case wx.FieldOrganizationID:
  32752. v, ok := value.(uint64)
  32753. if !ok {
  32754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32755. }
  32756. m.SetOrganizationID(v)
  32757. return nil
  32758. case wx.FieldAgentID:
  32759. v, ok := value.(uint64)
  32760. if !ok {
  32761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32762. }
  32763. m.SetAgentID(v)
  32764. return nil
  32765. case wx.FieldAPIBase:
  32766. v, ok := value.(string)
  32767. if !ok {
  32768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32769. }
  32770. m.SetAPIBase(v)
  32771. return nil
  32772. case wx.FieldAPIKey:
  32773. v, ok := value.(string)
  32774. if !ok {
  32775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32776. }
  32777. m.SetAPIKey(v)
  32778. return nil
  32779. case wx.FieldAllowList:
  32780. v, ok := value.([]string)
  32781. if !ok {
  32782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32783. }
  32784. m.SetAllowList(v)
  32785. return nil
  32786. case wx.FieldGroupAllowList:
  32787. v, ok := value.([]string)
  32788. if !ok {
  32789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32790. }
  32791. m.SetGroupAllowList(v)
  32792. return nil
  32793. case wx.FieldBlockList:
  32794. v, ok := value.([]string)
  32795. if !ok {
  32796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32797. }
  32798. m.SetBlockList(v)
  32799. return nil
  32800. case wx.FieldGroupBlockList:
  32801. v, ok := value.([]string)
  32802. if !ok {
  32803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32804. }
  32805. m.SetGroupBlockList(v)
  32806. return nil
  32807. }
  32808. return fmt.Errorf("unknown Wx field %s", name)
  32809. }
  32810. // AddedFields returns all numeric fields that were incremented/decremented during
  32811. // this mutation.
  32812. func (m *WxMutation) AddedFields() []string {
  32813. var fields []string
  32814. if m.addstatus != nil {
  32815. fields = append(fields, wx.FieldStatus)
  32816. }
  32817. if m.addorganization_id != nil {
  32818. fields = append(fields, wx.FieldOrganizationID)
  32819. }
  32820. return fields
  32821. }
  32822. // AddedField returns the numeric value that was incremented/decremented on a field
  32823. // with the given name. The second boolean return value indicates that this field
  32824. // was not set, or was not defined in the schema.
  32825. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  32826. switch name {
  32827. case wx.FieldStatus:
  32828. return m.AddedStatus()
  32829. case wx.FieldOrganizationID:
  32830. return m.AddedOrganizationID()
  32831. }
  32832. return nil, false
  32833. }
  32834. // AddField adds the value to the field with the given name. It returns an error if
  32835. // the field is not defined in the schema, or if the type mismatched the field
  32836. // type.
  32837. func (m *WxMutation) AddField(name string, value ent.Value) error {
  32838. switch name {
  32839. case wx.FieldStatus:
  32840. v, ok := value.(int8)
  32841. if !ok {
  32842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32843. }
  32844. m.AddStatus(v)
  32845. return nil
  32846. case wx.FieldOrganizationID:
  32847. v, ok := value.(int64)
  32848. if !ok {
  32849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32850. }
  32851. m.AddOrganizationID(v)
  32852. return nil
  32853. }
  32854. return fmt.Errorf("unknown Wx numeric field %s", name)
  32855. }
  32856. // ClearedFields returns all nullable fields that were cleared during this
  32857. // mutation.
  32858. func (m *WxMutation) ClearedFields() []string {
  32859. var fields []string
  32860. if m.FieldCleared(wx.FieldStatus) {
  32861. fields = append(fields, wx.FieldStatus)
  32862. }
  32863. if m.FieldCleared(wx.FieldDeletedAt) {
  32864. fields = append(fields, wx.FieldDeletedAt)
  32865. }
  32866. if m.FieldCleared(wx.FieldServerID) {
  32867. fields = append(fields, wx.FieldServerID)
  32868. }
  32869. if m.FieldCleared(wx.FieldOrganizationID) {
  32870. fields = append(fields, wx.FieldOrganizationID)
  32871. }
  32872. if m.FieldCleared(wx.FieldAPIBase) {
  32873. fields = append(fields, wx.FieldAPIBase)
  32874. }
  32875. if m.FieldCleared(wx.FieldAPIKey) {
  32876. fields = append(fields, wx.FieldAPIKey)
  32877. }
  32878. return fields
  32879. }
  32880. // FieldCleared returns a boolean indicating if a field with the given name was
  32881. // cleared in this mutation.
  32882. func (m *WxMutation) FieldCleared(name string) bool {
  32883. _, ok := m.clearedFields[name]
  32884. return ok
  32885. }
  32886. // ClearField clears the value of the field with the given name. It returns an
  32887. // error if the field is not defined in the schema.
  32888. func (m *WxMutation) ClearField(name string) error {
  32889. switch name {
  32890. case wx.FieldStatus:
  32891. m.ClearStatus()
  32892. return nil
  32893. case wx.FieldDeletedAt:
  32894. m.ClearDeletedAt()
  32895. return nil
  32896. case wx.FieldServerID:
  32897. m.ClearServerID()
  32898. return nil
  32899. case wx.FieldOrganizationID:
  32900. m.ClearOrganizationID()
  32901. return nil
  32902. case wx.FieldAPIBase:
  32903. m.ClearAPIBase()
  32904. return nil
  32905. case wx.FieldAPIKey:
  32906. m.ClearAPIKey()
  32907. return nil
  32908. }
  32909. return fmt.Errorf("unknown Wx nullable field %s", name)
  32910. }
  32911. // ResetField resets all changes in the mutation for the field with the given name.
  32912. // It returns an error if the field is not defined in the schema.
  32913. func (m *WxMutation) ResetField(name string) error {
  32914. switch name {
  32915. case wx.FieldCreatedAt:
  32916. m.ResetCreatedAt()
  32917. return nil
  32918. case wx.FieldUpdatedAt:
  32919. m.ResetUpdatedAt()
  32920. return nil
  32921. case wx.FieldStatus:
  32922. m.ResetStatus()
  32923. return nil
  32924. case wx.FieldDeletedAt:
  32925. m.ResetDeletedAt()
  32926. return nil
  32927. case wx.FieldServerID:
  32928. m.ResetServerID()
  32929. return nil
  32930. case wx.FieldPort:
  32931. m.ResetPort()
  32932. return nil
  32933. case wx.FieldProcessID:
  32934. m.ResetProcessID()
  32935. return nil
  32936. case wx.FieldCallback:
  32937. m.ResetCallback()
  32938. return nil
  32939. case wx.FieldWxid:
  32940. m.ResetWxid()
  32941. return nil
  32942. case wx.FieldAccount:
  32943. m.ResetAccount()
  32944. return nil
  32945. case wx.FieldNickname:
  32946. m.ResetNickname()
  32947. return nil
  32948. case wx.FieldTel:
  32949. m.ResetTel()
  32950. return nil
  32951. case wx.FieldHeadBig:
  32952. m.ResetHeadBig()
  32953. return nil
  32954. case wx.FieldOrganizationID:
  32955. m.ResetOrganizationID()
  32956. return nil
  32957. case wx.FieldAgentID:
  32958. m.ResetAgentID()
  32959. return nil
  32960. case wx.FieldAPIBase:
  32961. m.ResetAPIBase()
  32962. return nil
  32963. case wx.FieldAPIKey:
  32964. m.ResetAPIKey()
  32965. return nil
  32966. case wx.FieldAllowList:
  32967. m.ResetAllowList()
  32968. return nil
  32969. case wx.FieldGroupAllowList:
  32970. m.ResetGroupAllowList()
  32971. return nil
  32972. case wx.FieldBlockList:
  32973. m.ResetBlockList()
  32974. return nil
  32975. case wx.FieldGroupBlockList:
  32976. m.ResetGroupBlockList()
  32977. return nil
  32978. }
  32979. return fmt.Errorf("unknown Wx field %s", name)
  32980. }
  32981. // AddedEdges returns all edge names that were set/added in this mutation.
  32982. func (m *WxMutation) AddedEdges() []string {
  32983. edges := make([]string, 0, 2)
  32984. if m.server != nil {
  32985. edges = append(edges, wx.EdgeServer)
  32986. }
  32987. if m.agent != nil {
  32988. edges = append(edges, wx.EdgeAgent)
  32989. }
  32990. return edges
  32991. }
  32992. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32993. // name in this mutation.
  32994. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  32995. switch name {
  32996. case wx.EdgeServer:
  32997. if id := m.server; id != nil {
  32998. return []ent.Value{*id}
  32999. }
  33000. case wx.EdgeAgent:
  33001. if id := m.agent; id != nil {
  33002. return []ent.Value{*id}
  33003. }
  33004. }
  33005. return nil
  33006. }
  33007. // RemovedEdges returns all edge names that were removed in this mutation.
  33008. func (m *WxMutation) RemovedEdges() []string {
  33009. edges := make([]string, 0, 2)
  33010. return edges
  33011. }
  33012. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33013. // the given name in this mutation.
  33014. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  33015. return nil
  33016. }
  33017. // ClearedEdges returns all edge names that were cleared in this mutation.
  33018. func (m *WxMutation) ClearedEdges() []string {
  33019. edges := make([]string, 0, 2)
  33020. if m.clearedserver {
  33021. edges = append(edges, wx.EdgeServer)
  33022. }
  33023. if m.clearedagent {
  33024. edges = append(edges, wx.EdgeAgent)
  33025. }
  33026. return edges
  33027. }
  33028. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33029. // was cleared in this mutation.
  33030. func (m *WxMutation) EdgeCleared(name string) bool {
  33031. switch name {
  33032. case wx.EdgeServer:
  33033. return m.clearedserver
  33034. case wx.EdgeAgent:
  33035. return m.clearedagent
  33036. }
  33037. return false
  33038. }
  33039. // ClearEdge clears the value of the edge with the given name. It returns an error
  33040. // if that edge is not defined in the schema.
  33041. func (m *WxMutation) ClearEdge(name string) error {
  33042. switch name {
  33043. case wx.EdgeServer:
  33044. m.ClearServer()
  33045. return nil
  33046. case wx.EdgeAgent:
  33047. m.ClearAgent()
  33048. return nil
  33049. }
  33050. return fmt.Errorf("unknown Wx unique edge %s", name)
  33051. }
  33052. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33053. // It returns an error if the edge is not defined in the schema.
  33054. func (m *WxMutation) ResetEdge(name string) error {
  33055. switch name {
  33056. case wx.EdgeServer:
  33057. m.ResetServer()
  33058. return nil
  33059. case wx.EdgeAgent:
  33060. m.ResetAgent()
  33061. return nil
  33062. }
  33063. return fmt.Errorf("unknown Wx edge %s", name)
  33064. }
  33065. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  33066. type WxCardMutation struct {
  33067. config
  33068. op Op
  33069. typ string
  33070. id *uint64
  33071. created_at *time.Time
  33072. updated_at *time.Time
  33073. deleted_at *time.Time
  33074. user_id *uint64
  33075. adduser_id *int64
  33076. wx_user_id *uint64
  33077. addwx_user_id *int64
  33078. avatar *string
  33079. logo *string
  33080. name *string
  33081. company *string
  33082. address *string
  33083. phone *string
  33084. official_account *string
  33085. wechat_account *string
  33086. email *string
  33087. api_base *string
  33088. api_key *string
  33089. ai_info *string
  33090. intro *string
  33091. clearedFields map[string]struct{}
  33092. done bool
  33093. oldValue func(context.Context) (*WxCard, error)
  33094. predicates []predicate.WxCard
  33095. }
  33096. var _ ent.Mutation = (*WxCardMutation)(nil)
  33097. // wxcardOption allows management of the mutation configuration using functional options.
  33098. type wxcardOption func(*WxCardMutation)
  33099. // newWxCardMutation creates new mutation for the WxCard entity.
  33100. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  33101. m := &WxCardMutation{
  33102. config: c,
  33103. op: op,
  33104. typ: TypeWxCard,
  33105. clearedFields: make(map[string]struct{}),
  33106. }
  33107. for _, opt := range opts {
  33108. opt(m)
  33109. }
  33110. return m
  33111. }
  33112. // withWxCardID sets the ID field of the mutation.
  33113. func withWxCardID(id uint64) wxcardOption {
  33114. return func(m *WxCardMutation) {
  33115. var (
  33116. err error
  33117. once sync.Once
  33118. value *WxCard
  33119. )
  33120. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  33121. once.Do(func() {
  33122. if m.done {
  33123. err = errors.New("querying old values post mutation is not allowed")
  33124. } else {
  33125. value, err = m.Client().WxCard.Get(ctx, id)
  33126. }
  33127. })
  33128. return value, err
  33129. }
  33130. m.id = &id
  33131. }
  33132. }
  33133. // withWxCard sets the old WxCard of the mutation.
  33134. func withWxCard(node *WxCard) wxcardOption {
  33135. return func(m *WxCardMutation) {
  33136. m.oldValue = func(context.Context) (*WxCard, error) {
  33137. return node, nil
  33138. }
  33139. m.id = &node.ID
  33140. }
  33141. }
  33142. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33143. // executed in a transaction (ent.Tx), a transactional client is returned.
  33144. func (m WxCardMutation) Client() *Client {
  33145. client := &Client{config: m.config}
  33146. client.init()
  33147. return client
  33148. }
  33149. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33150. // it returns an error otherwise.
  33151. func (m WxCardMutation) Tx() (*Tx, error) {
  33152. if _, ok := m.driver.(*txDriver); !ok {
  33153. return nil, errors.New("ent: mutation is not running in a transaction")
  33154. }
  33155. tx := &Tx{config: m.config}
  33156. tx.init()
  33157. return tx, nil
  33158. }
  33159. // SetID sets the value of the id field. Note that this
  33160. // operation is only accepted on creation of WxCard entities.
  33161. func (m *WxCardMutation) SetID(id uint64) {
  33162. m.id = &id
  33163. }
  33164. // ID returns the ID value in the mutation. Note that the ID is only available
  33165. // if it was provided to the builder or after it was returned from the database.
  33166. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  33167. if m.id == nil {
  33168. return
  33169. }
  33170. return *m.id, true
  33171. }
  33172. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33173. // That means, if the mutation is applied within a transaction with an isolation level such
  33174. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33175. // or updated by the mutation.
  33176. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  33177. switch {
  33178. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33179. id, exists := m.ID()
  33180. if exists {
  33181. return []uint64{id}, nil
  33182. }
  33183. fallthrough
  33184. case m.op.Is(OpUpdate | OpDelete):
  33185. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  33186. default:
  33187. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33188. }
  33189. }
  33190. // SetCreatedAt sets the "created_at" field.
  33191. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  33192. m.created_at = &t
  33193. }
  33194. // CreatedAt returns the value of the "created_at" field in the mutation.
  33195. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  33196. v := m.created_at
  33197. if v == nil {
  33198. return
  33199. }
  33200. return *v, true
  33201. }
  33202. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  33203. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33205. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33206. if !m.op.Is(OpUpdateOne) {
  33207. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33208. }
  33209. if m.id == nil || m.oldValue == nil {
  33210. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33211. }
  33212. oldValue, err := m.oldValue(ctx)
  33213. if err != nil {
  33214. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33215. }
  33216. return oldValue.CreatedAt, nil
  33217. }
  33218. // ResetCreatedAt resets all changes to the "created_at" field.
  33219. func (m *WxCardMutation) ResetCreatedAt() {
  33220. m.created_at = nil
  33221. }
  33222. // SetUpdatedAt sets the "updated_at" field.
  33223. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  33224. m.updated_at = &t
  33225. }
  33226. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33227. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  33228. v := m.updated_at
  33229. if v == nil {
  33230. return
  33231. }
  33232. return *v, true
  33233. }
  33234. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  33235. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33237. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33238. if !m.op.Is(OpUpdateOne) {
  33239. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33240. }
  33241. if m.id == nil || m.oldValue == nil {
  33242. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33243. }
  33244. oldValue, err := m.oldValue(ctx)
  33245. if err != nil {
  33246. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33247. }
  33248. return oldValue.UpdatedAt, nil
  33249. }
  33250. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33251. func (m *WxCardMutation) ResetUpdatedAt() {
  33252. m.updated_at = nil
  33253. }
  33254. // SetDeletedAt sets the "deleted_at" field.
  33255. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  33256. m.deleted_at = &t
  33257. }
  33258. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33259. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  33260. v := m.deleted_at
  33261. if v == nil {
  33262. return
  33263. }
  33264. return *v, true
  33265. }
  33266. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  33267. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33269. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33270. if !m.op.Is(OpUpdateOne) {
  33271. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33272. }
  33273. if m.id == nil || m.oldValue == nil {
  33274. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33275. }
  33276. oldValue, err := m.oldValue(ctx)
  33277. if err != nil {
  33278. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33279. }
  33280. return oldValue.DeletedAt, nil
  33281. }
  33282. // ClearDeletedAt clears the value of the "deleted_at" field.
  33283. func (m *WxCardMutation) ClearDeletedAt() {
  33284. m.deleted_at = nil
  33285. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  33286. }
  33287. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33288. func (m *WxCardMutation) DeletedAtCleared() bool {
  33289. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  33290. return ok
  33291. }
  33292. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33293. func (m *WxCardMutation) ResetDeletedAt() {
  33294. m.deleted_at = nil
  33295. delete(m.clearedFields, wxcard.FieldDeletedAt)
  33296. }
  33297. // SetUserID sets the "user_id" field.
  33298. func (m *WxCardMutation) SetUserID(u uint64) {
  33299. m.user_id = &u
  33300. m.adduser_id = nil
  33301. }
  33302. // UserID returns the value of the "user_id" field in the mutation.
  33303. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  33304. v := m.user_id
  33305. if v == nil {
  33306. return
  33307. }
  33308. return *v, true
  33309. }
  33310. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  33311. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33313. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  33314. if !m.op.Is(OpUpdateOne) {
  33315. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  33316. }
  33317. if m.id == nil || m.oldValue == nil {
  33318. return v, errors.New("OldUserID requires an ID field in the mutation")
  33319. }
  33320. oldValue, err := m.oldValue(ctx)
  33321. if err != nil {
  33322. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  33323. }
  33324. return oldValue.UserID, nil
  33325. }
  33326. // AddUserID adds u to the "user_id" field.
  33327. func (m *WxCardMutation) AddUserID(u int64) {
  33328. if m.adduser_id != nil {
  33329. *m.adduser_id += u
  33330. } else {
  33331. m.adduser_id = &u
  33332. }
  33333. }
  33334. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  33335. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  33336. v := m.adduser_id
  33337. if v == nil {
  33338. return
  33339. }
  33340. return *v, true
  33341. }
  33342. // ClearUserID clears the value of the "user_id" field.
  33343. func (m *WxCardMutation) ClearUserID() {
  33344. m.user_id = nil
  33345. m.adduser_id = nil
  33346. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  33347. }
  33348. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  33349. func (m *WxCardMutation) UserIDCleared() bool {
  33350. _, ok := m.clearedFields[wxcard.FieldUserID]
  33351. return ok
  33352. }
  33353. // ResetUserID resets all changes to the "user_id" field.
  33354. func (m *WxCardMutation) ResetUserID() {
  33355. m.user_id = nil
  33356. m.adduser_id = nil
  33357. delete(m.clearedFields, wxcard.FieldUserID)
  33358. }
  33359. // SetWxUserID sets the "wx_user_id" field.
  33360. func (m *WxCardMutation) SetWxUserID(u uint64) {
  33361. m.wx_user_id = &u
  33362. m.addwx_user_id = nil
  33363. }
  33364. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  33365. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  33366. v := m.wx_user_id
  33367. if v == nil {
  33368. return
  33369. }
  33370. return *v, true
  33371. }
  33372. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  33373. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33375. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  33376. if !m.op.Is(OpUpdateOne) {
  33377. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  33378. }
  33379. if m.id == nil || m.oldValue == nil {
  33380. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  33381. }
  33382. oldValue, err := m.oldValue(ctx)
  33383. if err != nil {
  33384. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  33385. }
  33386. return oldValue.WxUserID, nil
  33387. }
  33388. // AddWxUserID adds u to the "wx_user_id" field.
  33389. func (m *WxCardMutation) AddWxUserID(u int64) {
  33390. if m.addwx_user_id != nil {
  33391. *m.addwx_user_id += u
  33392. } else {
  33393. m.addwx_user_id = &u
  33394. }
  33395. }
  33396. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  33397. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  33398. v := m.addwx_user_id
  33399. if v == nil {
  33400. return
  33401. }
  33402. return *v, true
  33403. }
  33404. // ClearWxUserID clears the value of the "wx_user_id" field.
  33405. func (m *WxCardMutation) ClearWxUserID() {
  33406. m.wx_user_id = nil
  33407. m.addwx_user_id = nil
  33408. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  33409. }
  33410. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  33411. func (m *WxCardMutation) WxUserIDCleared() bool {
  33412. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  33413. return ok
  33414. }
  33415. // ResetWxUserID resets all changes to the "wx_user_id" field.
  33416. func (m *WxCardMutation) ResetWxUserID() {
  33417. m.wx_user_id = nil
  33418. m.addwx_user_id = nil
  33419. delete(m.clearedFields, wxcard.FieldWxUserID)
  33420. }
  33421. // SetAvatar sets the "avatar" field.
  33422. func (m *WxCardMutation) SetAvatar(s string) {
  33423. m.avatar = &s
  33424. }
  33425. // Avatar returns the value of the "avatar" field in the mutation.
  33426. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  33427. v := m.avatar
  33428. if v == nil {
  33429. return
  33430. }
  33431. return *v, true
  33432. }
  33433. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  33434. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33436. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  33437. if !m.op.Is(OpUpdateOne) {
  33438. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  33439. }
  33440. if m.id == nil || m.oldValue == nil {
  33441. return v, errors.New("OldAvatar requires an ID field in the mutation")
  33442. }
  33443. oldValue, err := m.oldValue(ctx)
  33444. if err != nil {
  33445. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  33446. }
  33447. return oldValue.Avatar, nil
  33448. }
  33449. // ResetAvatar resets all changes to the "avatar" field.
  33450. func (m *WxCardMutation) ResetAvatar() {
  33451. m.avatar = nil
  33452. }
  33453. // SetLogo sets the "logo" field.
  33454. func (m *WxCardMutation) SetLogo(s string) {
  33455. m.logo = &s
  33456. }
  33457. // Logo returns the value of the "logo" field in the mutation.
  33458. func (m *WxCardMutation) Logo() (r string, exists bool) {
  33459. v := m.logo
  33460. if v == nil {
  33461. return
  33462. }
  33463. return *v, true
  33464. }
  33465. // OldLogo returns the old "logo" field's value of the WxCard entity.
  33466. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33468. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  33469. if !m.op.Is(OpUpdateOne) {
  33470. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  33471. }
  33472. if m.id == nil || m.oldValue == nil {
  33473. return v, errors.New("OldLogo requires an ID field in the mutation")
  33474. }
  33475. oldValue, err := m.oldValue(ctx)
  33476. if err != nil {
  33477. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  33478. }
  33479. return oldValue.Logo, nil
  33480. }
  33481. // ResetLogo resets all changes to the "logo" field.
  33482. func (m *WxCardMutation) ResetLogo() {
  33483. m.logo = nil
  33484. }
  33485. // SetName sets the "name" field.
  33486. func (m *WxCardMutation) SetName(s string) {
  33487. m.name = &s
  33488. }
  33489. // Name returns the value of the "name" field in the mutation.
  33490. func (m *WxCardMutation) Name() (r string, exists bool) {
  33491. v := m.name
  33492. if v == nil {
  33493. return
  33494. }
  33495. return *v, true
  33496. }
  33497. // OldName returns the old "name" field's value of the WxCard entity.
  33498. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33500. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  33501. if !m.op.Is(OpUpdateOne) {
  33502. return v, errors.New("OldName is only allowed on UpdateOne operations")
  33503. }
  33504. if m.id == nil || m.oldValue == nil {
  33505. return v, errors.New("OldName requires an ID field in the mutation")
  33506. }
  33507. oldValue, err := m.oldValue(ctx)
  33508. if err != nil {
  33509. return v, fmt.Errorf("querying old value for OldName: %w", err)
  33510. }
  33511. return oldValue.Name, nil
  33512. }
  33513. // ResetName resets all changes to the "name" field.
  33514. func (m *WxCardMutation) ResetName() {
  33515. m.name = nil
  33516. }
  33517. // SetCompany sets the "company" field.
  33518. func (m *WxCardMutation) SetCompany(s string) {
  33519. m.company = &s
  33520. }
  33521. // Company returns the value of the "company" field in the mutation.
  33522. func (m *WxCardMutation) Company() (r string, exists bool) {
  33523. v := m.company
  33524. if v == nil {
  33525. return
  33526. }
  33527. return *v, true
  33528. }
  33529. // OldCompany returns the old "company" field's value of the WxCard entity.
  33530. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33532. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  33533. if !m.op.Is(OpUpdateOne) {
  33534. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  33535. }
  33536. if m.id == nil || m.oldValue == nil {
  33537. return v, errors.New("OldCompany requires an ID field in the mutation")
  33538. }
  33539. oldValue, err := m.oldValue(ctx)
  33540. if err != nil {
  33541. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  33542. }
  33543. return oldValue.Company, nil
  33544. }
  33545. // ResetCompany resets all changes to the "company" field.
  33546. func (m *WxCardMutation) ResetCompany() {
  33547. m.company = nil
  33548. }
  33549. // SetAddress sets the "address" field.
  33550. func (m *WxCardMutation) SetAddress(s string) {
  33551. m.address = &s
  33552. }
  33553. // Address returns the value of the "address" field in the mutation.
  33554. func (m *WxCardMutation) Address() (r string, exists bool) {
  33555. v := m.address
  33556. if v == nil {
  33557. return
  33558. }
  33559. return *v, true
  33560. }
  33561. // OldAddress returns the old "address" field's value of the WxCard entity.
  33562. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33564. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  33565. if !m.op.Is(OpUpdateOne) {
  33566. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  33567. }
  33568. if m.id == nil || m.oldValue == nil {
  33569. return v, errors.New("OldAddress requires an ID field in the mutation")
  33570. }
  33571. oldValue, err := m.oldValue(ctx)
  33572. if err != nil {
  33573. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  33574. }
  33575. return oldValue.Address, nil
  33576. }
  33577. // ResetAddress resets all changes to the "address" field.
  33578. func (m *WxCardMutation) ResetAddress() {
  33579. m.address = nil
  33580. }
  33581. // SetPhone sets the "phone" field.
  33582. func (m *WxCardMutation) SetPhone(s string) {
  33583. m.phone = &s
  33584. }
  33585. // Phone returns the value of the "phone" field in the mutation.
  33586. func (m *WxCardMutation) Phone() (r string, exists bool) {
  33587. v := m.phone
  33588. if v == nil {
  33589. return
  33590. }
  33591. return *v, true
  33592. }
  33593. // OldPhone returns the old "phone" field's value of the WxCard entity.
  33594. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33596. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  33597. if !m.op.Is(OpUpdateOne) {
  33598. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  33599. }
  33600. if m.id == nil || m.oldValue == nil {
  33601. return v, errors.New("OldPhone requires an ID field in the mutation")
  33602. }
  33603. oldValue, err := m.oldValue(ctx)
  33604. if err != nil {
  33605. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  33606. }
  33607. return oldValue.Phone, nil
  33608. }
  33609. // ResetPhone resets all changes to the "phone" field.
  33610. func (m *WxCardMutation) ResetPhone() {
  33611. m.phone = nil
  33612. }
  33613. // SetOfficialAccount sets the "official_account" field.
  33614. func (m *WxCardMutation) SetOfficialAccount(s string) {
  33615. m.official_account = &s
  33616. }
  33617. // OfficialAccount returns the value of the "official_account" field in the mutation.
  33618. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  33619. v := m.official_account
  33620. if v == nil {
  33621. return
  33622. }
  33623. return *v, true
  33624. }
  33625. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  33626. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33628. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  33629. if !m.op.Is(OpUpdateOne) {
  33630. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  33631. }
  33632. if m.id == nil || m.oldValue == nil {
  33633. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  33634. }
  33635. oldValue, err := m.oldValue(ctx)
  33636. if err != nil {
  33637. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  33638. }
  33639. return oldValue.OfficialAccount, nil
  33640. }
  33641. // ResetOfficialAccount resets all changes to the "official_account" field.
  33642. func (m *WxCardMutation) ResetOfficialAccount() {
  33643. m.official_account = nil
  33644. }
  33645. // SetWechatAccount sets the "wechat_account" field.
  33646. func (m *WxCardMutation) SetWechatAccount(s string) {
  33647. m.wechat_account = &s
  33648. }
  33649. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  33650. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  33651. v := m.wechat_account
  33652. if v == nil {
  33653. return
  33654. }
  33655. return *v, true
  33656. }
  33657. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  33658. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33660. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  33661. if !m.op.Is(OpUpdateOne) {
  33662. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  33663. }
  33664. if m.id == nil || m.oldValue == nil {
  33665. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  33666. }
  33667. oldValue, err := m.oldValue(ctx)
  33668. if err != nil {
  33669. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  33670. }
  33671. return oldValue.WechatAccount, nil
  33672. }
  33673. // ResetWechatAccount resets all changes to the "wechat_account" field.
  33674. func (m *WxCardMutation) ResetWechatAccount() {
  33675. m.wechat_account = nil
  33676. }
  33677. // SetEmail sets the "email" field.
  33678. func (m *WxCardMutation) SetEmail(s string) {
  33679. m.email = &s
  33680. }
  33681. // Email returns the value of the "email" field in the mutation.
  33682. func (m *WxCardMutation) Email() (r string, exists bool) {
  33683. v := m.email
  33684. if v == nil {
  33685. return
  33686. }
  33687. return *v, true
  33688. }
  33689. // OldEmail returns the old "email" field's value of the WxCard entity.
  33690. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33692. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  33693. if !m.op.Is(OpUpdateOne) {
  33694. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  33695. }
  33696. if m.id == nil || m.oldValue == nil {
  33697. return v, errors.New("OldEmail requires an ID field in the mutation")
  33698. }
  33699. oldValue, err := m.oldValue(ctx)
  33700. if err != nil {
  33701. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  33702. }
  33703. return oldValue.Email, nil
  33704. }
  33705. // ClearEmail clears the value of the "email" field.
  33706. func (m *WxCardMutation) ClearEmail() {
  33707. m.email = nil
  33708. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  33709. }
  33710. // EmailCleared returns if the "email" field was cleared in this mutation.
  33711. func (m *WxCardMutation) EmailCleared() bool {
  33712. _, ok := m.clearedFields[wxcard.FieldEmail]
  33713. return ok
  33714. }
  33715. // ResetEmail resets all changes to the "email" field.
  33716. func (m *WxCardMutation) ResetEmail() {
  33717. m.email = nil
  33718. delete(m.clearedFields, wxcard.FieldEmail)
  33719. }
  33720. // SetAPIBase sets the "api_base" field.
  33721. func (m *WxCardMutation) SetAPIBase(s string) {
  33722. m.api_base = &s
  33723. }
  33724. // APIBase returns the value of the "api_base" field in the mutation.
  33725. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  33726. v := m.api_base
  33727. if v == nil {
  33728. return
  33729. }
  33730. return *v, true
  33731. }
  33732. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  33733. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33735. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  33736. if !m.op.Is(OpUpdateOne) {
  33737. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  33738. }
  33739. if m.id == nil || m.oldValue == nil {
  33740. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  33741. }
  33742. oldValue, err := m.oldValue(ctx)
  33743. if err != nil {
  33744. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  33745. }
  33746. return oldValue.APIBase, nil
  33747. }
  33748. // ClearAPIBase clears the value of the "api_base" field.
  33749. func (m *WxCardMutation) ClearAPIBase() {
  33750. m.api_base = nil
  33751. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  33752. }
  33753. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  33754. func (m *WxCardMutation) APIBaseCleared() bool {
  33755. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  33756. return ok
  33757. }
  33758. // ResetAPIBase resets all changes to the "api_base" field.
  33759. func (m *WxCardMutation) ResetAPIBase() {
  33760. m.api_base = nil
  33761. delete(m.clearedFields, wxcard.FieldAPIBase)
  33762. }
  33763. // SetAPIKey sets the "api_key" field.
  33764. func (m *WxCardMutation) SetAPIKey(s string) {
  33765. m.api_key = &s
  33766. }
  33767. // APIKey returns the value of the "api_key" field in the mutation.
  33768. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  33769. v := m.api_key
  33770. if v == nil {
  33771. return
  33772. }
  33773. return *v, true
  33774. }
  33775. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  33776. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33778. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  33779. if !m.op.Is(OpUpdateOne) {
  33780. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  33781. }
  33782. if m.id == nil || m.oldValue == nil {
  33783. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  33784. }
  33785. oldValue, err := m.oldValue(ctx)
  33786. if err != nil {
  33787. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  33788. }
  33789. return oldValue.APIKey, nil
  33790. }
  33791. // ClearAPIKey clears the value of the "api_key" field.
  33792. func (m *WxCardMutation) ClearAPIKey() {
  33793. m.api_key = nil
  33794. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  33795. }
  33796. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  33797. func (m *WxCardMutation) APIKeyCleared() bool {
  33798. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  33799. return ok
  33800. }
  33801. // ResetAPIKey resets all changes to the "api_key" field.
  33802. func (m *WxCardMutation) ResetAPIKey() {
  33803. m.api_key = nil
  33804. delete(m.clearedFields, wxcard.FieldAPIKey)
  33805. }
  33806. // SetAiInfo sets the "ai_info" field.
  33807. func (m *WxCardMutation) SetAiInfo(s string) {
  33808. m.ai_info = &s
  33809. }
  33810. // AiInfo returns the value of the "ai_info" field in the mutation.
  33811. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  33812. v := m.ai_info
  33813. if v == nil {
  33814. return
  33815. }
  33816. return *v, true
  33817. }
  33818. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  33819. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33821. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  33822. if !m.op.Is(OpUpdateOne) {
  33823. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  33824. }
  33825. if m.id == nil || m.oldValue == nil {
  33826. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  33827. }
  33828. oldValue, err := m.oldValue(ctx)
  33829. if err != nil {
  33830. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  33831. }
  33832. return oldValue.AiInfo, nil
  33833. }
  33834. // ClearAiInfo clears the value of the "ai_info" field.
  33835. func (m *WxCardMutation) ClearAiInfo() {
  33836. m.ai_info = nil
  33837. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  33838. }
  33839. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  33840. func (m *WxCardMutation) AiInfoCleared() bool {
  33841. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  33842. return ok
  33843. }
  33844. // ResetAiInfo resets all changes to the "ai_info" field.
  33845. func (m *WxCardMutation) ResetAiInfo() {
  33846. m.ai_info = nil
  33847. delete(m.clearedFields, wxcard.FieldAiInfo)
  33848. }
  33849. // SetIntro sets the "intro" field.
  33850. func (m *WxCardMutation) SetIntro(s string) {
  33851. m.intro = &s
  33852. }
  33853. // Intro returns the value of the "intro" field in the mutation.
  33854. func (m *WxCardMutation) Intro() (r string, exists bool) {
  33855. v := m.intro
  33856. if v == nil {
  33857. return
  33858. }
  33859. return *v, true
  33860. }
  33861. // OldIntro returns the old "intro" field's value of the WxCard entity.
  33862. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33864. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  33865. if !m.op.Is(OpUpdateOne) {
  33866. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  33867. }
  33868. if m.id == nil || m.oldValue == nil {
  33869. return v, errors.New("OldIntro requires an ID field in the mutation")
  33870. }
  33871. oldValue, err := m.oldValue(ctx)
  33872. if err != nil {
  33873. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  33874. }
  33875. return oldValue.Intro, nil
  33876. }
  33877. // ClearIntro clears the value of the "intro" field.
  33878. func (m *WxCardMutation) ClearIntro() {
  33879. m.intro = nil
  33880. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  33881. }
  33882. // IntroCleared returns if the "intro" field was cleared in this mutation.
  33883. func (m *WxCardMutation) IntroCleared() bool {
  33884. _, ok := m.clearedFields[wxcard.FieldIntro]
  33885. return ok
  33886. }
  33887. // ResetIntro resets all changes to the "intro" field.
  33888. func (m *WxCardMutation) ResetIntro() {
  33889. m.intro = nil
  33890. delete(m.clearedFields, wxcard.FieldIntro)
  33891. }
  33892. // Where appends a list predicates to the WxCardMutation builder.
  33893. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  33894. m.predicates = append(m.predicates, ps...)
  33895. }
  33896. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  33897. // users can use type-assertion to append predicates that do not depend on any generated package.
  33898. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  33899. p := make([]predicate.WxCard, len(ps))
  33900. for i := range ps {
  33901. p[i] = ps[i]
  33902. }
  33903. m.Where(p...)
  33904. }
  33905. // Op returns the operation name.
  33906. func (m *WxCardMutation) Op() Op {
  33907. return m.op
  33908. }
  33909. // SetOp allows setting the mutation operation.
  33910. func (m *WxCardMutation) SetOp(op Op) {
  33911. m.op = op
  33912. }
  33913. // Type returns the node type of this mutation (WxCard).
  33914. func (m *WxCardMutation) Type() string {
  33915. return m.typ
  33916. }
  33917. // Fields returns all fields that were changed during this mutation. Note that in
  33918. // order to get all numeric fields that were incremented/decremented, call
  33919. // AddedFields().
  33920. func (m *WxCardMutation) Fields() []string {
  33921. fields := make([]string, 0, 18)
  33922. if m.created_at != nil {
  33923. fields = append(fields, wxcard.FieldCreatedAt)
  33924. }
  33925. if m.updated_at != nil {
  33926. fields = append(fields, wxcard.FieldUpdatedAt)
  33927. }
  33928. if m.deleted_at != nil {
  33929. fields = append(fields, wxcard.FieldDeletedAt)
  33930. }
  33931. if m.user_id != nil {
  33932. fields = append(fields, wxcard.FieldUserID)
  33933. }
  33934. if m.wx_user_id != nil {
  33935. fields = append(fields, wxcard.FieldWxUserID)
  33936. }
  33937. if m.avatar != nil {
  33938. fields = append(fields, wxcard.FieldAvatar)
  33939. }
  33940. if m.logo != nil {
  33941. fields = append(fields, wxcard.FieldLogo)
  33942. }
  33943. if m.name != nil {
  33944. fields = append(fields, wxcard.FieldName)
  33945. }
  33946. if m.company != nil {
  33947. fields = append(fields, wxcard.FieldCompany)
  33948. }
  33949. if m.address != nil {
  33950. fields = append(fields, wxcard.FieldAddress)
  33951. }
  33952. if m.phone != nil {
  33953. fields = append(fields, wxcard.FieldPhone)
  33954. }
  33955. if m.official_account != nil {
  33956. fields = append(fields, wxcard.FieldOfficialAccount)
  33957. }
  33958. if m.wechat_account != nil {
  33959. fields = append(fields, wxcard.FieldWechatAccount)
  33960. }
  33961. if m.email != nil {
  33962. fields = append(fields, wxcard.FieldEmail)
  33963. }
  33964. if m.api_base != nil {
  33965. fields = append(fields, wxcard.FieldAPIBase)
  33966. }
  33967. if m.api_key != nil {
  33968. fields = append(fields, wxcard.FieldAPIKey)
  33969. }
  33970. if m.ai_info != nil {
  33971. fields = append(fields, wxcard.FieldAiInfo)
  33972. }
  33973. if m.intro != nil {
  33974. fields = append(fields, wxcard.FieldIntro)
  33975. }
  33976. return fields
  33977. }
  33978. // Field returns the value of a field with the given name. The second boolean
  33979. // return value indicates that this field was not set, or was not defined in the
  33980. // schema.
  33981. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  33982. switch name {
  33983. case wxcard.FieldCreatedAt:
  33984. return m.CreatedAt()
  33985. case wxcard.FieldUpdatedAt:
  33986. return m.UpdatedAt()
  33987. case wxcard.FieldDeletedAt:
  33988. return m.DeletedAt()
  33989. case wxcard.FieldUserID:
  33990. return m.UserID()
  33991. case wxcard.FieldWxUserID:
  33992. return m.WxUserID()
  33993. case wxcard.FieldAvatar:
  33994. return m.Avatar()
  33995. case wxcard.FieldLogo:
  33996. return m.Logo()
  33997. case wxcard.FieldName:
  33998. return m.Name()
  33999. case wxcard.FieldCompany:
  34000. return m.Company()
  34001. case wxcard.FieldAddress:
  34002. return m.Address()
  34003. case wxcard.FieldPhone:
  34004. return m.Phone()
  34005. case wxcard.FieldOfficialAccount:
  34006. return m.OfficialAccount()
  34007. case wxcard.FieldWechatAccount:
  34008. return m.WechatAccount()
  34009. case wxcard.FieldEmail:
  34010. return m.Email()
  34011. case wxcard.FieldAPIBase:
  34012. return m.APIBase()
  34013. case wxcard.FieldAPIKey:
  34014. return m.APIKey()
  34015. case wxcard.FieldAiInfo:
  34016. return m.AiInfo()
  34017. case wxcard.FieldIntro:
  34018. return m.Intro()
  34019. }
  34020. return nil, false
  34021. }
  34022. // OldField returns the old value of the field from the database. An error is
  34023. // returned if the mutation operation is not UpdateOne, or the query to the
  34024. // database failed.
  34025. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34026. switch name {
  34027. case wxcard.FieldCreatedAt:
  34028. return m.OldCreatedAt(ctx)
  34029. case wxcard.FieldUpdatedAt:
  34030. return m.OldUpdatedAt(ctx)
  34031. case wxcard.FieldDeletedAt:
  34032. return m.OldDeletedAt(ctx)
  34033. case wxcard.FieldUserID:
  34034. return m.OldUserID(ctx)
  34035. case wxcard.FieldWxUserID:
  34036. return m.OldWxUserID(ctx)
  34037. case wxcard.FieldAvatar:
  34038. return m.OldAvatar(ctx)
  34039. case wxcard.FieldLogo:
  34040. return m.OldLogo(ctx)
  34041. case wxcard.FieldName:
  34042. return m.OldName(ctx)
  34043. case wxcard.FieldCompany:
  34044. return m.OldCompany(ctx)
  34045. case wxcard.FieldAddress:
  34046. return m.OldAddress(ctx)
  34047. case wxcard.FieldPhone:
  34048. return m.OldPhone(ctx)
  34049. case wxcard.FieldOfficialAccount:
  34050. return m.OldOfficialAccount(ctx)
  34051. case wxcard.FieldWechatAccount:
  34052. return m.OldWechatAccount(ctx)
  34053. case wxcard.FieldEmail:
  34054. return m.OldEmail(ctx)
  34055. case wxcard.FieldAPIBase:
  34056. return m.OldAPIBase(ctx)
  34057. case wxcard.FieldAPIKey:
  34058. return m.OldAPIKey(ctx)
  34059. case wxcard.FieldAiInfo:
  34060. return m.OldAiInfo(ctx)
  34061. case wxcard.FieldIntro:
  34062. return m.OldIntro(ctx)
  34063. }
  34064. return nil, fmt.Errorf("unknown WxCard field %s", name)
  34065. }
  34066. // SetField sets the value of a field with the given name. It returns an error if
  34067. // the field is not defined in the schema, or if the type mismatched the field
  34068. // type.
  34069. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  34070. switch name {
  34071. case wxcard.FieldCreatedAt:
  34072. v, ok := value.(time.Time)
  34073. if !ok {
  34074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34075. }
  34076. m.SetCreatedAt(v)
  34077. return nil
  34078. case wxcard.FieldUpdatedAt:
  34079. v, ok := value.(time.Time)
  34080. if !ok {
  34081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34082. }
  34083. m.SetUpdatedAt(v)
  34084. return nil
  34085. case wxcard.FieldDeletedAt:
  34086. v, ok := value.(time.Time)
  34087. if !ok {
  34088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34089. }
  34090. m.SetDeletedAt(v)
  34091. return nil
  34092. case wxcard.FieldUserID:
  34093. v, ok := value.(uint64)
  34094. if !ok {
  34095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34096. }
  34097. m.SetUserID(v)
  34098. return nil
  34099. case wxcard.FieldWxUserID:
  34100. v, ok := value.(uint64)
  34101. if !ok {
  34102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34103. }
  34104. m.SetWxUserID(v)
  34105. return nil
  34106. case wxcard.FieldAvatar:
  34107. v, ok := value.(string)
  34108. if !ok {
  34109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34110. }
  34111. m.SetAvatar(v)
  34112. return nil
  34113. case wxcard.FieldLogo:
  34114. v, ok := value.(string)
  34115. if !ok {
  34116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34117. }
  34118. m.SetLogo(v)
  34119. return nil
  34120. case wxcard.FieldName:
  34121. v, ok := value.(string)
  34122. if !ok {
  34123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34124. }
  34125. m.SetName(v)
  34126. return nil
  34127. case wxcard.FieldCompany:
  34128. v, ok := value.(string)
  34129. if !ok {
  34130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34131. }
  34132. m.SetCompany(v)
  34133. return nil
  34134. case wxcard.FieldAddress:
  34135. v, ok := value.(string)
  34136. if !ok {
  34137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34138. }
  34139. m.SetAddress(v)
  34140. return nil
  34141. case wxcard.FieldPhone:
  34142. v, ok := value.(string)
  34143. if !ok {
  34144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34145. }
  34146. m.SetPhone(v)
  34147. return nil
  34148. case wxcard.FieldOfficialAccount:
  34149. v, ok := value.(string)
  34150. if !ok {
  34151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34152. }
  34153. m.SetOfficialAccount(v)
  34154. return nil
  34155. case wxcard.FieldWechatAccount:
  34156. v, ok := value.(string)
  34157. if !ok {
  34158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34159. }
  34160. m.SetWechatAccount(v)
  34161. return nil
  34162. case wxcard.FieldEmail:
  34163. v, ok := value.(string)
  34164. if !ok {
  34165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34166. }
  34167. m.SetEmail(v)
  34168. return nil
  34169. case wxcard.FieldAPIBase:
  34170. v, ok := value.(string)
  34171. if !ok {
  34172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34173. }
  34174. m.SetAPIBase(v)
  34175. return nil
  34176. case wxcard.FieldAPIKey:
  34177. v, ok := value.(string)
  34178. if !ok {
  34179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34180. }
  34181. m.SetAPIKey(v)
  34182. return nil
  34183. case wxcard.FieldAiInfo:
  34184. v, ok := value.(string)
  34185. if !ok {
  34186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34187. }
  34188. m.SetAiInfo(v)
  34189. return nil
  34190. case wxcard.FieldIntro:
  34191. v, ok := value.(string)
  34192. if !ok {
  34193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34194. }
  34195. m.SetIntro(v)
  34196. return nil
  34197. }
  34198. return fmt.Errorf("unknown WxCard field %s", name)
  34199. }
  34200. // AddedFields returns all numeric fields that were incremented/decremented during
  34201. // this mutation.
  34202. func (m *WxCardMutation) AddedFields() []string {
  34203. var fields []string
  34204. if m.adduser_id != nil {
  34205. fields = append(fields, wxcard.FieldUserID)
  34206. }
  34207. if m.addwx_user_id != nil {
  34208. fields = append(fields, wxcard.FieldWxUserID)
  34209. }
  34210. return fields
  34211. }
  34212. // AddedField returns the numeric value that was incremented/decremented on a field
  34213. // with the given name. The second boolean return value indicates that this field
  34214. // was not set, or was not defined in the schema.
  34215. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  34216. switch name {
  34217. case wxcard.FieldUserID:
  34218. return m.AddedUserID()
  34219. case wxcard.FieldWxUserID:
  34220. return m.AddedWxUserID()
  34221. }
  34222. return nil, false
  34223. }
  34224. // AddField adds the value to the field with the given name. It returns an error if
  34225. // the field is not defined in the schema, or if the type mismatched the field
  34226. // type.
  34227. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  34228. switch name {
  34229. case wxcard.FieldUserID:
  34230. v, ok := value.(int64)
  34231. if !ok {
  34232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34233. }
  34234. m.AddUserID(v)
  34235. return nil
  34236. case wxcard.FieldWxUserID:
  34237. v, ok := value.(int64)
  34238. if !ok {
  34239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34240. }
  34241. m.AddWxUserID(v)
  34242. return nil
  34243. }
  34244. return fmt.Errorf("unknown WxCard numeric field %s", name)
  34245. }
  34246. // ClearedFields returns all nullable fields that were cleared during this
  34247. // mutation.
  34248. func (m *WxCardMutation) ClearedFields() []string {
  34249. var fields []string
  34250. if m.FieldCleared(wxcard.FieldDeletedAt) {
  34251. fields = append(fields, wxcard.FieldDeletedAt)
  34252. }
  34253. if m.FieldCleared(wxcard.FieldUserID) {
  34254. fields = append(fields, wxcard.FieldUserID)
  34255. }
  34256. if m.FieldCleared(wxcard.FieldWxUserID) {
  34257. fields = append(fields, wxcard.FieldWxUserID)
  34258. }
  34259. if m.FieldCleared(wxcard.FieldEmail) {
  34260. fields = append(fields, wxcard.FieldEmail)
  34261. }
  34262. if m.FieldCleared(wxcard.FieldAPIBase) {
  34263. fields = append(fields, wxcard.FieldAPIBase)
  34264. }
  34265. if m.FieldCleared(wxcard.FieldAPIKey) {
  34266. fields = append(fields, wxcard.FieldAPIKey)
  34267. }
  34268. if m.FieldCleared(wxcard.FieldAiInfo) {
  34269. fields = append(fields, wxcard.FieldAiInfo)
  34270. }
  34271. if m.FieldCleared(wxcard.FieldIntro) {
  34272. fields = append(fields, wxcard.FieldIntro)
  34273. }
  34274. return fields
  34275. }
  34276. // FieldCleared returns a boolean indicating if a field with the given name was
  34277. // cleared in this mutation.
  34278. func (m *WxCardMutation) FieldCleared(name string) bool {
  34279. _, ok := m.clearedFields[name]
  34280. return ok
  34281. }
  34282. // ClearField clears the value of the field with the given name. It returns an
  34283. // error if the field is not defined in the schema.
  34284. func (m *WxCardMutation) ClearField(name string) error {
  34285. switch name {
  34286. case wxcard.FieldDeletedAt:
  34287. m.ClearDeletedAt()
  34288. return nil
  34289. case wxcard.FieldUserID:
  34290. m.ClearUserID()
  34291. return nil
  34292. case wxcard.FieldWxUserID:
  34293. m.ClearWxUserID()
  34294. return nil
  34295. case wxcard.FieldEmail:
  34296. m.ClearEmail()
  34297. return nil
  34298. case wxcard.FieldAPIBase:
  34299. m.ClearAPIBase()
  34300. return nil
  34301. case wxcard.FieldAPIKey:
  34302. m.ClearAPIKey()
  34303. return nil
  34304. case wxcard.FieldAiInfo:
  34305. m.ClearAiInfo()
  34306. return nil
  34307. case wxcard.FieldIntro:
  34308. m.ClearIntro()
  34309. return nil
  34310. }
  34311. return fmt.Errorf("unknown WxCard nullable field %s", name)
  34312. }
  34313. // ResetField resets all changes in the mutation for the field with the given name.
  34314. // It returns an error if the field is not defined in the schema.
  34315. func (m *WxCardMutation) ResetField(name string) error {
  34316. switch name {
  34317. case wxcard.FieldCreatedAt:
  34318. m.ResetCreatedAt()
  34319. return nil
  34320. case wxcard.FieldUpdatedAt:
  34321. m.ResetUpdatedAt()
  34322. return nil
  34323. case wxcard.FieldDeletedAt:
  34324. m.ResetDeletedAt()
  34325. return nil
  34326. case wxcard.FieldUserID:
  34327. m.ResetUserID()
  34328. return nil
  34329. case wxcard.FieldWxUserID:
  34330. m.ResetWxUserID()
  34331. return nil
  34332. case wxcard.FieldAvatar:
  34333. m.ResetAvatar()
  34334. return nil
  34335. case wxcard.FieldLogo:
  34336. m.ResetLogo()
  34337. return nil
  34338. case wxcard.FieldName:
  34339. m.ResetName()
  34340. return nil
  34341. case wxcard.FieldCompany:
  34342. m.ResetCompany()
  34343. return nil
  34344. case wxcard.FieldAddress:
  34345. m.ResetAddress()
  34346. return nil
  34347. case wxcard.FieldPhone:
  34348. m.ResetPhone()
  34349. return nil
  34350. case wxcard.FieldOfficialAccount:
  34351. m.ResetOfficialAccount()
  34352. return nil
  34353. case wxcard.FieldWechatAccount:
  34354. m.ResetWechatAccount()
  34355. return nil
  34356. case wxcard.FieldEmail:
  34357. m.ResetEmail()
  34358. return nil
  34359. case wxcard.FieldAPIBase:
  34360. m.ResetAPIBase()
  34361. return nil
  34362. case wxcard.FieldAPIKey:
  34363. m.ResetAPIKey()
  34364. return nil
  34365. case wxcard.FieldAiInfo:
  34366. m.ResetAiInfo()
  34367. return nil
  34368. case wxcard.FieldIntro:
  34369. m.ResetIntro()
  34370. return nil
  34371. }
  34372. return fmt.Errorf("unknown WxCard field %s", name)
  34373. }
  34374. // AddedEdges returns all edge names that were set/added in this mutation.
  34375. func (m *WxCardMutation) AddedEdges() []string {
  34376. edges := make([]string, 0, 0)
  34377. return edges
  34378. }
  34379. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34380. // name in this mutation.
  34381. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  34382. return nil
  34383. }
  34384. // RemovedEdges returns all edge names that were removed in this mutation.
  34385. func (m *WxCardMutation) RemovedEdges() []string {
  34386. edges := make([]string, 0, 0)
  34387. return edges
  34388. }
  34389. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34390. // the given name in this mutation.
  34391. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  34392. return nil
  34393. }
  34394. // ClearedEdges returns all edge names that were cleared in this mutation.
  34395. func (m *WxCardMutation) ClearedEdges() []string {
  34396. edges := make([]string, 0, 0)
  34397. return edges
  34398. }
  34399. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34400. // was cleared in this mutation.
  34401. func (m *WxCardMutation) EdgeCleared(name string) bool {
  34402. return false
  34403. }
  34404. // ClearEdge clears the value of the edge with the given name. It returns an error
  34405. // if that edge is not defined in the schema.
  34406. func (m *WxCardMutation) ClearEdge(name string) error {
  34407. return fmt.Errorf("unknown WxCard unique edge %s", name)
  34408. }
  34409. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34410. // It returns an error if the edge is not defined in the schema.
  34411. func (m *WxCardMutation) ResetEdge(name string) error {
  34412. return fmt.Errorf("unknown WxCard edge %s", name)
  34413. }
  34414. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  34415. type WxCardUserMutation struct {
  34416. config
  34417. op Op
  34418. typ string
  34419. id *uint64
  34420. created_at *time.Time
  34421. updated_at *time.Time
  34422. deleted_at *time.Time
  34423. wxid *string
  34424. account *string
  34425. avatar *string
  34426. nickname *string
  34427. remark *string
  34428. phone *string
  34429. open_id *string
  34430. union_id *string
  34431. session_key *string
  34432. is_vip *int
  34433. addis_vip *int
  34434. clearedFields map[string]struct{}
  34435. done bool
  34436. oldValue func(context.Context) (*WxCardUser, error)
  34437. predicates []predicate.WxCardUser
  34438. }
  34439. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  34440. // wxcarduserOption allows management of the mutation configuration using functional options.
  34441. type wxcarduserOption func(*WxCardUserMutation)
  34442. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  34443. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  34444. m := &WxCardUserMutation{
  34445. config: c,
  34446. op: op,
  34447. typ: TypeWxCardUser,
  34448. clearedFields: make(map[string]struct{}),
  34449. }
  34450. for _, opt := range opts {
  34451. opt(m)
  34452. }
  34453. return m
  34454. }
  34455. // withWxCardUserID sets the ID field of the mutation.
  34456. func withWxCardUserID(id uint64) wxcarduserOption {
  34457. return func(m *WxCardUserMutation) {
  34458. var (
  34459. err error
  34460. once sync.Once
  34461. value *WxCardUser
  34462. )
  34463. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  34464. once.Do(func() {
  34465. if m.done {
  34466. err = errors.New("querying old values post mutation is not allowed")
  34467. } else {
  34468. value, err = m.Client().WxCardUser.Get(ctx, id)
  34469. }
  34470. })
  34471. return value, err
  34472. }
  34473. m.id = &id
  34474. }
  34475. }
  34476. // withWxCardUser sets the old WxCardUser of the mutation.
  34477. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  34478. return func(m *WxCardUserMutation) {
  34479. m.oldValue = func(context.Context) (*WxCardUser, error) {
  34480. return node, nil
  34481. }
  34482. m.id = &node.ID
  34483. }
  34484. }
  34485. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34486. // executed in a transaction (ent.Tx), a transactional client is returned.
  34487. func (m WxCardUserMutation) Client() *Client {
  34488. client := &Client{config: m.config}
  34489. client.init()
  34490. return client
  34491. }
  34492. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34493. // it returns an error otherwise.
  34494. func (m WxCardUserMutation) Tx() (*Tx, error) {
  34495. if _, ok := m.driver.(*txDriver); !ok {
  34496. return nil, errors.New("ent: mutation is not running in a transaction")
  34497. }
  34498. tx := &Tx{config: m.config}
  34499. tx.init()
  34500. return tx, nil
  34501. }
  34502. // SetID sets the value of the id field. Note that this
  34503. // operation is only accepted on creation of WxCardUser entities.
  34504. func (m *WxCardUserMutation) SetID(id uint64) {
  34505. m.id = &id
  34506. }
  34507. // ID returns the ID value in the mutation. Note that the ID is only available
  34508. // if it was provided to the builder or after it was returned from the database.
  34509. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  34510. if m.id == nil {
  34511. return
  34512. }
  34513. return *m.id, true
  34514. }
  34515. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34516. // That means, if the mutation is applied within a transaction with an isolation level such
  34517. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34518. // or updated by the mutation.
  34519. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  34520. switch {
  34521. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34522. id, exists := m.ID()
  34523. if exists {
  34524. return []uint64{id}, nil
  34525. }
  34526. fallthrough
  34527. case m.op.Is(OpUpdate | OpDelete):
  34528. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  34529. default:
  34530. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34531. }
  34532. }
  34533. // SetCreatedAt sets the "created_at" field.
  34534. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  34535. m.created_at = &t
  34536. }
  34537. // CreatedAt returns the value of the "created_at" field in the mutation.
  34538. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  34539. v := m.created_at
  34540. if v == nil {
  34541. return
  34542. }
  34543. return *v, true
  34544. }
  34545. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  34546. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34548. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34549. if !m.op.Is(OpUpdateOne) {
  34550. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34551. }
  34552. if m.id == nil || m.oldValue == nil {
  34553. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34554. }
  34555. oldValue, err := m.oldValue(ctx)
  34556. if err != nil {
  34557. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34558. }
  34559. return oldValue.CreatedAt, nil
  34560. }
  34561. // ResetCreatedAt resets all changes to the "created_at" field.
  34562. func (m *WxCardUserMutation) ResetCreatedAt() {
  34563. m.created_at = nil
  34564. }
  34565. // SetUpdatedAt sets the "updated_at" field.
  34566. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  34567. m.updated_at = &t
  34568. }
  34569. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34570. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  34571. v := m.updated_at
  34572. if v == nil {
  34573. return
  34574. }
  34575. return *v, true
  34576. }
  34577. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  34578. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34580. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34581. if !m.op.Is(OpUpdateOne) {
  34582. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34583. }
  34584. if m.id == nil || m.oldValue == nil {
  34585. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34586. }
  34587. oldValue, err := m.oldValue(ctx)
  34588. if err != nil {
  34589. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34590. }
  34591. return oldValue.UpdatedAt, nil
  34592. }
  34593. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34594. func (m *WxCardUserMutation) ResetUpdatedAt() {
  34595. m.updated_at = nil
  34596. }
  34597. // SetDeletedAt sets the "deleted_at" field.
  34598. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  34599. m.deleted_at = &t
  34600. }
  34601. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34602. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  34603. v := m.deleted_at
  34604. if v == nil {
  34605. return
  34606. }
  34607. return *v, true
  34608. }
  34609. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  34610. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34612. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34613. if !m.op.Is(OpUpdateOne) {
  34614. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34615. }
  34616. if m.id == nil || m.oldValue == nil {
  34617. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34618. }
  34619. oldValue, err := m.oldValue(ctx)
  34620. if err != nil {
  34621. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34622. }
  34623. return oldValue.DeletedAt, nil
  34624. }
  34625. // ClearDeletedAt clears the value of the "deleted_at" field.
  34626. func (m *WxCardUserMutation) ClearDeletedAt() {
  34627. m.deleted_at = nil
  34628. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  34629. }
  34630. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34631. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  34632. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  34633. return ok
  34634. }
  34635. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34636. func (m *WxCardUserMutation) ResetDeletedAt() {
  34637. m.deleted_at = nil
  34638. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  34639. }
  34640. // SetWxid sets the "wxid" field.
  34641. func (m *WxCardUserMutation) SetWxid(s string) {
  34642. m.wxid = &s
  34643. }
  34644. // Wxid returns the value of the "wxid" field in the mutation.
  34645. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  34646. v := m.wxid
  34647. if v == nil {
  34648. return
  34649. }
  34650. return *v, true
  34651. }
  34652. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  34653. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34655. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  34656. if !m.op.Is(OpUpdateOne) {
  34657. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  34658. }
  34659. if m.id == nil || m.oldValue == nil {
  34660. return v, errors.New("OldWxid requires an ID field in the mutation")
  34661. }
  34662. oldValue, err := m.oldValue(ctx)
  34663. if err != nil {
  34664. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  34665. }
  34666. return oldValue.Wxid, nil
  34667. }
  34668. // ResetWxid resets all changes to the "wxid" field.
  34669. func (m *WxCardUserMutation) ResetWxid() {
  34670. m.wxid = nil
  34671. }
  34672. // SetAccount sets the "account" field.
  34673. func (m *WxCardUserMutation) SetAccount(s string) {
  34674. m.account = &s
  34675. }
  34676. // Account returns the value of the "account" field in the mutation.
  34677. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  34678. v := m.account
  34679. if v == nil {
  34680. return
  34681. }
  34682. return *v, true
  34683. }
  34684. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  34685. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34687. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  34688. if !m.op.Is(OpUpdateOne) {
  34689. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34690. }
  34691. if m.id == nil || m.oldValue == nil {
  34692. return v, errors.New("OldAccount requires an ID field in the mutation")
  34693. }
  34694. oldValue, err := m.oldValue(ctx)
  34695. if err != nil {
  34696. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34697. }
  34698. return oldValue.Account, nil
  34699. }
  34700. // ResetAccount resets all changes to the "account" field.
  34701. func (m *WxCardUserMutation) ResetAccount() {
  34702. m.account = nil
  34703. }
  34704. // SetAvatar sets the "avatar" field.
  34705. func (m *WxCardUserMutation) SetAvatar(s string) {
  34706. m.avatar = &s
  34707. }
  34708. // Avatar returns the value of the "avatar" field in the mutation.
  34709. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  34710. v := m.avatar
  34711. if v == nil {
  34712. return
  34713. }
  34714. return *v, true
  34715. }
  34716. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  34717. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34719. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  34720. if !m.op.Is(OpUpdateOne) {
  34721. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  34722. }
  34723. if m.id == nil || m.oldValue == nil {
  34724. return v, errors.New("OldAvatar requires an ID field in the mutation")
  34725. }
  34726. oldValue, err := m.oldValue(ctx)
  34727. if err != nil {
  34728. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  34729. }
  34730. return oldValue.Avatar, nil
  34731. }
  34732. // ResetAvatar resets all changes to the "avatar" field.
  34733. func (m *WxCardUserMutation) ResetAvatar() {
  34734. m.avatar = nil
  34735. }
  34736. // SetNickname sets the "nickname" field.
  34737. func (m *WxCardUserMutation) SetNickname(s string) {
  34738. m.nickname = &s
  34739. }
  34740. // Nickname returns the value of the "nickname" field in the mutation.
  34741. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  34742. v := m.nickname
  34743. if v == nil {
  34744. return
  34745. }
  34746. return *v, true
  34747. }
  34748. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  34749. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34751. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  34752. if !m.op.Is(OpUpdateOne) {
  34753. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34754. }
  34755. if m.id == nil || m.oldValue == nil {
  34756. return v, errors.New("OldNickname requires an ID field in the mutation")
  34757. }
  34758. oldValue, err := m.oldValue(ctx)
  34759. if err != nil {
  34760. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34761. }
  34762. return oldValue.Nickname, nil
  34763. }
  34764. // ResetNickname resets all changes to the "nickname" field.
  34765. func (m *WxCardUserMutation) ResetNickname() {
  34766. m.nickname = nil
  34767. }
  34768. // SetRemark sets the "remark" field.
  34769. func (m *WxCardUserMutation) SetRemark(s string) {
  34770. m.remark = &s
  34771. }
  34772. // Remark returns the value of the "remark" field in the mutation.
  34773. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  34774. v := m.remark
  34775. if v == nil {
  34776. return
  34777. }
  34778. return *v, true
  34779. }
  34780. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  34781. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34783. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  34784. if !m.op.Is(OpUpdateOne) {
  34785. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  34786. }
  34787. if m.id == nil || m.oldValue == nil {
  34788. return v, errors.New("OldRemark requires an ID field in the mutation")
  34789. }
  34790. oldValue, err := m.oldValue(ctx)
  34791. if err != nil {
  34792. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  34793. }
  34794. return oldValue.Remark, nil
  34795. }
  34796. // ResetRemark resets all changes to the "remark" field.
  34797. func (m *WxCardUserMutation) ResetRemark() {
  34798. m.remark = nil
  34799. }
  34800. // SetPhone sets the "phone" field.
  34801. func (m *WxCardUserMutation) SetPhone(s string) {
  34802. m.phone = &s
  34803. }
  34804. // Phone returns the value of the "phone" field in the mutation.
  34805. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  34806. v := m.phone
  34807. if v == nil {
  34808. return
  34809. }
  34810. return *v, true
  34811. }
  34812. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  34813. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34815. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  34816. if !m.op.Is(OpUpdateOne) {
  34817. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34818. }
  34819. if m.id == nil || m.oldValue == nil {
  34820. return v, errors.New("OldPhone requires an ID field in the mutation")
  34821. }
  34822. oldValue, err := m.oldValue(ctx)
  34823. if err != nil {
  34824. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34825. }
  34826. return oldValue.Phone, nil
  34827. }
  34828. // ResetPhone resets all changes to the "phone" field.
  34829. func (m *WxCardUserMutation) ResetPhone() {
  34830. m.phone = nil
  34831. }
  34832. // SetOpenID sets the "open_id" field.
  34833. func (m *WxCardUserMutation) SetOpenID(s string) {
  34834. m.open_id = &s
  34835. }
  34836. // OpenID returns the value of the "open_id" field in the mutation.
  34837. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  34838. v := m.open_id
  34839. if v == nil {
  34840. return
  34841. }
  34842. return *v, true
  34843. }
  34844. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  34845. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34847. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  34848. if !m.op.Is(OpUpdateOne) {
  34849. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  34850. }
  34851. if m.id == nil || m.oldValue == nil {
  34852. return v, errors.New("OldOpenID requires an ID field in the mutation")
  34853. }
  34854. oldValue, err := m.oldValue(ctx)
  34855. if err != nil {
  34856. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  34857. }
  34858. return oldValue.OpenID, nil
  34859. }
  34860. // ResetOpenID resets all changes to the "open_id" field.
  34861. func (m *WxCardUserMutation) ResetOpenID() {
  34862. m.open_id = nil
  34863. }
  34864. // SetUnionID sets the "union_id" field.
  34865. func (m *WxCardUserMutation) SetUnionID(s string) {
  34866. m.union_id = &s
  34867. }
  34868. // UnionID returns the value of the "union_id" field in the mutation.
  34869. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  34870. v := m.union_id
  34871. if v == nil {
  34872. return
  34873. }
  34874. return *v, true
  34875. }
  34876. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  34877. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34879. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  34880. if !m.op.Is(OpUpdateOne) {
  34881. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  34882. }
  34883. if m.id == nil || m.oldValue == nil {
  34884. return v, errors.New("OldUnionID requires an ID field in the mutation")
  34885. }
  34886. oldValue, err := m.oldValue(ctx)
  34887. if err != nil {
  34888. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  34889. }
  34890. return oldValue.UnionID, nil
  34891. }
  34892. // ResetUnionID resets all changes to the "union_id" field.
  34893. func (m *WxCardUserMutation) ResetUnionID() {
  34894. m.union_id = nil
  34895. }
  34896. // SetSessionKey sets the "session_key" field.
  34897. func (m *WxCardUserMutation) SetSessionKey(s string) {
  34898. m.session_key = &s
  34899. }
  34900. // SessionKey returns the value of the "session_key" field in the mutation.
  34901. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  34902. v := m.session_key
  34903. if v == nil {
  34904. return
  34905. }
  34906. return *v, true
  34907. }
  34908. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  34909. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34911. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  34912. if !m.op.Is(OpUpdateOne) {
  34913. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  34914. }
  34915. if m.id == nil || m.oldValue == nil {
  34916. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  34917. }
  34918. oldValue, err := m.oldValue(ctx)
  34919. if err != nil {
  34920. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  34921. }
  34922. return oldValue.SessionKey, nil
  34923. }
  34924. // ResetSessionKey resets all changes to the "session_key" field.
  34925. func (m *WxCardUserMutation) ResetSessionKey() {
  34926. m.session_key = nil
  34927. }
  34928. // SetIsVip sets the "is_vip" field.
  34929. func (m *WxCardUserMutation) SetIsVip(i int) {
  34930. m.is_vip = &i
  34931. m.addis_vip = nil
  34932. }
  34933. // IsVip returns the value of the "is_vip" field in the mutation.
  34934. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  34935. v := m.is_vip
  34936. if v == nil {
  34937. return
  34938. }
  34939. return *v, true
  34940. }
  34941. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  34942. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34944. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  34945. if !m.op.Is(OpUpdateOne) {
  34946. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  34947. }
  34948. if m.id == nil || m.oldValue == nil {
  34949. return v, errors.New("OldIsVip requires an ID field in the mutation")
  34950. }
  34951. oldValue, err := m.oldValue(ctx)
  34952. if err != nil {
  34953. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  34954. }
  34955. return oldValue.IsVip, nil
  34956. }
  34957. // AddIsVip adds i to the "is_vip" field.
  34958. func (m *WxCardUserMutation) AddIsVip(i int) {
  34959. if m.addis_vip != nil {
  34960. *m.addis_vip += i
  34961. } else {
  34962. m.addis_vip = &i
  34963. }
  34964. }
  34965. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  34966. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  34967. v := m.addis_vip
  34968. if v == nil {
  34969. return
  34970. }
  34971. return *v, true
  34972. }
  34973. // ResetIsVip resets all changes to the "is_vip" field.
  34974. func (m *WxCardUserMutation) ResetIsVip() {
  34975. m.is_vip = nil
  34976. m.addis_vip = nil
  34977. }
  34978. // Where appends a list predicates to the WxCardUserMutation builder.
  34979. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  34980. m.predicates = append(m.predicates, ps...)
  34981. }
  34982. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  34983. // users can use type-assertion to append predicates that do not depend on any generated package.
  34984. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  34985. p := make([]predicate.WxCardUser, len(ps))
  34986. for i := range ps {
  34987. p[i] = ps[i]
  34988. }
  34989. m.Where(p...)
  34990. }
  34991. // Op returns the operation name.
  34992. func (m *WxCardUserMutation) Op() Op {
  34993. return m.op
  34994. }
  34995. // SetOp allows setting the mutation operation.
  34996. func (m *WxCardUserMutation) SetOp(op Op) {
  34997. m.op = op
  34998. }
  34999. // Type returns the node type of this mutation (WxCardUser).
  35000. func (m *WxCardUserMutation) Type() string {
  35001. return m.typ
  35002. }
  35003. // Fields returns all fields that were changed during this mutation. Note that in
  35004. // order to get all numeric fields that were incremented/decremented, call
  35005. // AddedFields().
  35006. func (m *WxCardUserMutation) Fields() []string {
  35007. fields := make([]string, 0, 13)
  35008. if m.created_at != nil {
  35009. fields = append(fields, wxcarduser.FieldCreatedAt)
  35010. }
  35011. if m.updated_at != nil {
  35012. fields = append(fields, wxcarduser.FieldUpdatedAt)
  35013. }
  35014. if m.deleted_at != nil {
  35015. fields = append(fields, wxcarduser.FieldDeletedAt)
  35016. }
  35017. if m.wxid != nil {
  35018. fields = append(fields, wxcarduser.FieldWxid)
  35019. }
  35020. if m.account != nil {
  35021. fields = append(fields, wxcarduser.FieldAccount)
  35022. }
  35023. if m.avatar != nil {
  35024. fields = append(fields, wxcarduser.FieldAvatar)
  35025. }
  35026. if m.nickname != nil {
  35027. fields = append(fields, wxcarduser.FieldNickname)
  35028. }
  35029. if m.remark != nil {
  35030. fields = append(fields, wxcarduser.FieldRemark)
  35031. }
  35032. if m.phone != nil {
  35033. fields = append(fields, wxcarduser.FieldPhone)
  35034. }
  35035. if m.open_id != nil {
  35036. fields = append(fields, wxcarduser.FieldOpenID)
  35037. }
  35038. if m.union_id != nil {
  35039. fields = append(fields, wxcarduser.FieldUnionID)
  35040. }
  35041. if m.session_key != nil {
  35042. fields = append(fields, wxcarduser.FieldSessionKey)
  35043. }
  35044. if m.is_vip != nil {
  35045. fields = append(fields, wxcarduser.FieldIsVip)
  35046. }
  35047. return fields
  35048. }
  35049. // Field returns the value of a field with the given name. The second boolean
  35050. // return value indicates that this field was not set, or was not defined in the
  35051. // schema.
  35052. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  35053. switch name {
  35054. case wxcarduser.FieldCreatedAt:
  35055. return m.CreatedAt()
  35056. case wxcarduser.FieldUpdatedAt:
  35057. return m.UpdatedAt()
  35058. case wxcarduser.FieldDeletedAt:
  35059. return m.DeletedAt()
  35060. case wxcarduser.FieldWxid:
  35061. return m.Wxid()
  35062. case wxcarduser.FieldAccount:
  35063. return m.Account()
  35064. case wxcarduser.FieldAvatar:
  35065. return m.Avatar()
  35066. case wxcarduser.FieldNickname:
  35067. return m.Nickname()
  35068. case wxcarduser.FieldRemark:
  35069. return m.Remark()
  35070. case wxcarduser.FieldPhone:
  35071. return m.Phone()
  35072. case wxcarduser.FieldOpenID:
  35073. return m.OpenID()
  35074. case wxcarduser.FieldUnionID:
  35075. return m.UnionID()
  35076. case wxcarduser.FieldSessionKey:
  35077. return m.SessionKey()
  35078. case wxcarduser.FieldIsVip:
  35079. return m.IsVip()
  35080. }
  35081. return nil, false
  35082. }
  35083. // OldField returns the old value of the field from the database. An error is
  35084. // returned if the mutation operation is not UpdateOne, or the query to the
  35085. // database failed.
  35086. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35087. switch name {
  35088. case wxcarduser.FieldCreatedAt:
  35089. return m.OldCreatedAt(ctx)
  35090. case wxcarduser.FieldUpdatedAt:
  35091. return m.OldUpdatedAt(ctx)
  35092. case wxcarduser.FieldDeletedAt:
  35093. return m.OldDeletedAt(ctx)
  35094. case wxcarduser.FieldWxid:
  35095. return m.OldWxid(ctx)
  35096. case wxcarduser.FieldAccount:
  35097. return m.OldAccount(ctx)
  35098. case wxcarduser.FieldAvatar:
  35099. return m.OldAvatar(ctx)
  35100. case wxcarduser.FieldNickname:
  35101. return m.OldNickname(ctx)
  35102. case wxcarduser.FieldRemark:
  35103. return m.OldRemark(ctx)
  35104. case wxcarduser.FieldPhone:
  35105. return m.OldPhone(ctx)
  35106. case wxcarduser.FieldOpenID:
  35107. return m.OldOpenID(ctx)
  35108. case wxcarduser.FieldUnionID:
  35109. return m.OldUnionID(ctx)
  35110. case wxcarduser.FieldSessionKey:
  35111. return m.OldSessionKey(ctx)
  35112. case wxcarduser.FieldIsVip:
  35113. return m.OldIsVip(ctx)
  35114. }
  35115. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  35116. }
  35117. // SetField sets the value of a field with the given name. It returns an error if
  35118. // the field is not defined in the schema, or if the type mismatched the field
  35119. // type.
  35120. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  35121. switch name {
  35122. case wxcarduser.FieldCreatedAt:
  35123. v, ok := value.(time.Time)
  35124. if !ok {
  35125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35126. }
  35127. m.SetCreatedAt(v)
  35128. return nil
  35129. case wxcarduser.FieldUpdatedAt:
  35130. v, ok := value.(time.Time)
  35131. if !ok {
  35132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35133. }
  35134. m.SetUpdatedAt(v)
  35135. return nil
  35136. case wxcarduser.FieldDeletedAt:
  35137. v, ok := value.(time.Time)
  35138. if !ok {
  35139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35140. }
  35141. m.SetDeletedAt(v)
  35142. return nil
  35143. case wxcarduser.FieldWxid:
  35144. v, ok := value.(string)
  35145. if !ok {
  35146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35147. }
  35148. m.SetWxid(v)
  35149. return nil
  35150. case wxcarduser.FieldAccount:
  35151. v, ok := value.(string)
  35152. if !ok {
  35153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35154. }
  35155. m.SetAccount(v)
  35156. return nil
  35157. case wxcarduser.FieldAvatar:
  35158. v, ok := value.(string)
  35159. if !ok {
  35160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35161. }
  35162. m.SetAvatar(v)
  35163. return nil
  35164. case wxcarduser.FieldNickname:
  35165. v, ok := value.(string)
  35166. if !ok {
  35167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35168. }
  35169. m.SetNickname(v)
  35170. return nil
  35171. case wxcarduser.FieldRemark:
  35172. v, ok := value.(string)
  35173. if !ok {
  35174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35175. }
  35176. m.SetRemark(v)
  35177. return nil
  35178. case wxcarduser.FieldPhone:
  35179. v, ok := value.(string)
  35180. if !ok {
  35181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35182. }
  35183. m.SetPhone(v)
  35184. return nil
  35185. case wxcarduser.FieldOpenID:
  35186. v, ok := value.(string)
  35187. if !ok {
  35188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35189. }
  35190. m.SetOpenID(v)
  35191. return nil
  35192. case wxcarduser.FieldUnionID:
  35193. v, ok := value.(string)
  35194. if !ok {
  35195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35196. }
  35197. m.SetUnionID(v)
  35198. return nil
  35199. case wxcarduser.FieldSessionKey:
  35200. v, ok := value.(string)
  35201. if !ok {
  35202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35203. }
  35204. m.SetSessionKey(v)
  35205. return nil
  35206. case wxcarduser.FieldIsVip:
  35207. v, ok := value.(int)
  35208. if !ok {
  35209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35210. }
  35211. m.SetIsVip(v)
  35212. return nil
  35213. }
  35214. return fmt.Errorf("unknown WxCardUser field %s", name)
  35215. }
  35216. // AddedFields returns all numeric fields that were incremented/decremented during
  35217. // this mutation.
  35218. func (m *WxCardUserMutation) AddedFields() []string {
  35219. var fields []string
  35220. if m.addis_vip != nil {
  35221. fields = append(fields, wxcarduser.FieldIsVip)
  35222. }
  35223. return fields
  35224. }
  35225. // AddedField returns the numeric value that was incremented/decremented on a field
  35226. // with the given name. The second boolean return value indicates that this field
  35227. // was not set, or was not defined in the schema.
  35228. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  35229. switch name {
  35230. case wxcarduser.FieldIsVip:
  35231. return m.AddedIsVip()
  35232. }
  35233. return nil, false
  35234. }
  35235. // AddField adds the value to the field with the given name. It returns an error if
  35236. // the field is not defined in the schema, or if the type mismatched the field
  35237. // type.
  35238. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  35239. switch name {
  35240. case wxcarduser.FieldIsVip:
  35241. v, ok := value.(int)
  35242. if !ok {
  35243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35244. }
  35245. m.AddIsVip(v)
  35246. return nil
  35247. }
  35248. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  35249. }
  35250. // ClearedFields returns all nullable fields that were cleared during this
  35251. // mutation.
  35252. func (m *WxCardUserMutation) ClearedFields() []string {
  35253. var fields []string
  35254. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  35255. fields = append(fields, wxcarduser.FieldDeletedAt)
  35256. }
  35257. return fields
  35258. }
  35259. // FieldCleared returns a boolean indicating if a field with the given name was
  35260. // cleared in this mutation.
  35261. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  35262. _, ok := m.clearedFields[name]
  35263. return ok
  35264. }
  35265. // ClearField clears the value of the field with the given name. It returns an
  35266. // error if the field is not defined in the schema.
  35267. func (m *WxCardUserMutation) ClearField(name string) error {
  35268. switch name {
  35269. case wxcarduser.FieldDeletedAt:
  35270. m.ClearDeletedAt()
  35271. return nil
  35272. }
  35273. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  35274. }
  35275. // ResetField resets all changes in the mutation for the field with the given name.
  35276. // It returns an error if the field is not defined in the schema.
  35277. func (m *WxCardUserMutation) ResetField(name string) error {
  35278. switch name {
  35279. case wxcarduser.FieldCreatedAt:
  35280. m.ResetCreatedAt()
  35281. return nil
  35282. case wxcarduser.FieldUpdatedAt:
  35283. m.ResetUpdatedAt()
  35284. return nil
  35285. case wxcarduser.FieldDeletedAt:
  35286. m.ResetDeletedAt()
  35287. return nil
  35288. case wxcarduser.FieldWxid:
  35289. m.ResetWxid()
  35290. return nil
  35291. case wxcarduser.FieldAccount:
  35292. m.ResetAccount()
  35293. return nil
  35294. case wxcarduser.FieldAvatar:
  35295. m.ResetAvatar()
  35296. return nil
  35297. case wxcarduser.FieldNickname:
  35298. m.ResetNickname()
  35299. return nil
  35300. case wxcarduser.FieldRemark:
  35301. m.ResetRemark()
  35302. return nil
  35303. case wxcarduser.FieldPhone:
  35304. m.ResetPhone()
  35305. return nil
  35306. case wxcarduser.FieldOpenID:
  35307. m.ResetOpenID()
  35308. return nil
  35309. case wxcarduser.FieldUnionID:
  35310. m.ResetUnionID()
  35311. return nil
  35312. case wxcarduser.FieldSessionKey:
  35313. m.ResetSessionKey()
  35314. return nil
  35315. case wxcarduser.FieldIsVip:
  35316. m.ResetIsVip()
  35317. return nil
  35318. }
  35319. return fmt.Errorf("unknown WxCardUser field %s", name)
  35320. }
  35321. // AddedEdges returns all edge names that were set/added in this mutation.
  35322. func (m *WxCardUserMutation) AddedEdges() []string {
  35323. edges := make([]string, 0, 0)
  35324. return edges
  35325. }
  35326. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35327. // name in this mutation.
  35328. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  35329. return nil
  35330. }
  35331. // RemovedEdges returns all edge names that were removed in this mutation.
  35332. func (m *WxCardUserMutation) RemovedEdges() []string {
  35333. edges := make([]string, 0, 0)
  35334. return edges
  35335. }
  35336. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35337. // the given name in this mutation.
  35338. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  35339. return nil
  35340. }
  35341. // ClearedEdges returns all edge names that were cleared in this mutation.
  35342. func (m *WxCardUserMutation) ClearedEdges() []string {
  35343. edges := make([]string, 0, 0)
  35344. return edges
  35345. }
  35346. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35347. // was cleared in this mutation.
  35348. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  35349. return false
  35350. }
  35351. // ClearEdge clears the value of the edge with the given name. It returns an error
  35352. // if that edge is not defined in the schema.
  35353. func (m *WxCardUserMutation) ClearEdge(name string) error {
  35354. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  35355. }
  35356. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35357. // It returns an error if the edge is not defined in the schema.
  35358. func (m *WxCardUserMutation) ResetEdge(name string) error {
  35359. return fmt.Errorf("unknown WxCardUser edge %s", name)
  35360. }
  35361. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  35362. type WxCardVisitMutation struct {
  35363. config
  35364. op Op
  35365. typ string
  35366. id *uint64
  35367. created_at *time.Time
  35368. updated_at *time.Time
  35369. deleted_at *time.Time
  35370. user_id *uint64
  35371. adduser_id *int64
  35372. bot_id *uint64
  35373. addbot_id *int64
  35374. bot_type *uint8
  35375. addbot_type *int8
  35376. clearedFields map[string]struct{}
  35377. done bool
  35378. oldValue func(context.Context) (*WxCardVisit, error)
  35379. predicates []predicate.WxCardVisit
  35380. }
  35381. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  35382. // wxcardvisitOption allows management of the mutation configuration using functional options.
  35383. type wxcardvisitOption func(*WxCardVisitMutation)
  35384. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  35385. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  35386. m := &WxCardVisitMutation{
  35387. config: c,
  35388. op: op,
  35389. typ: TypeWxCardVisit,
  35390. clearedFields: make(map[string]struct{}),
  35391. }
  35392. for _, opt := range opts {
  35393. opt(m)
  35394. }
  35395. return m
  35396. }
  35397. // withWxCardVisitID sets the ID field of the mutation.
  35398. func withWxCardVisitID(id uint64) wxcardvisitOption {
  35399. return func(m *WxCardVisitMutation) {
  35400. var (
  35401. err error
  35402. once sync.Once
  35403. value *WxCardVisit
  35404. )
  35405. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  35406. once.Do(func() {
  35407. if m.done {
  35408. err = errors.New("querying old values post mutation is not allowed")
  35409. } else {
  35410. value, err = m.Client().WxCardVisit.Get(ctx, id)
  35411. }
  35412. })
  35413. return value, err
  35414. }
  35415. m.id = &id
  35416. }
  35417. }
  35418. // withWxCardVisit sets the old WxCardVisit of the mutation.
  35419. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  35420. return func(m *WxCardVisitMutation) {
  35421. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  35422. return node, nil
  35423. }
  35424. m.id = &node.ID
  35425. }
  35426. }
  35427. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35428. // executed in a transaction (ent.Tx), a transactional client is returned.
  35429. func (m WxCardVisitMutation) Client() *Client {
  35430. client := &Client{config: m.config}
  35431. client.init()
  35432. return client
  35433. }
  35434. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35435. // it returns an error otherwise.
  35436. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  35437. if _, ok := m.driver.(*txDriver); !ok {
  35438. return nil, errors.New("ent: mutation is not running in a transaction")
  35439. }
  35440. tx := &Tx{config: m.config}
  35441. tx.init()
  35442. return tx, nil
  35443. }
  35444. // SetID sets the value of the id field. Note that this
  35445. // operation is only accepted on creation of WxCardVisit entities.
  35446. func (m *WxCardVisitMutation) SetID(id uint64) {
  35447. m.id = &id
  35448. }
  35449. // ID returns the ID value in the mutation. Note that the ID is only available
  35450. // if it was provided to the builder or after it was returned from the database.
  35451. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  35452. if m.id == nil {
  35453. return
  35454. }
  35455. return *m.id, true
  35456. }
  35457. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35458. // That means, if the mutation is applied within a transaction with an isolation level such
  35459. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35460. // or updated by the mutation.
  35461. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  35462. switch {
  35463. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35464. id, exists := m.ID()
  35465. if exists {
  35466. return []uint64{id}, nil
  35467. }
  35468. fallthrough
  35469. case m.op.Is(OpUpdate | OpDelete):
  35470. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  35471. default:
  35472. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35473. }
  35474. }
  35475. // SetCreatedAt sets the "created_at" field.
  35476. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  35477. m.created_at = &t
  35478. }
  35479. // CreatedAt returns the value of the "created_at" field in the mutation.
  35480. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  35481. v := m.created_at
  35482. if v == nil {
  35483. return
  35484. }
  35485. return *v, true
  35486. }
  35487. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  35488. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35490. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35491. if !m.op.Is(OpUpdateOne) {
  35492. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35493. }
  35494. if m.id == nil || m.oldValue == nil {
  35495. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35496. }
  35497. oldValue, err := m.oldValue(ctx)
  35498. if err != nil {
  35499. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35500. }
  35501. return oldValue.CreatedAt, nil
  35502. }
  35503. // ResetCreatedAt resets all changes to the "created_at" field.
  35504. func (m *WxCardVisitMutation) ResetCreatedAt() {
  35505. m.created_at = nil
  35506. }
  35507. // SetUpdatedAt sets the "updated_at" field.
  35508. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  35509. m.updated_at = &t
  35510. }
  35511. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35512. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  35513. v := m.updated_at
  35514. if v == nil {
  35515. return
  35516. }
  35517. return *v, true
  35518. }
  35519. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  35520. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35522. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35523. if !m.op.Is(OpUpdateOne) {
  35524. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35525. }
  35526. if m.id == nil || m.oldValue == nil {
  35527. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35528. }
  35529. oldValue, err := m.oldValue(ctx)
  35530. if err != nil {
  35531. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35532. }
  35533. return oldValue.UpdatedAt, nil
  35534. }
  35535. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35536. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  35537. m.updated_at = nil
  35538. }
  35539. // SetDeletedAt sets the "deleted_at" field.
  35540. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  35541. m.deleted_at = &t
  35542. }
  35543. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35544. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  35545. v := m.deleted_at
  35546. if v == nil {
  35547. return
  35548. }
  35549. return *v, true
  35550. }
  35551. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  35552. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35554. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35555. if !m.op.Is(OpUpdateOne) {
  35556. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35557. }
  35558. if m.id == nil || m.oldValue == nil {
  35559. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35560. }
  35561. oldValue, err := m.oldValue(ctx)
  35562. if err != nil {
  35563. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35564. }
  35565. return oldValue.DeletedAt, nil
  35566. }
  35567. // ClearDeletedAt clears the value of the "deleted_at" field.
  35568. func (m *WxCardVisitMutation) ClearDeletedAt() {
  35569. m.deleted_at = nil
  35570. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  35571. }
  35572. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35573. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  35574. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  35575. return ok
  35576. }
  35577. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35578. func (m *WxCardVisitMutation) ResetDeletedAt() {
  35579. m.deleted_at = nil
  35580. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  35581. }
  35582. // SetUserID sets the "user_id" field.
  35583. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  35584. m.user_id = &u
  35585. m.adduser_id = nil
  35586. }
  35587. // UserID returns the value of the "user_id" field in the mutation.
  35588. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  35589. v := m.user_id
  35590. if v == nil {
  35591. return
  35592. }
  35593. return *v, true
  35594. }
  35595. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  35596. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35598. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  35599. if !m.op.Is(OpUpdateOne) {
  35600. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  35601. }
  35602. if m.id == nil || m.oldValue == nil {
  35603. return v, errors.New("OldUserID requires an ID field in the mutation")
  35604. }
  35605. oldValue, err := m.oldValue(ctx)
  35606. if err != nil {
  35607. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  35608. }
  35609. return oldValue.UserID, nil
  35610. }
  35611. // AddUserID adds u to the "user_id" field.
  35612. func (m *WxCardVisitMutation) AddUserID(u int64) {
  35613. if m.adduser_id != nil {
  35614. *m.adduser_id += u
  35615. } else {
  35616. m.adduser_id = &u
  35617. }
  35618. }
  35619. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  35620. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  35621. v := m.adduser_id
  35622. if v == nil {
  35623. return
  35624. }
  35625. return *v, true
  35626. }
  35627. // ClearUserID clears the value of the "user_id" field.
  35628. func (m *WxCardVisitMutation) ClearUserID() {
  35629. m.user_id = nil
  35630. m.adduser_id = nil
  35631. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  35632. }
  35633. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  35634. func (m *WxCardVisitMutation) UserIDCleared() bool {
  35635. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  35636. return ok
  35637. }
  35638. // ResetUserID resets all changes to the "user_id" field.
  35639. func (m *WxCardVisitMutation) ResetUserID() {
  35640. m.user_id = nil
  35641. m.adduser_id = nil
  35642. delete(m.clearedFields, wxcardvisit.FieldUserID)
  35643. }
  35644. // SetBotID sets the "bot_id" field.
  35645. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  35646. m.bot_id = &u
  35647. m.addbot_id = nil
  35648. }
  35649. // BotID returns the value of the "bot_id" field in the mutation.
  35650. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  35651. v := m.bot_id
  35652. if v == nil {
  35653. return
  35654. }
  35655. return *v, true
  35656. }
  35657. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  35658. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35660. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  35661. if !m.op.Is(OpUpdateOne) {
  35662. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35663. }
  35664. if m.id == nil || m.oldValue == nil {
  35665. return v, errors.New("OldBotID requires an ID field in the mutation")
  35666. }
  35667. oldValue, err := m.oldValue(ctx)
  35668. if err != nil {
  35669. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35670. }
  35671. return oldValue.BotID, nil
  35672. }
  35673. // AddBotID adds u to the "bot_id" field.
  35674. func (m *WxCardVisitMutation) AddBotID(u int64) {
  35675. if m.addbot_id != nil {
  35676. *m.addbot_id += u
  35677. } else {
  35678. m.addbot_id = &u
  35679. }
  35680. }
  35681. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  35682. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  35683. v := m.addbot_id
  35684. if v == nil {
  35685. return
  35686. }
  35687. return *v, true
  35688. }
  35689. // ResetBotID resets all changes to the "bot_id" field.
  35690. func (m *WxCardVisitMutation) ResetBotID() {
  35691. m.bot_id = nil
  35692. m.addbot_id = nil
  35693. }
  35694. // SetBotType sets the "bot_type" field.
  35695. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  35696. m.bot_type = &u
  35697. m.addbot_type = nil
  35698. }
  35699. // BotType returns the value of the "bot_type" field in the mutation.
  35700. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  35701. v := m.bot_type
  35702. if v == nil {
  35703. return
  35704. }
  35705. return *v, true
  35706. }
  35707. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  35708. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35710. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  35711. if !m.op.Is(OpUpdateOne) {
  35712. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  35713. }
  35714. if m.id == nil || m.oldValue == nil {
  35715. return v, errors.New("OldBotType requires an ID field in the mutation")
  35716. }
  35717. oldValue, err := m.oldValue(ctx)
  35718. if err != nil {
  35719. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  35720. }
  35721. return oldValue.BotType, nil
  35722. }
  35723. // AddBotType adds u to the "bot_type" field.
  35724. func (m *WxCardVisitMutation) AddBotType(u int8) {
  35725. if m.addbot_type != nil {
  35726. *m.addbot_type += u
  35727. } else {
  35728. m.addbot_type = &u
  35729. }
  35730. }
  35731. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  35732. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  35733. v := m.addbot_type
  35734. if v == nil {
  35735. return
  35736. }
  35737. return *v, true
  35738. }
  35739. // ResetBotType resets all changes to the "bot_type" field.
  35740. func (m *WxCardVisitMutation) ResetBotType() {
  35741. m.bot_type = nil
  35742. m.addbot_type = nil
  35743. }
  35744. // Where appends a list predicates to the WxCardVisitMutation builder.
  35745. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  35746. m.predicates = append(m.predicates, ps...)
  35747. }
  35748. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  35749. // users can use type-assertion to append predicates that do not depend on any generated package.
  35750. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  35751. p := make([]predicate.WxCardVisit, len(ps))
  35752. for i := range ps {
  35753. p[i] = ps[i]
  35754. }
  35755. m.Where(p...)
  35756. }
  35757. // Op returns the operation name.
  35758. func (m *WxCardVisitMutation) Op() Op {
  35759. return m.op
  35760. }
  35761. // SetOp allows setting the mutation operation.
  35762. func (m *WxCardVisitMutation) SetOp(op Op) {
  35763. m.op = op
  35764. }
  35765. // Type returns the node type of this mutation (WxCardVisit).
  35766. func (m *WxCardVisitMutation) Type() string {
  35767. return m.typ
  35768. }
  35769. // Fields returns all fields that were changed during this mutation. Note that in
  35770. // order to get all numeric fields that were incremented/decremented, call
  35771. // AddedFields().
  35772. func (m *WxCardVisitMutation) Fields() []string {
  35773. fields := make([]string, 0, 6)
  35774. if m.created_at != nil {
  35775. fields = append(fields, wxcardvisit.FieldCreatedAt)
  35776. }
  35777. if m.updated_at != nil {
  35778. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  35779. }
  35780. if m.deleted_at != nil {
  35781. fields = append(fields, wxcardvisit.FieldDeletedAt)
  35782. }
  35783. if m.user_id != nil {
  35784. fields = append(fields, wxcardvisit.FieldUserID)
  35785. }
  35786. if m.bot_id != nil {
  35787. fields = append(fields, wxcardvisit.FieldBotID)
  35788. }
  35789. if m.bot_type != nil {
  35790. fields = append(fields, wxcardvisit.FieldBotType)
  35791. }
  35792. return fields
  35793. }
  35794. // Field returns the value of a field with the given name. The second boolean
  35795. // return value indicates that this field was not set, or was not defined in the
  35796. // schema.
  35797. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  35798. switch name {
  35799. case wxcardvisit.FieldCreatedAt:
  35800. return m.CreatedAt()
  35801. case wxcardvisit.FieldUpdatedAt:
  35802. return m.UpdatedAt()
  35803. case wxcardvisit.FieldDeletedAt:
  35804. return m.DeletedAt()
  35805. case wxcardvisit.FieldUserID:
  35806. return m.UserID()
  35807. case wxcardvisit.FieldBotID:
  35808. return m.BotID()
  35809. case wxcardvisit.FieldBotType:
  35810. return m.BotType()
  35811. }
  35812. return nil, false
  35813. }
  35814. // OldField returns the old value of the field from the database. An error is
  35815. // returned if the mutation operation is not UpdateOne, or the query to the
  35816. // database failed.
  35817. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35818. switch name {
  35819. case wxcardvisit.FieldCreatedAt:
  35820. return m.OldCreatedAt(ctx)
  35821. case wxcardvisit.FieldUpdatedAt:
  35822. return m.OldUpdatedAt(ctx)
  35823. case wxcardvisit.FieldDeletedAt:
  35824. return m.OldDeletedAt(ctx)
  35825. case wxcardvisit.FieldUserID:
  35826. return m.OldUserID(ctx)
  35827. case wxcardvisit.FieldBotID:
  35828. return m.OldBotID(ctx)
  35829. case wxcardvisit.FieldBotType:
  35830. return m.OldBotType(ctx)
  35831. }
  35832. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  35833. }
  35834. // SetField sets the value of a field with the given name. It returns an error if
  35835. // the field is not defined in the schema, or if the type mismatched the field
  35836. // type.
  35837. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  35838. switch name {
  35839. case wxcardvisit.FieldCreatedAt:
  35840. v, ok := value.(time.Time)
  35841. if !ok {
  35842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35843. }
  35844. m.SetCreatedAt(v)
  35845. return nil
  35846. case wxcardvisit.FieldUpdatedAt:
  35847. v, ok := value.(time.Time)
  35848. if !ok {
  35849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35850. }
  35851. m.SetUpdatedAt(v)
  35852. return nil
  35853. case wxcardvisit.FieldDeletedAt:
  35854. v, ok := value.(time.Time)
  35855. if !ok {
  35856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35857. }
  35858. m.SetDeletedAt(v)
  35859. return nil
  35860. case wxcardvisit.FieldUserID:
  35861. v, ok := value.(uint64)
  35862. if !ok {
  35863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35864. }
  35865. m.SetUserID(v)
  35866. return nil
  35867. case wxcardvisit.FieldBotID:
  35868. v, ok := value.(uint64)
  35869. if !ok {
  35870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35871. }
  35872. m.SetBotID(v)
  35873. return nil
  35874. case wxcardvisit.FieldBotType:
  35875. v, ok := value.(uint8)
  35876. if !ok {
  35877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35878. }
  35879. m.SetBotType(v)
  35880. return nil
  35881. }
  35882. return fmt.Errorf("unknown WxCardVisit field %s", name)
  35883. }
  35884. // AddedFields returns all numeric fields that were incremented/decremented during
  35885. // this mutation.
  35886. func (m *WxCardVisitMutation) AddedFields() []string {
  35887. var fields []string
  35888. if m.adduser_id != nil {
  35889. fields = append(fields, wxcardvisit.FieldUserID)
  35890. }
  35891. if m.addbot_id != nil {
  35892. fields = append(fields, wxcardvisit.FieldBotID)
  35893. }
  35894. if m.addbot_type != nil {
  35895. fields = append(fields, wxcardvisit.FieldBotType)
  35896. }
  35897. return fields
  35898. }
  35899. // AddedField returns the numeric value that was incremented/decremented on a field
  35900. // with the given name. The second boolean return value indicates that this field
  35901. // was not set, or was not defined in the schema.
  35902. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  35903. switch name {
  35904. case wxcardvisit.FieldUserID:
  35905. return m.AddedUserID()
  35906. case wxcardvisit.FieldBotID:
  35907. return m.AddedBotID()
  35908. case wxcardvisit.FieldBotType:
  35909. return m.AddedBotType()
  35910. }
  35911. return nil, false
  35912. }
  35913. // AddField adds the value to the field with the given name. It returns an error if
  35914. // the field is not defined in the schema, or if the type mismatched the field
  35915. // type.
  35916. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  35917. switch name {
  35918. case wxcardvisit.FieldUserID:
  35919. v, ok := value.(int64)
  35920. if !ok {
  35921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35922. }
  35923. m.AddUserID(v)
  35924. return nil
  35925. case wxcardvisit.FieldBotID:
  35926. v, ok := value.(int64)
  35927. if !ok {
  35928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35929. }
  35930. m.AddBotID(v)
  35931. return nil
  35932. case wxcardvisit.FieldBotType:
  35933. v, ok := value.(int8)
  35934. if !ok {
  35935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35936. }
  35937. m.AddBotType(v)
  35938. return nil
  35939. }
  35940. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  35941. }
  35942. // ClearedFields returns all nullable fields that were cleared during this
  35943. // mutation.
  35944. func (m *WxCardVisitMutation) ClearedFields() []string {
  35945. var fields []string
  35946. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  35947. fields = append(fields, wxcardvisit.FieldDeletedAt)
  35948. }
  35949. if m.FieldCleared(wxcardvisit.FieldUserID) {
  35950. fields = append(fields, wxcardvisit.FieldUserID)
  35951. }
  35952. return fields
  35953. }
  35954. // FieldCleared returns a boolean indicating if a field with the given name was
  35955. // cleared in this mutation.
  35956. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  35957. _, ok := m.clearedFields[name]
  35958. return ok
  35959. }
  35960. // ClearField clears the value of the field with the given name. It returns an
  35961. // error if the field is not defined in the schema.
  35962. func (m *WxCardVisitMutation) ClearField(name string) error {
  35963. switch name {
  35964. case wxcardvisit.FieldDeletedAt:
  35965. m.ClearDeletedAt()
  35966. return nil
  35967. case wxcardvisit.FieldUserID:
  35968. m.ClearUserID()
  35969. return nil
  35970. }
  35971. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  35972. }
  35973. // ResetField resets all changes in the mutation for the field with the given name.
  35974. // It returns an error if the field is not defined in the schema.
  35975. func (m *WxCardVisitMutation) ResetField(name string) error {
  35976. switch name {
  35977. case wxcardvisit.FieldCreatedAt:
  35978. m.ResetCreatedAt()
  35979. return nil
  35980. case wxcardvisit.FieldUpdatedAt:
  35981. m.ResetUpdatedAt()
  35982. return nil
  35983. case wxcardvisit.FieldDeletedAt:
  35984. m.ResetDeletedAt()
  35985. return nil
  35986. case wxcardvisit.FieldUserID:
  35987. m.ResetUserID()
  35988. return nil
  35989. case wxcardvisit.FieldBotID:
  35990. m.ResetBotID()
  35991. return nil
  35992. case wxcardvisit.FieldBotType:
  35993. m.ResetBotType()
  35994. return nil
  35995. }
  35996. return fmt.Errorf("unknown WxCardVisit field %s", name)
  35997. }
  35998. // AddedEdges returns all edge names that were set/added in this mutation.
  35999. func (m *WxCardVisitMutation) AddedEdges() []string {
  36000. edges := make([]string, 0, 0)
  36001. return edges
  36002. }
  36003. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36004. // name in this mutation.
  36005. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  36006. return nil
  36007. }
  36008. // RemovedEdges returns all edge names that were removed in this mutation.
  36009. func (m *WxCardVisitMutation) RemovedEdges() []string {
  36010. edges := make([]string, 0, 0)
  36011. return edges
  36012. }
  36013. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36014. // the given name in this mutation.
  36015. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  36016. return nil
  36017. }
  36018. // ClearedEdges returns all edge names that were cleared in this mutation.
  36019. func (m *WxCardVisitMutation) ClearedEdges() []string {
  36020. edges := make([]string, 0, 0)
  36021. return edges
  36022. }
  36023. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36024. // was cleared in this mutation.
  36025. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  36026. return false
  36027. }
  36028. // ClearEdge clears the value of the edge with the given name. It returns an error
  36029. // if that edge is not defined in the schema.
  36030. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  36031. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  36032. }
  36033. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36034. // It returns an error if the edge is not defined in the schema.
  36035. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  36036. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  36037. }