mutation.go 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548
  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. deleted_at *time.Time
  11963. organization_id *uint64
  11964. addorganization_id *int64
  11965. clearedFields map[string]struct{}
  11966. contacts *uint64
  11967. clearedcontacts bool
  11968. labels *uint64
  11969. clearedlabels bool
  11970. done bool
  11971. oldValue func(context.Context) (*LabelRelationship, error)
  11972. predicates []predicate.LabelRelationship
  11973. }
  11974. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  11975. // labelrelationshipOption allows management of the mutation configuration using functional options.
  11976. type labelrelationshipOption func(*LabelRelationshipMutation)
  11977. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  11978. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  11979. m := &LabelRelationshipMutation{
  11980. config: c,
  11981. op: op,
  11982. typ: TypeLabelRelationship,
  11983. clearedFields: make(map[string]struct{}),
  11984. }
  11985. for _, opt := range opts {
  11986. opt(m)
  11987. }
  11988. return m
  11989. }
  11990. // withLabelRelationshipID sets the ID field of the mutation.
  11991. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  11992. return func(m *LabelRelationshipMutation) {
  11993. var (
  11994. err error
  11995. once sync.Once
  11996. value *LabelRelationship
  11997. )
  11998. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  11999. once.Do(func() {
  12000. if m.done {
  12001. err = errors.New("querying old values post mutation is not allowed")
  12002. } else {
  12003. value, err = m.Client().LabelRelationship.Get(ctx, id)
  12004. }
  12005. })
  12006. return value, err
  12007. }
  12008. m.id = &id
  12009. }
  12010. }
  12011. // withLabelRelationship sets the old LabelRelationship of the mutation.
  12012. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  12013. return func(m *LabelRelationshipMutation) {
  12014. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12015. return node, nil
  12016. }
  12017. m.id = &node.ID
  12018. }
  12019. }
  12020. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12021. // executed in a transaction (ent.Tx), a transactional client is returned.
  12022. func (m LabelRelationshipMutation) Client() *Client {
  12023. client := &Client{config: m.config}
  12024. client.init()
  12025. return client
  12026. }
  12027. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12028. // it returns an error otherwise.
  12029. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12030. if _, ok := m.driver.(*txDriver); !ok {
  12031. return nil, errors.New("ent: mutation is not running in a transaction")
  12032. }
  12033. tx := &Tx{config: m.config}
  12034. tx.init()
  12035. return tx, nil
  12036. }
  12037. // SetID sets the value of the id field. Note that this
  12038. // operation is only accepted on creation of LabelRelationship entities.
  12039. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12040. m.id = &id
  12041. }
  12042. // ID returns the ID value in the mutation. Note that the ID is only available
  12043. // if it was provided to the builder or after it was returned from the database.
  12044. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12045. if m.id == nil {
  12046. return
  12047. }
  12048. return *m.id, true
  12049. }
  12050. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12051. // That means, if the mutation is applied within a transaction with an isolation level such
  12052. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12053. // or updated by the mutation.
  12054. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12055. switch {
  12056. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12057. id, exists := m.ID()
  12058. if exists {
  12059. return []uint64{id}, nil
  12060. }
  12061. fallthrough
  12062. case m.op.Is(OpUpdate | OpDelete):
  12063. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12064. default:
  12065. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12066. }
  12067. }
  12068. // SetCreatedAt sets the "created_at" field.
  12069. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12070. m.created_at = &t
  12071. }
  12072. // CreatedAt returns the value of the "created_at" field in the mutation.
  12073. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12074. v := m.created_at
  12075. if v == nil {
  12076. return
  12077. }
  12078. return *v, true
  12079. }
  12080. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12081. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12083. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12084. if !m.op.Is(OpUpdateOne) {
  12085. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12086. }
  12087. if m.id == nil || m.oldValue == nil {
  12088. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12089. }
  12090. oldValue, err := m.oldValue(ctx)
  12091. if err != nil {
  12092. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12093. }
  12094. return oldValue.CreatedAt, nil
  12095. }
  12096. // ResetCreatedAt resets all changes to the "created_at" field.
  12097. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12098. m.created_at = nil
  12099. }
  12100. // SetUpdatedAt sets the "updated_at" field.
  12101. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12102. m.updated_at = &t
  12103. }
  12104. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12105. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12106. v := m.updated_at
  12107. if v == nil {
  12108. return
  12109. }
  12110. return *v, true
  12111. }
  12112. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12113. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12115. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12116. if !m.op.Is(OpUpdateOne) {
  12117. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12118. }
  12119. if m.id == nil || m.oldValue == nil {
  12120. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12121. }
  12122. oldValue, err := m.oldValue(ctx)
  12123. if err != nil {
  12124. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12125. }
  12126. return oldValue.UpdatedAt, nil
  12127. }
  12128. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12129. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12130. m.updated_at = nil
  12131. }
  12132. // SetStatus sets the "status" field.
  12133. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12134. m.status = &u
  12135. m.addstatus = nil
  12136. }
  12137. // Status returns the value of the "status" field in the mutation.
  12138. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12139. v := m.status
  12140. if v == nil {
  12141. return
  12142. }
  12143. return *v, true
  12144. }
  12145. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12146. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12148. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12149. if !m.op.Is(OpUpdateOne) {
  12150. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12151. }
  12152. if m.id == nil || m.oldValue == nil {
  12153. return v, errors.New("OldStatus requires an ID field in the mutation")
  12154. }
  12155. oldValue, err := m.oldValue(ctx)
  12156. if err != nil {
  12157. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12158. }
  12159. return oldValue.Status, nil
  12160. }
  12161. // AddStatus adds u to the "status" field.
  12162. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12163. if m.addstatus != nil {
  12164. *m.addstatus += u
  12165. } else {
  12166. m.addstatus = &u
  12167. }
  12168. }
  12169. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12170. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12171. v := m.addstatus
  12172. if v == nil {
  12173. return
  12174. }
  12175. return *v, true
  12176. }
  12177. // ClearStatus clears the value of the "status" field.
  12178. func (m *LabelRelationshipMutation) ClearStatus() {
  12179. m.status = nil
  12180. m.addstatus = nil
  12181. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12182. }
  12183. // StatusCleared returns if the "status" field was cleared in this mutation.
  12184. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12185. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12186. return ok
  12187. }
  12188. // ResetStatus resets all changes to the "status" field.
  12189. func (m *LabelRelationshipMutation) ResetStatus() {
  12190. m.status = nil
  12191. m.addstatus = nil
  12192. delete(m.clearedFields, labelrelationship.FieldStatus)
  12193. }
  12194. // SetDeletedAt sets the "deleted_at" field.
  12195. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12196. m.deleted_at = &t
  12197. }
  12198. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12199. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12200. v := m.deleted_at
  12201. if v == nil {
  12202. return
  12203. }
  12204. return *v, true
  12205. }
  12206. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12207. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12209. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12210. if !m.op.Is(OpUpdateOne) {
  12211. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12212. }
  12213. if m.id == nil || m.oldValue == nil {
  12214. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12215. }
  12216. oldValue, err := m.oldValue(ctx)
  12217. if err != nil {
  12218. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12219. }
  12220. return oldValue.DeletedAt, nil
  12221. }
  12222. // ClearDeletedAt clears the value of the "deleted_at" field.
  12223. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12224. m.deleted_at = nil
  12225. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12226. }
  12227. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12228. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12229. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12230. return ok
  12231. }
  12232. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12233. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12234. m.deleted_at = nil
  12235. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12236. }
  12237. // SetLabelID sets the "label_id" field.
  12238. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12239. m.labels = &u
  12240. }
  12241. // LabelID returns the value of the "label_id" field in the mutation.
  12242. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12243. v := m.labels
  12244. if v == nil {
  12245. return
  12246. }
  12247. return *v, true
  12248. }
  12249. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12250. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12252. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12253. if !m.op.Is(OpUpdateOne) {
  12254. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12255. }
  12256. if m.id == nil || m.oldValue == nil {
  12257. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12258. }
  12259. oldValue, err := m.oldValue(ctx)
  12260. if err != nil {
  12261. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  12262. }
  12263. return oldValue.LabelID, nil
  12264. }
  12265. // ResetLabelID resets all changes to the "label_id" field.
  12266. func (m *LabelRelationshipMutation) ResetLabelID() {
  12267. m.labels = nil
  12268. }
  12269. // SetContactID sets the "contact_id" field.
  12270. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  12271. m.contacts = &u
  12272. }
  12273. // ContactID returns the value of the "contact_id" field in the mutation.
  12274. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  12275. v := m.contacts
  12276. if v == nil {
  12277. return
  12278. }
  12279. return *v, true
  12280. }
  12281. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  12282. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12284. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12285. if !m.op.Is(OpUpdateOne) {
  12286. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12287. }
  12288. if m.id == nil || m.oldValue == nil {
  12289. return v, errors.New("OldContactID requires an ID field in the mutation")
  12290. }
  12291. oldValue, err := m.oldValue(ctx)
  12292. if err != nil {
  12293. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12294. }
  12295. return oldValue.ContactID, nil
  12296. }
  12297. // ResetContactID resets all changes to the "contact_id" field.
  12298. func (m *LabelRelationshipMutation) ResetContactID() {
  12299. m.contacts = nil
  12300. }
  12301. // SetOrganizationID sets the "organization_id" field.
  12302. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  12303. m.organization_id = &u
  12304. m.addorganization_id = nil
  12305. }
  12306. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12307. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  12308. v := m.organization_id
  12309. if v == nil {
  12310. return
  12311. }
  12312. return *v, true
  12313. }
  12314. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  12315. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12317. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12318. if !m.op.Is(OpUpdateOne) {
  12319. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12320. }
  12321. if m.id == nil || m.oldValue == nil {
  12322. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12323. }
  12324. oldValue, err := m.oldValue(ctx)
  12325. if err != nil {
  12326. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12327. }
  12328. return oldValue.OrganizationID, nil
  12329. }
  12330. // AddOrganizationID adds u to the "organization_id" field.
  12331. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  12332. if m.addorganization_id != nil {
  12333. *m.addorganization_id += u
  12334. } else {
  12335. m.addorganization_id = &u
  12336. }
  12337. }
  12338. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12339. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  12340. v := m.addorganization_id
  12341. if v == nil {
  12342. return
  12343. }
  12344. return *v, true
  12345. }
  12346. // ClearOrganizationID clears the value of the "organization_id" field.
  12347. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  12348. m.organization_id = nil
  12349. m.addorganization_id = nil
  12350. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  12351. }
  12352. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12353. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  12354. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  12355. return ok
  12356. }
  12357. // ResetOrganizationID resets all changes to the "organization_id" field.
  12358. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  12359. m.organization_id = nil
  12360. m.addorganization_id = nil
  12361. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  12362. }
  12363. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  12364. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  12365. m.contacts = &id
  12366. }
  12367. // ClearContacts clears the "contacts" edge to the Contact entity.
  12368. func (m *LabelRelationshipMutation) ClearContacts() {
  12369. m.clearedcontacts = true
  12370. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  12371. }
  12372. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  12373. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  12374. return m.clearedcontacts
  12375. }
  12376. // ContactsID returns the "contacts" edge ID in the mutation.
  12377. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  12378. if m.contacts != nil {
  12379. return *m.contacts, true
  12380. }
  12381. return
  12382. }
  12383. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  12384. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12385. // ContactsID instead. It exists only for internal usage by the builders.
  12386. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  12387. if id := m.contacts; id != nil {
  12388. ids = append(ids, *id)
  12389. }
  12390. return
  12391. }
  12392. // ResetContacts resets all changes to the "contacts" edge.
  12393. func (m *LabelRelationshipMutation) ResetContacts() {
  12394. m.contacts = nil
  12395. m.clearedcontacts = false
  12396. }
  12397. // SetLabelsID sets the "labels" edge to the Label entity by id.
  12398. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  12399. m.labels = &id
  12400. }
  12401. // ClearLabels clears the "labels" edge to the Label entity.
  12402. func (m *LabelRelationshipMutation) ClearLabels() {
  12403. m.clearedlabels = true
  12404. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  12405. }
  12406. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  12407. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  12408. return m.clearedlabels
  12409. }
  12410. // LabelsID returns the "labels" edge ID in the mutation.
  12411. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  12412. if m.labels != nil {
  12413. return *m.labels, true
  12414. }
  12415. return
  12416. }
  12417. // LabelsIDs returns the "labels" edge IDs in the mutation.
  12418. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12419. // LabelsID instead. It exists only for internal usage by the builders.
  12420. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  12421. if id := m.labels; id != nil {
  12422. ids = append(ids, *id)
  12423. }
  12424. return
  12425. }
  12426. // ResetLabels resets all changes to the "labels" edge.
  12427. func (m *LabelRelationshipMutation) ResetLabels() {
  12428. m.labels = nil
  12429. m.clearedlabels = false
  12430. }
  12431. // Where appends a list predicates to the LabelRelationshipMutation builder.
  12432. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  12433. m.predicates = append(m.predicates, ps...)
  12434. }
  12435. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  12436. // users can use type-assertion to append predicates that do not depend on any generated package.
  12437. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  12438. p := make([]predicate.LabelRelationship, len(ps))
  12439. for i := range ps {
  12440. p[i] = ps[i]
  12441. }
  12442. m.Where(p...)
  12443. }
  12444. // Op returns the operation name.
  12445. func (m *LabelRelationshipMutation) Op() Op {
  12446. return m.op
  12447. }
  12448. // SetOp allows setting the mutation operation.
  12449. func (m *LabelRelationshipMutation) SetOp(op Op) {
  12450. m.op = op
  12451. }
  12452. // Type returns the node type of this mutation (LabelRelationship).
  12453. func (m *LabelRelationshipMutation) Type() string {
  12454. return m.typ
  12455. }
  12456. // Fields returns all fields that were changed during this mutation. Note that in
  12457. // order to get all numeric fields that were incremented/decremented, call
  12458. // AddedFields().
  12459. func (m *LabelRelationshipMutation) Fields() []string {
  12460. fields := make([]string, 0, 7)
  12461. if m.created_at != nil {
  12462. fields = append(fields, labelrelationship.FieldCreatedAt)
  12463. }
  12464. if m.updated_at != nil {
  12465. fields = append(fields, labelrelationship.FieldUpdatedAt)
  12466. }
  12467. if m.status != nil {
  12468. fields = append(fields, labelrelationship.FieldStatus)
  12469. }
  12470. if m.deleted_at != nil {
  12471. fields = append(fields, labelrelationship.FieldDeletedAt)
  12472. }
  12473. if m.labels != nil {
  12474. fields = append(fields, labelrelationship.FieldLabelID)
  12475. }
  12476. if m.contacts != nil {
  12477. fields = append(fields, labelrelationship.FieldContactID)
  12478. }
  12479. if m.organization_id != nil {
  12480. fields = append(fields, labelrelationship.FieldOrganizationID)
  12481. }
  12482. return fields
  12483. }
  12484. // Field returns the value of a field with the given name. The second boolean
  12485. // return value indicates that this field was not set, or was not defined in the
  12486. // schema.
  12487. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  12488. switch name {
  12489. case labelrelationship.FieldCreatedAt:
  12490. return m.CreatedAt()
  12491. case labelrelationship.FieldUpdatedAt:
  12492. return m.UpdatedAt()
  12493. case labelrelationship.FieldStatus:
  12494. return m.Status()
  12495. case labelrelationship.FieldDeletedAt:
  12496. return m.DeletedAt()
  12497. case labelrelationship.FieldLabelID:
  12498. return m.LabelID()
  12499. case labelrelationship.FieldContactID:
  12500. return m.ContactID()
  12501. case labelrelationship.FieldOrganizationID:
  12502. return m.OrganizationID()
  12503. }
  12504. return nil, false
  12505. }
  12506. // OldField returns the old value of the field from the database. An error is
  12507. // returned if the mutation operation is not UpdateOne, or the query to the
  12508. // database failed.
  12509. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12510. switch name {
  12511. case labelrelationship.FieldCreatedAt:
  12512. return m.OldCreatedAt(ctx)
  12513. case labelrelationship.FieldUpdatedAt:
  12514. return m.OldUpdatedAt(ctx)
  12515. case labelrelationship.FieldStatus:
  12516. return m.OldStatus(ctx)
  12517. case labelrelationship.FieldDeletedAt:
  12518. return m.OldDeletedAt(ctx)
  12519. case labelrelationship.FieldLabelID:
  12520. return m.OldLabelID(ctx)
  12521. case labelrelationship.FieldContactID:
  12522. return m.OldContactID(ctx)
  12523. case labelrelationship.FieldOrganizationID:
  12524. return m.OldOrganizationID(ctx)
  12525. }
  12526. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  12527. }
  12528. // SetField sets the value of a field with the given name. It returns an error if
  12529. // the field is not defined in the schema, or if the type mismatched the field
  12530. // type.
  12531. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  12532. switch name {
  12533. case labelrelationship.FieldCreatedAt:
  12534. v, ok := value.(time.Time)
  12535. if !ok {
  12536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12537. }
  12538. m.SetCreatedAt(v)
  12539. return nil
  12540. case labelrelationship.FieldUpdatedAt:
  12541. v, ok := value.(time.Time)
  12542. if !ok {
  12543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12544. }
  12545. m.SetUpdatedAt(v)
  12546. return nil
  12547. case labelrelationship.FieldStatus:
  12548. v, ok := value.(uint8)
  12549. if !ok {
  12550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12551. }
  12552. m.SetStatus(v)
  12553. return nil
  12554. case labelrelationship.FieldDeletedAt:
  12555. v, ok := value.(time.Time)
  12556. if !ok {
  12557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12558. }
  12559. m.SetDeletedAt(v)
  12560. return nil
  12561. case labelrelationship.FieldLabelID:
  12562. v, ok := value.(uint64)
  12563. if !ok {
  12564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12565. }
  12566. m.SetLabelID(v)
  12567. return nil
  12568. case labelrelationship.FieldContactID:
  12569. v, ok := value.(uint64)
  12570. if !ok {
  12571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12572. }
  12573. m.SetContactID(v)
  12574. return nil
  12575. case labelrelationship.FieldOrganizationID:
  12576. v, ok := value.(uint64)
  12577. if !ok {
  12578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12579. }
  12580. m.SetOrganizationID(v)
  12581. return nil
  12582. }
  12583. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12584. }
  12585. // AddedFields returns all numeric fields that were incremented/decremented during
  12586. // this mutation.
  12587. func (m *LabelRelationshipMutation) AddedFields() []string {
  12588. var fields []string
  12589. if m.addstatus != nil {
  12590. fields = append(fields, labelrelationship.FieldStatus)
  12591. }
  12592. if m.addorganization_id != nil {
  12593. fields = append(fields, labelrelationship.FieldOrganizationID)
  12594. }
  12595. return fields
  12596. }
  12597. // AddedField returns the numeric value that was incremented/decremented on a field
  12598. // with the given name. The second boolean return value indicates that this field
  12599. // was not set, or was not defined in the schema.
  12600. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  12601. switch name {
  12602. case labelrelationship.FieldStatus:
  12603. return m.AddedStatus()
  12604. case labelrelationship.FieldOrganizationID:
  12605. return m.AddedOrganizationID()
  12606. }
  12607. return nil, false
  12608. }
  12609. // AddField adds the value to the field with the given name. It returns an error if
  12610. // the field is not defined in the schema, or if the type mismatched the field
  12611. // type.
  12612. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  12613. switch name {
  12614. case labelrelationship.FieldStatus:
  12615. v, ok := value.(int8)
  12616. if !ok {
  12617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12618. }
  12619. m.AddStatus(v)
  12620. return nil
  12621. case labelrelationship.FieldOrganizationID:
  12622. v, ok := value.(int64)
  12623. if !ok {
  12624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12625. }
  12626. m.AddOrganizationID(v)
  12627. return nil
  12628. }
  12629. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  12630. }
  12631. // ClearedFields returns all nullable fields that were cleared during this
  12632. // mutation.
  12633. func (m *LabelRelationshipMutation) ClearedFields() []string {
  12634. var fields []string
  12635. if m.FieldCleared(labelrelationship.FieldStatus) {
  12636. fields = append(fields, labelrelationship.FieldStatus)
  12637. }
  12638. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  12639. fields = append(fields, labelrelationship.FieldDeletedAt)
  12640. }
  12641. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  12642. fields = append(fields, labelrelationship.FieldOrganizationID)
  12643. }
  12644. return fields
  12645. }
  12646. // FieldCleared returns a boolean indicating if a field with the given name was
  12647. // cleared in this mutation.
  12648. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  12649. _, ok := m.clearedFields[name]
  12650. return ok
  12651. }
  12652. // ClearField clears the value of the field with the given name. It returns an
  12653. // error if the field is not defined in the schema.
  12654. func (m *LabelRelationshipMutation) ClearField(name string) error {
  12655. switch name {
  12656. case labelrelationship.FieldStatus:
  12657. m.ClearStatus()
  12658. return nil
  12659. case labelrelationship.FieldDeletedAt:
  12660. m.ClearDeletedAt()
  12661. return nil
  12662. case labelrelationship.FieldOrganizationID:
  12663. m.ClearOrganizationID()
  12664. return nil
  12665. }
  12666. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  12667. }
  12668. // ResetField resets all changes in the mutation for the field with the given name.
  12669. // It returns an error if the field is not defined in the schema.
  12670. func (m *LabelRelationshipMutation) ResetField(name string) error {
  12671. switch name {
  12672. case labelrelationship.FieldCreatedAt:
  12673. m.ResetCreatedAt()
  12674. return nil
  12675. case labelrelationship.FieldUpdatedAt:
  12676. m.ResetUpdatedAt()
  12677. return nil
  12678. case labelrelationship.FieldStatus:
  12679. m.ResetStatus()
  12680. return nil
  12681. case labelrelationship.FieldDeletedAt:
  12682. m.ResetDeletedAt()
  12683. return nil
  12684. case labelrelationship.FieldLabelID:
  12685. m.ResetLabelID()
  12686. return nil
  12687. case labelrelationship.FieldContactID:
  12688. m.ResetContactID()
  12689. return nil
  12690. case labelrelationship.FieldOrganizationID:
  12691. m.ResetOrganizationID()
  12692. return nil
  12693. }
  12694. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12695. }
  12696. // AddedEdges returns all edge names that were set/added in this mutation.
  12697. func (m *LabelRelationshipMutation) AddedEdges() []string {
  12698. edges := make([]string, 0, 2)
  12699. if m.contacts != nil {
  12700. edges = append(edges, labelrelationship.EdgeContacts)
  12701. }
  12702. if m.labels != nil {
  12703. edges = append(edges, labelrelationship.EdgeLabels)
  12704. }
  12705. return edges
  12706. }
  12707. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12708. // name in this mutation.
  12709. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  12710. switch name {
  12711. case labelrelationship.EdgeContacts:
  12712. if id := m.contacts; id != nil {
  12713. return []ent.Value{*id}
  12714. }
  12715. case labelrelationship.EdgeLabels:
  12716. if id := m.labels; id != nil {
  12717. return []ent.Value{*id}
  12718. }
  12719. }
  12720. return nil
  12721. }
  12722. // RemovedEdges returns all edge names that were removed in this mutation.
  12723. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  12724. edges := make([]string, 0, 2)
  12725. return edges
  12726. }
  12727. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12728. // the given name in this mutation.
  12729. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  12730. return nil
  12731. }
  12732. // ClearedEdges returns all edge names that were cleared in this mutation.
  12733. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  12734. edges := make([]string, 0, 2)
  12735. if m.clearedcontacts {
  12736. edges = append(edges, labelrelationship.EdgeContacts)
  12737. }
  12738. if m.clearedlabels {
  12739. edges = append(edges, labelrelationship.EdgeLabels)
  12740. }
  12741. return edges
  12742. }
  12743. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12744. // was cleared in this mutation.
  12745. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  12746. switch name {
  12747. case labelrelationship.EdgeContacts:
  12748. return m.clearedcontacts
  12749. case labelrelationship.EdgeLabels:
  12750. return m.clearedlabels
  12751. }
  12752. return false
  12753. }
  12754. // ClearEdge clears the value of the edge with the given name. It returns an error
  12755. // if that edge is not defined in the schema.
  12756. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  12757. switch name {
  12758. case labelrelationship.EdgeContacts:
  12759. m.ClearContacts()
  12760. return nil
  12761. case labelrelationship.EdgeLabels:
  12762. m.ClearLabels()
  12763. return nil
  12764. }
  12765. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  12766. }
  12767. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12768. // It returns an error if the edge is not defined in the schema.
  12769. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  12770. switch name {
  12771. case labelrelationship.EdgeContacts:
  12772. m.ResetContacts()
  12773. return nil
  12774. case labelrelationship.EdgeLabels:
  12775. m.ResetLabels()
  12776. return nil
  12777. }
  12778. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  12779. }
  12780. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  12781. type MessageMutation struct {
  12782. config
  12783. op Op
  12784. typ string
  12785. id *int
  12786. wx_wxid *string
  12787. wxid *string
  12788. content *string
  12789. clearedFields map[string]struct{}
  12790. done bool
  12791. oldValue func(context.Context) (*Message, error)
  12792. predicates []predicate.Message
  12793. }
  12794. var _ ent.Mutation = (*MessageMutation)(nil)
  12795. // messageOption allows management of the mutation configuration using functional options.
  12796. type messageOption func(*MessageMutation)
  12797. // newMessageMutation creates new mutation for the Message entity.
  12798. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  12799. m := &MessageMutation{
  12800. config: c,
  12801. op: op,
  12802. typ: TypeMessage,
  12803. clearedFields: make(map[string]struct{}),
  12804. }
  12805. for _, opt := range opts {
  12806. opt(m)
  12807. }
  12808. return m
  12809. }
  12810. // withMessageID sets the ID field of the mutation.
  12811. func withMessageID(id int) messageOption {
  12812. return func(m *MessageMutation) {
  12813. var (
  12814. err error
  12815. once sync.Once
  12816. value *Message
  12817. )
  12818. m.oldValue = func(ctx context.Context) (*Message, error) {
  12819. once.Do(func() {
  12820. if m.done {
  12821. err = errors.New("querying old values post mutation is not allowed")
  12822. } else {
  12823. value, err = m.Client().Message.Get(ctx, id)
  12824. }
  12825. })
  12826. return value, err
  12827. }
  12828. m.id = &id
  12829. }
  12830. }
  12831. // withMessage sets the old Message of the mutation.
  12832. func withMessage(node *Message) messageOption {
  12833. return func(m *MessageMutation) {
  12834. m.oldValue = func(context.Context) (*Message, error) {
  12835. return node, nil
  12836. }
  12837. m.id = &node.ID
  12838. }
  12839. }
  12840. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12841. // executed in a transaction (ent.Tx), a transactional client is returned.
  12842. func (m MessageMutation) Client() *Client {
  12843. client := &Client{config: m.config}
  12844. client.init()
  12845. return client
  12846. }
  12847. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12848. // it returns an error otherwise.
  12849. func (m MessageMutation) Tx() (*Tx, error) {
  12850. if _, ok := m.driver.(*txDriver); !ok {
  12851. return nil, errors.New("ent: mutation is not running in a transaction")
  12852. }
  12853. tx := &Tx{config: m.config}
  12854. tx.init()
  12855. return tx, nil
  12856. }
  12857. // ID returns the ID value in the mutation. Note that the ID is only available
  12858. // if it was provided to the builder or after it was returned from the database.
  12859. func (m *MessageMutation) ID() (id int, exists bool) {
  12860. if m.id == nil {
  12861. return
  12862. }
  12863. return *m.id, true
  12864. }
  12865. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12866. // That means, if the mutation is applied within a transaction with an isolation level such
  12867. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12868. // or updated by the mutation.
  12869. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  12870. switch {
  12871. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12872. id, exists := m.ID()
  12873. if exists {
  12874. return []int{id}, nil
  12875. }
  12876. fallthrough
  12877. case m.op.Is(OpUpdate | OpDelete):
  12878. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  12879. default:
  12880. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12881. }
  12882. }
  12883. // SetWxWxid sets the "wx_wxid" field.
  12884. func (m *MessageMutation) SetWxWxid(s string) {
  12885. m.wx_wxid = &s
  12886. }
  12887. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12888. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  12889. v := m.wx_wxid
  12890. if v == nil {
  12891. return
  12892. }
  12893. return *v, true
  12894. }
  12895. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  12896. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12898. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12899. if !m.op.Is(OpUpdateOne) {
  12900. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12901. }
  12902. if m.id == nil || m.oldValue == nil {
  12903. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12904. }
  12905. oldValue, err := m.oldValue(ctx)
  12906. if err != nil {
  12907. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12908. }
  12909. return oldValue.WxWxid, nil
  12910. }
  12911. // ClearWxWxid clears the value of the "wx_wxid" field.
  12912. func (m *MessageMutation) ClearWxWxid() {
  12913. m.wx_wxid = nil
  12914. m.clearedFields[message.FieldWxWxid] = struct{}{}
  12915. }
  12916. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  12917. func (m *MessageMutation) WxWxidCleared() bool {
  12918. _, ok := m.clearedFields[message.FieldWxWxid]
  12919. return ok
  12920. }
  12921. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12922. func (m *MessageMutation) ResetWxWxid() {
  12923. m.wx_wxid = nil
  12924. delete(m.clearedFields, message.FieldWxWxid)
  12925. }
  12926. // SetWxid sets the "wxid" field.
  12927. func (m *MessageMutation) SetWxid(s string) {
  12928. m.wxid = &s
  12929. }
  12930. // Wxid returns the value of the "wxid" field in the mutation.
  12931. func (m *MessageMutation) Wxid() (r string, exists bool) {
  12932. v := m.wxid
  12933. if v == nil {
  12934. return
  12935. }
  12936. return *v, true
  12937. }
  12938. // OldWxid returns the old "wxid" field's value of the Message entity.
  12939. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12941. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  12942. if !m.op.Is(OpUpdateOne) {
  12943. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12944. }
  12945. if m.id == nil || m.oldValue == nil {
  12946. return v, errors.New("OldWxid requires an ID field in the mutation")
  12947. }
  12948. oldValue, err := m.oldValue(ctx)
  12949. if err != nil {
  12950. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12951. }
  12952. return oldValue.Wxid, nil
  12953. }
  12954. // ResetWxid resets all changes to the "wxid" field.
  12955. func (m *MessageMutation) ResetWxid() {
  12956. m.wxid = nil
  12957. }
  12958. // SetContent sets the "content" field.
  12959. func (m *MessageMutation) SetContent(s string) {
  12960. m.content = &s
  12961. }
  12962. // Content returns the value of the "content" field in the mutation.
  12963. func (m *MessageMutation) Content() (r string, exists bool) {
  12964. v := m.content
  12965. if v == nil {
  12966. return
  12967. }
  12968. return *v, true
  12969. }
  12970. // OldContent returns the old "content" field's value of the Message entity.
  12971. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12973. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  12974. if !m.op.Is(OpUpdateOne) {
  12975. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  12976. }
  12977. if m.id == nil || m.oldValue == nil {
  12978. return v, errors.New("OldContent requires an ID field in the mutation")
  12979. }
  12980. oldValue, err := m.oldValue(ctx)
  12981. if err != nil {
  12982. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  12983. }
  12984. return oldValue.Content, nil
  12985. }
  12986. // ResetContent resets all changes to the "content" field.
  12987. func (m *MessageMutation) ResetContent() {
  12988. m.content = nil
  12989. }
  12990. // Where appends a list predicates to the MessageMutation builder.
  12991. func (m *MessageMutation) Where(ps ...predicate.Message) {
  12992. m.predicates = append(m.predicates, ps...)
  12993. }
  12994. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  12995. // users can use type-assertion to append predicates that do not depend on any generated package.
  12996. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  12997. p := make([]predicate.Message, len(ps))
  12998. for i := range ps {
  12999. p[i] = ps[i]
  13000. }
  13001. m.Where(p...)
  13002. }
  13003. // Op returns the operation name.
  13004. func (m *MessageMutation) Op() Op {
  13005. return m.op
  13006. }
  13007. // SetOp allows setting the mutation operation.
  13008. func (m *MessageMutation) SetOp(op Op) {
  13009. m.op = op
  13010. }
  13011. // Type returns the node type of this mutation (Message).
  13012. func (m *MessageMutation) Type() string {
  13013. return m.typ
  13014. }
  13015. // Fields returns all fields that were changed during this mutation. Note that in
  13016. // order to get all numeric fields that were incremented/decremented, call
  13017. // AddedFields().
  13018. func (m *MessageMutation) Fields() []string {
  13019. fields := make([]string, 0, 3)
  13020. if m.wx_wxid != nil {
  13021. fields = append(fields, message.FieldWxWxid)
  13022. }
  13023. if m.wxid != nil {
  13024. fields = append(fields, message.FieldWxid)
  13025. }
  13026. if m.content != nil {
  13027. fields = append(fields, message.FieldContent)
  13028. }
  13029. return fields
  13030. }
  13031. // Field returns the value of a field with the given name. The second boolean
  13032. // return value indicates that this field was not set, or was not defined in the
  13033. // schema.
  13034. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  13035. switch name {
  13036. case message.FieldWxWxid:
  13037. return m.WxWxid()
  13038. case message.FieldWxid:
  13039. return m.Wxid()
  13040. case message.FieldContent:
  13041. return m.Content()
  13042. }
  13043. return nil, false
  13044. }
  13045. // OldField returns the old value of the field from the database. An error is
  13046. // returned if the mutation operation is not UpdateOne, or the query to the
  13047. // database failed.
  13048. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13049. switch name {
  13050. case message.FieldWxWxid:
  13051. return m.OldWxWxid(ctx)
  13052. case message.FieldWxid:
  13053. return m.OldWxid(ctx)
  13054. case message.FieldContent:
  13055. return m.OldContent(ctx)
  13056. }
  13057. return nil, fmt.Errorf("unknown Message field %s", name)
  13058. }
  13059. // SetField sets the value of a field with the given name. It returns an error if
  13060. // the field is not defined in the schema, or if the type mismatched the field
  13061. // type.
  13062. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  13063. switch name {
  13064. case message.FieldWxWxid:
  13065. v, ok := value.(string)
  13066. if !ok {
  13067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13068. }
  13069. m.SetWxWxid(v)
  13070. return nil
  13071. case message.FieldWxid:
  13072. v, ok := value.(string)
  13073. if !ok {
  13074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13075. }
  13076. m.SetWxid(v)
  13077. return nil
  13078. case message.FieldContent:
  13079. v, ok := value.(string)
  13080. if !ok {
  13081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13082. }
  13083. m.SetContent(v)
  13084. return nil
  13085. }
  13086. return fmt.Errorf("unknown Message field %s", name)
  13087. }
  13088. // AddedFields returns all numeric fields that were incremented/decremented during
  13089. // this mutation.
  13090. func (m *MessageMutation) AddedFields() []string {
  13091. return nil
  13092. }
  13093. // AddedField returns the numeric value that was incremented/decremented on a field
  13094. // with the given name. The second boolean return value indicates that this field
  13095. // was not set, or was not defined in the schema.
  13096. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  13097. return nil, false
  13098. }
  13099. // AddField adds the value to the field with the given name. It returns an error if
  13100. // the field is not defined in the schema, or if the type mismatched the field
  13101. // type.
  13102. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  13103. switch name {
  13104. }
  13105. return fmt.Errorf("unknown Message numeric field %s", name)
  13106. }
  13107. // ClearedFields returns all nullable fields that were cleared during this
  13108. // mutation.
  13109. func (m *MessageMutation) ClearedFields() []string {
  13110. var fields []string
  13111. if m.FieldCleared(message.FieldWxWxid) {
  13112. fields = append(fields, message.FieldWxWxid)
  13113. }
  13114. return fields
  13115. }
  13116. // FieldCleared returns a boolean indicating if a field with the given name was
  13117. // cleared in this mutation.
  13118. func (m *MessageMutation) FieldCleared(name string) bool {
  13119. _, ok := m.clearedFields[name]
  13120. return ok
  13121. }
  13122. // ClearField clears the value of the field with the given name. It returns an
  13123. // error if the field is not defined in the schema.
  13124. func (m *MessageMutation) ClearField(name string) error {
  13125. switch name {
  13126. case message.FieldWxWxid:
  13127. m.ClearWxWxid()
  13128. return nil
  13129. }
  13130. return fmt.Errorf("unknown Message nullable field %s", name)
  13131. }
  13132. // ResetField resets all changes in the mutation for the field with the given name.
  13133. // It returns an error if the field is not defined in the schema.
  13134. func (m *MessageMutation) ResetField(name string) error {
  13135. switch name {
  13136. case message.FieldWxWxid:
  13137. m.ResetWxWxid()
  13138. return nil
  13139. case message.FieldWxid:
  13140. m.ResetWxid()
  13141. return nil
  13142. case message.FieldContent:
  13143. m.ResetContent()
  13144. return nil
  13145. }
  13146. return fmt.Errorf("unknown Message field %s", name)
  13147. }
  13148. // AddedEdges returns all edge names that were set/added in this mutation.
  13149. func (m *MessageMutation) AddedEdges() []string {
  13150. edges := make([]string, 0, 0)
  13151. return edges
  13152. }
  13153. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13154. // name in this mutation.
  13155. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  13156. return nil
  13157. }
  13158. // RemovedEdges returns all edge names that were removed in this mutation.
  13159. func (m *MessageMutation) RemovedEdges() []string {
  13160. edges := make([]string, 0, 0)
  13161. return edges
  13162. }
  13163. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13164. // the given name in this mutation.
  13165. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  13166. return nil
  13167. }
  13168. // ClearedEdges returns all edge names that were cleared in this mutation.
  13169. func (m *MessageMutation) ClearedEdges() []string {
  13170. edges := make([]string, 0, 0)
  13171. return edges
  13172. }
  13173. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13174. // was cleared in this mutation.
  13175. func (m *MessageMutation) EdgeCleared(name string) bool {
  13176. return false
  13177. }
  13178. // ClearEdge clears the value of the edge with the given name. It returns an error
  13179. // if that edge is not defined in the schema.
  13180. func (m *MessageMutation) ClearEdge(name string) error {
  13181. return fmt.Errorf("unknown Message unique edge %s", name)
  13182. }
  13183. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13184. // It returns an error if the edge is not defined in the schema.
  13185. func (m *MessageMutation) ResetEdge(name string) error {
  13186. return fmt.Errorf("unknown Message edge %s", name)
  13187. }
  13188. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  13189. type MessageRecordsMutation struct {
  13190. config
  13191. op Op
  13192. typ string
  13193. id *uint64
  13194. created_at *time.Time
  13195. updated_at *time.Time
  13196. status *uint8
  13197. addstatus *int8
  13198. bot_wxid *string
  13199. contact_type *int
  13200. addcontact_type *int
  13201. contact_wxid *string
  13202. content_type *int
  13203. addcontent_type *int
  13204. content *string
  13205. meta *custom_types.Meta
  13206. error_detail *string
  13207. send_time *time.Time
  13208. source_type *int
  13209. addsource_type *int
  13210. organization_id *uint64
  13211. addorganization_id *int64
  13212. clearedFields map[string]struct{}
  13213. sop_stage *uint64
  13214. clearedsop_stage bool
  13215. sop_node *uint64
  13216. clearedsop_node bool
  13217. message_contact *uint64
  13218. clearedmessage_contact bool
  13219. done bool
  13220. oldValue func(context.Context) (*MessageRecords, error)
  13221. predicates []predicate.MessageRecords
  13222. }
  13223. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  13224. // messagerecordsOption allows management of the mutation configuration using functional options.
  13225. type messagerecordsOption func(*MessageRecordsMutation)
  13226. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  13227. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  13228. m := &MessageRecordsMutation{
  13229. config: c,
  13230. op: op,
  13231. typ: TypeMessageRecords,
  13232. clearedFields: make(map[string]struct{}),
  13233. }
  13234. for _, opt := range opts {
  13235. opt(m)
  13236. }
  13237. return m
  13238. }
  13239. // withMessageRecordsID sets the ID field of the mutation.
  13240. func withMessageRecordsID(id uint64) messagerecordsOption {
  13241. return func(m *MessageRecordsMutation) {
  13242. var (
  13243. err error
  13244. once sync.Once
  13245. value *MessageRecords
  13246. )
  13247. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  13248. once.Do(func() {
  13249. if m.done {
  13250. err = errors.New("querying old values post mutation is not allowed")
  13251. } else {
  13252. value, err = m.Client().MessageRecords.Get(ctx, id)
  13253. }
  13254. })
  13255. return value, err
  13256. }
  13257. m.id = &id
  13258. }
  13259. }
  13260. // withMessageRecords sets the old MessageRecords of the mutation.
  13261. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  13262. return func(m *MessageRecordsMutation) {
  13263. m.oldValue = func(context.Context) (*MessageRecords, error) {
  13264. return node, nil
  13265. }
  13266. m.id = &node.ID
  13267. }
  13268. }
  13269. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13270. // executed in a transaction (ent.Tx), a transactional client is returned.
  13271. func (m MessageRecordsMutation) Client() *Client {
  13272. client := &Client{config: m.config}
  13273. client.init()
  13274. return client
  13275. }
  13276. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13277. // it returns an error otherwise.
  13278. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  13279. if _, ok := m.driver.(*txDriver); !ok {
  13280. return nil, errors.New("ent: mutation is not running in a transaction")
  13281. }
  13282. tx := &Tx{config: m.config}
  13283. tx.init()
  13284. return tx, nil
  13285. }
  13286. // SetID sets the value of the id field. Note that this
  13287. // operation is only accepted on creation of MessageRecords entities.
  13288. func (m *MessageRecordsMutation) SetID(id uint64) {
  13289. m.id = &id
  13290. }
  13291. // ID returns the ID value in the mutation. Note that the ID is only available
  13292. // if it was provided to the builder or after it was returned from the database.
  13293. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  13294. if m.id == nil {
  13295. return
  13296. }
  13297. return *m.id, true
  13298. }
  13299. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13300. // That means, if the mutation is applied within a transaction with an isolation level such
  13301. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13302. // or updated by the mutation.
  13303. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  13304. switch {
  13305. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13306. id, exists := m.ID()
  13307. if exists {
  13308. return []uint64{id}, nil
  13309. }
  13310. fallthrough
  13311. case m.op.Is(OpUpdate | OpDelete):
  13312. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  13313. default:
  13314. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13315. }
  13316. }
  13317. // SetCreatedAt sets the "created_at" field.
  13318. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  13319. m.created_at = &t
  13320. }
  13321. // CreatedAt returns the value of the "created_at" field in the mutation.
  13322. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  13323. v := m.created_at
  13324. if v == nil {
  13325. return
  13326. }
  13327. return *v, true
  13328. }
  13329. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  13330. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13332. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13333. if !m.op.Is(OpUpdateOne) {
  13334. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13335. }
  13336. if m.id == nil || m.oldValue == nil {
  13337. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13338. }
  13339. oldValue, err := m.oldValue(ctx)
  13340. if err != nil {
  13341. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13342. }
  13343. return oldValue.CreatedAt, nil
  13344. }
  13345. // ResetCreatedAt resets all changes to the "created_at" field.
  13346. func (m *MessageRecordsMutation) ResetCreatedAt() {
  13347. m.created_at = nil
  13348. }
  13349. // SetUpdatedAt sets the "updated_at" field.
  13350. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  13351. m.updated_at = &t
  13352. }
  13353. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13354. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  13355. v := m.updated_at
  13356. if v == nil {
  13357. return
  13358. }
  13359. return *v, true
  13360. }
  13361. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  13362. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13364. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13365. if !m.op.Is(OpUpdateOne) {
  13366. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13367. }
  13368. if m.id == nil || m.oldValue == nil {
  13369. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13370. }
  13371. oldValue, err := m.oldValue(ctx)
  13372. if err != nil {
  13373. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13374. }
  13375. return oldValue.UpdatedAt, nil
  13376. }
  13377. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13378. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  13379. m.updated_at = nil
  13380. }
  13381. // SetStatus sets the "status" field.
  13382. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  13383. m.status = &u
  13384. m.addstatus = nil
  13385. }
  13386. // Status returns the value of the "status" field in the mutation.
  13387. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  13388. v := m.status
  13389. if v == nil {
  13390. return
  13391. }
  13392. return *v, true
  13393. }
  13394. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  13395. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13397. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13398. if !m.op.Is(OpUpdateOne) {
  13399. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13400. }
  13401. if m.id == nil || m.oldValue == nil {
  13402. return v, errors.New("OldStatus requires an ID field in the mutation")
  13403. }
  13404. oldValue, err := m.oldValue(ctx)
  13405. if err != nil {
  13406. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13407. }
  13408. return oldValue.Status, nil
  13409. }
  13410. // AddStatus adds u to the "status" field.
  13411. func (m *MessageRecordsMutation) AddStatus(u int8) {
  13412. if m.addstatus != nil {
  13413. *m.addstatus += u
  13414. } else {
  13415. m.addstatus = &u
  13416. }
  13417. }
  13418. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13419. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  13420. v := m.addstatus
  13421. if v == nil {
  13422. return
  13423. }
  13424. return *v, true
  13425. }
  13426. // ClearStatus clears the value of the "status" field.
  13427. func (m *MessageRecordsMutation) ClearStatus() {
  13428. m.status = nil
  13429. m.addstatus = nil
  13430. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  13431. }
  13432. // StatusCleared returns if the "status" field was cleared in this mutation.
  13433. func (m *MessageRecordsMutation) StatusCleared() bool {
  13434. _, ok := m.clearedFields[messagerecords.FieldStatus]
  13435. return ok
  13436. }
  13437. // ResetStatus resets all changes to the "status" field.
  13438. func (m *MessageRecordsMutation) ResetStatus() {
  13439. m.status = nil
  13440. m.addstatus = nil
  13441. delete(m.clearedFields, messagerecords.FieldStatus)
  13442. }
  13443. // SetBotWxid sets the "bot_wxid" field.
  13444. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  13445. m.bot_wxid = &s
  13446. }
  13447. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  13448. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  13449. v := m.bot_wxid
  13450. if v == nil {
  13451. return
  13452. }
  13453. return *v, true
  13454. }
  13455. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  13456. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13458. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  13459. if !m.op.Is(OpUpdateOne) {
  13460. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  13461. }
  13462. if m.id == nil || m.oldValue == nil {
  13463. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  13464. }
  13465. oldValue, err := m.oldValue(ctx)
  13466. if err != nil {
  13467. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  13468. }
  13469. return oldValue.BotWxid, nil
  13470. }
  13471. // ResetBotWxid resets all changes to the "bot_wxid" field.
  13472. func (m *MessageRecordsMutation) ResetBotWxid() {
  13473. m.bot_wxid = nil
  13474. }
  13475. // SetContactID sets the "contact_id" field.
  13476. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  13477. m.message_contact = &u
  13478. }
  13479. // ContactID returns the value of the "contact_id" field in the mutation.
  13480. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  13481. v := m.message_contact
  13482. if v == nil {
  13483. return
  13484. }
  13485. return *v, true
  13486. }
  13487. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  13488. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13490. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13491. if !m.op.Is(OpUpdateOne) {
  13492. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13493. }
  13494. if m.id == nil || m.oldValue == nil {
  13495. return v, errors.New("OldContactID requires an ID field in the mutation")
  13496. }
  13497. oldValue, err := m.oldValue(ctx)
  13498. if err != nil {
  13499. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13500. }
  13501. return oldValue.ContactID, nil
  13502. }
  13503. // ClearContactID clears the value of the "contact_id" field.
  13504. func (m *MessageRecordsMutation) ClearContactID() {
  13505. m.message_contact = nil
  13506. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  13507. }
  13508. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  13509. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  13510. _, ok := m.clearedFields[messagerecords.FieldContactID]
  13511. return ok
  13512. }
  13513. // ResetContactID resets all changes to the "contact_id" field.
  13514. func (m *MessageRecordsMutation) ResetContactID() {
  13515. m.message_contact = nil
  13516. delete(m.clearedFields, messagerecords.FieldContactID)
  13517. }
  13518. // SetContactType sets the "contact_type" field.
  13519. func (m *MessageRecordsMutation) SetContactType(i int) {
  13520. m.contact_type = &i
  13521. m.addcontact_type = nil
  13522. }
  13523. // ContactType returns the value of the "contact_type" field in the mutation.
  13524. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  13525. v := m.contact_type
  13526. if v == nil {
  13527. return
  13528. }
  13529. return *v, true
  13530. }
  13531. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  13532. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13534. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  13535. if !m.op.Is(OpUpdateOne) {
  13536. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  13537. }
  13538. if m.id == nil || m.oldValue == nil {
  13539. return v, errors.New("OldContactType requires an ID field in the mutation")
  13540. }
  13541. oldValue, err := m.oldValue(ctx)
  13542. if err != nil {
  13543. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  13544. }
  13545. return oldValue.ContactType, nil
  13546. }
  13547. // AddContactType adds i to the "contact_type" field.
  13548. func (m *MessageRecordsMutation) AddContactType(i int) {
  13549. if m.addcontact_type != nil {
  13550. *m.addcontact_type += i
  13551. } else {
  13552. m.addcontact_type = &i
  13553. }
  13554. }
  13555. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  13556. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  13557. v := m.addcontact_type
  13558. if v == nil {
  13559. return
  13560. }
  13561. return *v, true
  13562. }
  13563. // ResetContactType resets all changes to the "contact_type" field.
  13564. func (m *MessageRecordsMutation) ResetContactType() {
  13565. m.contact_type = nil
  13566. m.addcontact_type = nil
  13567. }
  13568. // SetContactWxid sets the "contact_wxid" field.
  13569. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  13570. m.contact_wxid = &s
  13571. }
  13572. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  13573. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  13574. v := m.contact_wxid
  13575. if v == nil {
  13576. return
  13577. }
  13578. return *v, true
  13579. }
  13580. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  13581. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13583. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  13584. if !m.op.Is(OpUpdateOne) {
  13585. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  13586. }
  13587. if m.id == nil || m.oldValue == nil {
  13588. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  13589. }
  13590. oldValue, err := m.oldValue(ctx)
  13591. if err != nil {
  13592. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  13593. }
  13594. return oldValue.ContactWxid, nil
  13595. }
  13596. // ResetContactWxid resets all changes to the "contact_wxid" field.
  13597. func (m *MessageRecordsMutation) ResetContactWxid() {
  13598. m.contact_wxid = nil
  13599. }
  13600. // SetContentType sets the "content_type" field.
  13601. func (m *MessageRecordsMutation) SetContentType(i int) {
  13602. m.content_type = &i
  13603. m.addcontent_type = nil
  13604. }
  13605. // ContentType returns the value of the "content_type" field in the mutation.
  13606. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  13607. v := m.content_type
  13608. if v == nil {
  13609. return
  13610. }
  13611. return *v, true
  13612. }
  13613. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  13614. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13616. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  13617. if !m.op.Is(OpUpdateOne) {
  13618. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  13619. }
  13620. if m.id == nil || m.oldValue == nil {
  13621. return v, errors.New("OldContentType requires an ID field in the mutation")
  13622. }
  13623. oldValue, err := m.oldValue(ctx)
  13624. if err != nil {
  13625. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  13626. }
  13627. return oldValue.ContentType, nil
  13628. }
  13629. // AddContentType adds i to the "content_type" field.
  13630. func (m *MessageRecordsMutation) AddContentType(i int) {
  13631. if m.addcontent_type != nil {
  13632. *m.addcontent_type += i
  13633. } else {
  13634. m.addcontent_type = &i
  13635. }
  13636. }
  13637. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  13638. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  13639. v := m.addcontent_type
  13640. if v == nil {
  13641. return
  13642. }
  13643. return *v, true
  13644. }
  13645. // ResetContentType resets all changes to the "content_type" field.
  13646. func (m *MessageRecordsMutation) ResetContentType() {
  13647. m.content_type = nil
  13648. m.addcontent_type = nil
  13649. }
  13650. // SetContent sets the "content" field.
  13651. func (m *MessageRecordsMutation) SetContent(s string) {
  13652. m.content = &s
  13653. }
  13654. // Content returns the value of the "content" field in the mutation.
  13655. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  13656. v := m.content
  13657. if v == nil {
  13658. return
  13659. }
  13660. return *v, true
  13661. }
  13662. // OldContent returns the old "content" field's value of the MessageRecords entity.
  13663. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13665. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  13666. if !m.op.Is(OpUpdateOne) {
  13667. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13668. }
  13669. if m.id == nil || m.oldValue == nil {
  13670. return v, errors.New("OldContent requires an ID field in the mutation")
  13671. }
  13672. oldValue, err := m.oldValue(ctx)
  13673. if err != nil {
  13674. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13675. }
  13676. return oldValue.Content, nil
  13677. }
  13678. // ResetContent resets all changes to the "content" field.
  13679. func (m *MessageRecordsMutation) ResetContent() {
  13680. m.content = nil
  13681. }
  13682. // SetMeta sets the "meta" field.
  13683. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  13684. m.meta = &ct
  13685. }
  13686. // Meta returns the value of the "meta" field in the mutation.
  13687. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  13688. v := m.meta
  13689. if v == nil {
  13690. return
  13691. }
  13692. return *v, true
  13693. }
  13694. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  13695. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13697. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  13698. if !m.op.Is(OpUpdateOne) {
  13699. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  13700. }
  13701. if m.id == nil || m.oldValue == nil {
  13702. return v, errors.New("OldMeta requires an ID field in the mutation")
  13703. }
  13704. oldValue, err := m.oldValue(ctx)
  13705. if err != nil {
  13706. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  13707. }
  13708. return oldValue.Meta, nil
  13709. }
  13710. // ClearMeta clears the value of the "meta" field.
  13711. func (m *MessageRecordsMutation) ClearMeta() {
  13712. m.meta = nil
  13713. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  13714. }
  13715. // MetaCleared returns if the "meta" field was cleared in this mutation.
  13716. func (m *MessageRecordsMutation) MetaCleared() bool {
  13717. _, ok := m.clearedFields[messagerecords.FieldMeta]
  13718. return ok
  13719. }
  13720. // ResetMeta resets all changes to the "meta" field.
  13721. func (m *MessageRecordsMutation) ResetMeta() {
  13722. m.meta = nil
  13723. delete(m.clearedFields, messagerecords.FieldMeta)
  13724. }
  13725. // SetErrorDetail sets the "error_detail" field.
  13726. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  13727. m.error_detail = &s
  13728. }
  13729. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  13730. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  13731. v := m.error_detail
  13732. if v == nil {
  13733. return
  13734. }
  13735. return *v, true
  13736. }
  13737. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  13738. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13740. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  13741. if !m.op.Is(OpUpdateOne) {
  13742. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  13743. }
  13744. if m.id == nil || m.oldValue == nil {
  13745. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  13746. }
  13747. oldValue, err := m.oldValue(ctx)
  13748. if err != nil {
  13749. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  13750. }
  13751. return oldValue.ErrorDetail, nil
  13752. }
  13753. // ResetErrorDetail resets all changes to the "error_detail" field.
  13754. func (m *MessageRecordsMutation) ResetErrorDetail() {
  13755. m.error_detail = nil
  13756. }
  13757. // SetSendTime sets the "send_time" field.
  13758. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  13759. m.send_time = &t
  13760. }
  13761. // SendTime returns the value of the "send_time" field in the mutation.
  13762. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  13763. v := m.send_time
  13764. if v == nil {
  13765. return
  13766. }
  13767. return *v, true
  13768. }
  13769. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  13770. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13772. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  13773. if !m.op.Is(OpUpdateOne) {
  13774. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  13775. }
  13776. if m.id == nil || m.oldValue == nil {
  13777. return v, errors.New("OldSendTime requires an ID field in the mutation")
  13778. }
  13779. oldValue, err := m.oldValue(ctx)
  13780. if err != nil {
  13781. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  13782. }
  13783. return oldValue.SendTime, nil
  13784. }
  13785. // ClearSendTime clears the value of the "send_time" field.
  13786. func (m *MessageRecordsMutation) ClearSendTime() {
  13787. m.send_time = nil
  13788. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  13789. }
  13790. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  13791. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  13792. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  13793. return ok
  13794. }
  13795. // ResetSendTime resets all changes to the "send_time" field.
  13796. func (m *MessageRecordsMutation) ResetSendTime() {
  13797. m.send_time = nil
  13798. delete(m.clearedFields, messagerecords.FieldSendTime)
  13799. }
  13800. // SetSourceType sets the "source_type" field.
  13801. func (m *MessageRecordsMutation) SetSourceType(i int) {
  13802. m.source_type = &i
  13803. m.addsource_type = nil
  13804. }
  13805. // SourceType returns the value of the "source_type" field in the mutation.
  13806. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  13807. v := m.source_type
  13808. if v == nil {
  13809. return
  13810. }
  13811. return *v, true
  13812. }
  13813. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  13814. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13816. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  13817. if !m.op.Is(OpUpdateOne) {
  13818. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  13819. }
  13820. if m.id == nil || m.oldValue == nil {
  13821. return v, errors.New("OldSourceType requires an ID field in the mutation")
  13822. }
  13823. oldValue, err := m.oldValue(ctx)
  13824. if err != nil {
  13825. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  13826. }
  13827. return oldValue.SourceType, nil
  13828. }
  13829. // AddSourceType adds i to the "source_type" field.
  13830. func (m *MessageRecordsMutation) AddSourceType(i int) {
  13831. if m.addsource_type != nil {
  13832. *m.addsource_type += i
  13833. } else {
  13834. m.addsource_type = &i
  13835. }
  13836. }
  13837. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  13838. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  13839. v := m.addsource_type
  13840. if v == nil {
  13841. return
  13842. }
  13843. return *v, true
  13844. }
  13845. // ResetSourceType resets all changes to the "source_type" field.
  13846. func (m *MessageRecordsMutation) ResetSourceType() {
  13847. m.source_type = nil
  13848. m.addsource_type = nil
  13849. }
  13850. // SetSourceID sets the "source_id" field.
  13851. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  13852. m.sop_stage = &u
  13853. }
  13854. // SourceID returns the value of the "source_id" field in the mutation.
  13855. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  13856. v := m.sop_stage
  13857. if v == nil {
  13858. return
  13859. }
  13860. return *v, true
  13861. }
  13862. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  13863. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13865. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  13866. if !m.op.Is(OpUpdateOne) {
  13867. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  13868. }
  13869. if m.id == nil || m.oldValue == nil {
  13870. return v, errors.New("OldSourceID requires an ID field in the mutation")
  13871. }
  13872. oldValue, err := m.oldValue(ctx)
  13873. if err != nil {
  13874. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  13875. }
  13876. return oldValue.SourceID, nil
  13877. }
  13878. // ClearSourceID clears the value of the "source_id" field.
  13879. func (m *MessageRecordsMutation) ClearSourceID() {
  13880. m.sop_stage = nil
  13881. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13882. }
  13883. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  13884. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  13885. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  13886. return ok
  13887. }
  13888. // ResetSourceID resets all changes to the "source_id" field.
  13889. func (m *MessageRecordsMutation) ResetSourceID() {
  13890. m.sop_stage = nil
  13891. delete(m.clearedFields, messagerecords.FieldSourceID)
  13892. }
  13893. // SetSubSourceID sets the "sub_source_id" field.
  13894. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  13895. m.sop_node = &u
  13896. }
  13897. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  13898. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  13899. v := m.sop_node
  13900. if v == nil {
  13901. return
  13902. }
  13903. return *v, true
  13904. }
  13905. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  13906. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13908. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  13909. if !m.op.Is(OpUpdateOne) {
  13910. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  13911. }
  13912. if m.id == nil || m.oldValue == nil {
  13913. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  13914. }
  13915. oldValue, err := m.oldValue(ctx)
  13916. if err != nil {
  13917. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  13918. }
  13919. return oldValue.SubSourceID, nil
  13920. }
  13921. // ClearSubSourceID clears the value of the "sub_source_id" field.
  13922. func (m *MessageRecordsMutation) ClearSubSourceID() {
  13923. m.sop_node = nil
  13924. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13925. }
  13926. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  13927. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  13928. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  13929. return ok
  13930. }
  13931. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  13932. func (m *MessageRecordsMutation) ResetSubSourceID() {
  13933. m.sop_node = nil
  13934. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  13935. }
  13936. // SetOrganizationID sets the "organization_id" field.
  13937. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  13938. m.organization_id = &u
  13939. m.addorganization_id = nil
  13940. }
  13941. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13942. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  13943. v := m.organization_id
  13944. if v == nil {
  13945. return
  13946. }
  13947. return *v, true
  13948. }
  13949. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  13950. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13952. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13953. if !m.op.Is(OpUpdateOne) {
  13954. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13955. }
  13956. if m.id == nil || m.oldValue == nil {
  13957. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13958. }
  13959. oldValue, err := m.oldValue(ctx)
  13960. if err != nil {
  13961. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13962. }
  13963. return oldValue.OrganizationID, nil
  13964. }
  13965. // AddOrganizationID adds u to the "organization_id" field.
  13966. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  13967. if m.addorganization_id != nil {
  13968. *m.addorganization_id += u
  13969. } else {
  13970. m.addorganization_id = &u
  13971. }
  13972. }
  13973. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13974. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  13975. v := m.addorganization_id
  13976. if v == nil {
  13977. return
  13978. }
  13979. return *v, true
  13980. }
  13981. // ClearOrganizationID clears the value of the "organization_id" field.
  13982. func (m *MessageRecordsMutation) ClearOrganizationID() {
  13983. m.organization_id = nil
  13984. m.addorganization_id = nil
  13985. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  13986. }
  13987. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13988. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  13989. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  13990. return ok
  13991. }
  13992. // ResetOrganizationID resets all changes to the "organization_id" field.
  13993. func (m *MessageRecordsMutation) ResetOrganizationID() {
  13994. m.organization_id = nil
  13995. m.addorganization_id = nil
  13996. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  13997. }
  13998. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13999. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  14000. m.sop_stage = &id
  14001. }
  14002. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  14003. func (m *MessageRecordsMutation) ClearSopStage() {
  14004. m.clearedsop_stage = true
  14005. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14006. }
  14007. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  14008. func (m *MessageRecordsMutation) SopStageCleared() bool {
  14009. return m.SourceIDCleared() || m.clearedsop_stage
  14010. }
  14011. // SopStageID returns the "sop_stage" edge ID in the mutation.
  14012. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  14013. if m.sop_stage != nil {
  14014. return *m.sop_stage, true
  14015. }
  14016. return
  14017. }
  14018. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  14019. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14020. // SopStageID instead. It exists only for internal usage by the builders.
  14021. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  14022. if id := m.sop_stage; id != nil {
  14023. ids = append(ids, *id)
  14024. }
  14025. return
  14026. }
  14027. // ResetSopStage resets all changes to the "sop_stage" edge.
  14028. func (m *MessageRecordsMutation) ResetSopStage() {
  14029. m.sop_stage = nil
  14030. m.clearedsop_stage = false
  14031. }
  14032. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  14033. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  14034. m.sop_node = &id
  14035. }
  14036. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  14037. func (m *MessageRecordsMutation) ClearSopNode() {
  14038. m.clearedsop_node = true
  14039. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14040. }
  14041. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  14042. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  14043. return m.SubSourceIDCleared() || m.clearedsop_node
  14044. }
  14045. // SopNodeID returns the "sop_node" edge ID in the mutation.
  14046. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  14047. if m.sop_node != nil {
  14048. return *m.sop_node, true
  14049. }
  14050. return
  14051. }
  14052. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  14053. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14054. // SopNodeID instead. It exists only for internal usage by the builders.
  14055. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  14056. if id := m.sop_node; id != nil {
  14057. ids = append(ids, *id)
  14058. }
  14059. return
  14060. }
  14061. // ResetSopNode resets all changes to the "sop_node" edge.
  14062. func (m *MessageRecordsMutation) ResetSopNode() {
  14063. m.sop_node = nil
  14064. m.clearedsop_node = false
  14065. }
  14066. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  14067. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  14068. m.message_contact = &id
  14069. }
  14070. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  14071. func (m *MessageRecordsMutation) ClearMessageContact() {
  14072. m.clearedmessage_contact = true
  14073. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14074. }
  14075. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  14076. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  14077. return m.ContactIDCleared() || m.clearedmessage_contact
  14078. }
  14079. // MessageContactID returns the "message_contact" edge ID in the mutation.
  14080. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  14081. if m.message_contact != nil {
  14082. return *m.message_contact, true
  14083. }
  14084. return
  14085. }
  14086. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  14087. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14088. // MessageContactID instead. It exists only for internal usage by the builders.
  14089. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  14090. if id := m.message_contact; id != nil {
  14091. ids = append(ids, *id)
  14092. }
  14093. return
  14094. }
  14095. // ResetMessageContact resets all changes to the "message_contact" edge.
  14096. func (m *MessageRecordsMutation) ResetMessageContact() {
  14097. m.message_contact = nil
  14098. m.clearedmessage_contact = false
  14099. }
  14100. // Where appends a list predicates to the MessageRecordsMutation builder.
  14101. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  14102. m.predicates = append(m.predicates, ps...)
  14103. }
  14104. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  14105. // users can use type-assertion to append predicates that do not depend on any generated package.
  14106. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  14107. p := make([]predicate.MessageRecords, len(ps))
  14108. for i := range ps {
  14109. p[i] = ps[i]
  14110. }
  14111. m.Where(p...)
  14112. }
  14113. // Op returns the operation name.
  14114. func (m *MessageRecordsMutation) Op() Op {
  14115. return m.op
  14116. }
  14117. // SetOp allows setting the mutation operation.
  14118. func (m *MessageRecordsMutation) SetOp(op Op) {
  14119. m.op = op
  14120. }
  14121. // Type returns the node type of this mutation (MessageRecords).
  14122. func (m *MessageRecordsMutation) Type() string {
  14123. return m.typ
  14124. }
  14125. // Fields returns all fields that were changed during this mutation. Note that in
  14126. // order to get all numeric fields that were incremented/decremented, call
  14127. // AddedFields().
  14128. func (m *MessageRecordsMutation) Fields() []string {
  14129. fields := make([]string, 0, 16)
  14130. if m.created_at != nil {
  14131. fields = append(fields, messagerecords.FieldCreatedAt)
  14132. }
  14133. if m.updated_at != nil {
  14134. fields = append(fields, messagerecords.FieldUpdatedAt)
  14135. }
  14136. if m.status != nil {
  14137. fields = append(fields, messagerecords.FieldStatus)
  14138. }
  14139. if m.bot_wxid != nil {
  14140. fields = append(fields, messagerecords.FieldBotWxid)
  14141. }
  14142. if m.message_contact != nil {
  14143. fields = append(fields, messagerecords.FieldContactID)
  14144. }
  14145. if m.contact_type != nil {
  14146. fields = append(fields, messagerecords.FieldContactType)
  14147. }
  14148. if m.contact_wxid != nil {
  14149. fields = append(fields, messagerecords.FieldContactWxid)
  14150. }
  14151. if m.content_type != nil {
  14152. fields = append(fields, messagerecords.FieldContentType)
  14153. }
  14154. if m.content != nil {
  14155. fields = append(fields, messagerecords.FieldContent)
  14156. }
  14157. if m.meta != nil {
  14158. fields = append(fields, messagerecords.FieldMeta)
  14159. }
  14160. if m.error_detail != nil {
  14161. fields = append(fields, messagerecords.FieldErrorDetail)
  14162. }
  14163. if m.send_time != nil {
  14164. fields = append(fields, messagerecords.FieldSendTime)
  14165. }
  14166. if m.source_type != nil {
  14167. fields = append(fields, messagerecords.FieldSourceType)
  14168. }
  14169. if m.sop_stage != nil {
  14170. fields = append(fields, messagerecords.FieldSourceID)
  14171. }
  14172. if m.sop_node != nil {
  14173. fields = append(fields, messagerecords.FieldSubSourceID)
  14174. }
  14175. if m.organization_id != nil {
  14176. fields = append(fields, messagerecords.FieldOrganizationID)
  14177. }
  14178. return fields
  14179. }
  14180. // Field returns the value of a field with the given name. The second boolean
  14181. // return value indicates that this field was not set, or was not defined in the
  14182. // schema.
  14183. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  14184. switch name {
  14185. case messagerecords.FieldCreatedAt:
  14186. return m.CreatedAt()
  14187. case messagerecords.FieldUpdatedAt:
  14188. return m.UpdatedAt()
  14189. case messagerecords.FieldStatus:
  14190. return m.Status()
  14191. case messagerecords.FieldBotWxid:
  14192. return m.BotWxid()
  14193. case messagerecords.FieldContactID:
  14194. return m.ContactID()
  14195. case messagerecords.FieldContactType:
  14196. return m.ContactType()
  14197. case messagerecords.FieldContactWxid:
  14198. return m.ContactWxid()
  14199. case messagerecords.FieldContentType:
  14200. return m.ContentType()
  14201. case messagerecords.FieldContent:
  14202. return m.Content()
  14203. case messagerecords.FieldMeta:
  14204. return m.Meta()
  14205. case messagerecords.FieldErrorDetail:
  14206. return m.ErrorDetail()
  14207. case messagerecords.FieldSendTime:
  14208. return m.SendTime()
  14209. case messagerecords.FieldSourceType:
  14210. return m.SourceType()
  14211. case messagerecords.FieldSourceID:
  14212. return m.SourceID()
  14213. case messagerecords.FieldSubSourceID:
  14214. return m.SubSourceID()
  14215. case messagerecords.FieldOrganizationID:
  14216. return m.OrganizationID()
  14217. }
  14218. return nil, false
  14219. }
  14220. // OldField returns the old value of the field from the database. An error is
  14221. // returned if the mutation operation is not UpdateOne, or the query to the
  14222. // database failed.
  14223. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14224. switch name {
  14225. case messagerecords.FieldCreatedAt:
  14226. return m.OldCreatedAt(ctx)
  14227. case messagerecords.FieldUpdatedAt:
  14228. return m.OldUpdatedAt(ctx)
  14229. case messagerecords.FieldStatus:
  14230. return m.OldStatus(ctx)
  14231. case messagerecords.FieldBotWxid:
  14232. return m.OldBotWxid(ctx)
  14233. case messagerecords.FieldContactID:
  14234. return m.OldContactID(ctx)
  14235. case messagerecords.FieldContactType:
  14236. return m.OldContactType(ctx)
  14237. case messagerecords.FieldContactWxid:
  14238. return m.OldContactWxid(ctx)
  14239. case messagerecords.FieldContentType:
  14240. return m.OldContentType(ctx)
  14241. case messagerecords.FieldContent:
  14242. return m.OldContent(ctx)
  14243. case messagerecords.FieldMeta:
  14244. return m.OldMeta(ctx)
  14245. case messagerecords.FieldErrorDetail:
  14246. return m.OldErrorDetail(ctx)
  14247. case messagerecords.FieldSendTime:
  14248. return m.OldSendTime(ctx)
  14249. case messagerecords.FieldSourceType:
  14250. return m.OldSourceType(ctx)
  14251. case messagerecords.FieldSourceID:
  14252. return m.OldSourceID(ctx)
  14253. case messagerecords.FieldSubSourceID:
  14254. return m.OldSubSourceID(ctx)
  14255. case messagerecords.FieldOrganizationID:
  14256. return m.OldOrganizationID(ctx)
  14257. }
  14258. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  14259. }
  14260. // SetField sets the value of a field with the given name. It returns an error if
  14261. // the field is not defined in the schema, or if the type mismatched the field
  14262. // type.
  14263. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  14264. switch name {
  14265. case messagerecords.FieldCreatedAt:
  14266. v, ok := value.(time.Time)
  14267. if !ok {
  14268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14269. }
  14270. m.SetCreatedAt(v)
  14271. return nil
  14272. case messagerecords.FieldUpdatedAt:
  14273. v, ok := value.(time.Time)
  14274. if !ok {
  14275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14276. }
  14277. m.SetUpdatedAt(v)
  14278. return nil
  14279. case messagerecords.FieldStatus:
  14280. v, ok := value.(uint8)
  14281. if !ok {
  14282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14283. }
  14284. m.SetStatus(v)
  14285. return nil
  14286. case messagerecords.FieldBotWxid:
  14287. v, ok := value.(string)
  14288. if !ok {
  14289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14290. }
  14291. m.SetBotWxid(v)
  14292. return nil
  14293. case messagerecords.FieldContactID:
  14294. v, ok := value.(uint64)
  14295. if !ok {
  14296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14297. }
  14298. m.SetContactID(v)
  14299. return nil
  14300. case messagerecords.FieldContactType:
  14301. v, ok := value.(int)
  14302. if !ok {
  14303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14304. }
  14305. m.SetContactType(v)
  14306. return nil
  14307. case messagerecords.FieldContactWxid:
  14308. v, ok := value.(string)
  14309. if !ok {
  14310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14311. }
  14312. m.SetContactWxid(v)
  14313. return nil
  14314. case messagerecords.FieldContentType:
  14315. v, ok := value.(int)
  14316. if !ok {
  14317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14318. }
  14319. m.SetContentType(v)
  14320. return nil
  14321. case messagerecords.FieldContent:
  14322. v, ok := value.(string)
  14323. if !ok {
  14324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14325. }
  14326. m.SetContent(v)
  14327. return nil
  14328. case messagerecords.FieldMeta:
  14329. v, ok := value.(custom_types.Meta)
  14330. if !ok {
  14331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14332. }
  14333. m.SetMeta(v)
  14334. return nil
  14335. case messagerecords.FieldErrorDetail:
  14336. v, ok := value.(string)
  14337. if !ok {
  14338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14339. }
  14340. m.SetErrorDetail(v)
  14341. return nil
  14342. case messagerecords.FieldSendTime:
  14343. v, ok := value.(time.Time)
  14344. if !ok {
  14345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14346. }
  14347. m.SetSendTime(v)
  14348. return nil
  14349. case messagerecords.FieldSourceType:
  14350. v, ok := value.(int)
  14351. if !ok {
  14352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14353. }
  14354. m.SetSourceType(v)
  14355. return nil
  14356. case messagerecords.FieldSourceID:
  14357. v, ok := value.(uint64)
  14358. if !ok {
  14359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14360. }
  14361. m.SetSourceID(v)
  14362. return nil
  14363. case messagerecords.FieldSubSourceID:
  14364. v, ok := value.(uint64)
  14365. if !ok {
  14366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14367. }
  14368. m.SetSubSourceID(v)
  14369. return nil
  14370. case messagerecords.FieldOrganizationID:
  14371. v, ok := value.(uint64)
  14372. if !ok {
  14373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14374. }
  14375. m.SetOrganizationID(v)
  14376. return nil
  14377. }
  14378. return fmt.Errorf("unknown MessageRecords field %s", name)
  14379. }
  14380. // AddedFields returns all numeric fields that were incremented/decremented during
  14381. // this mutation.
  14382. func (m *MessageRecordsMutation) AddedFields() []string {
  14383. var fields []string
  14384. if m.addstatus != nil {
  14385. fields = append(fields, messagerecords.FieldStatus)
  14386. }
  14387. if m.addcontact_type != nil {
  14388. fields = append(fields, messagerecords.FieldContactType)
  14389. }
  14390. if m.addcontent_type != nil {
  14391. fields = append(fields, messagerecords.FieldContentType)
  14392. }
  14393. if m.addsource_type != nil {
  14394. fields = append(fields, messagerecords.FieldSourceType)
  14395. }
  14396. if m.addorganization_id != nil {
  14397. fields = append(fields, messagerecords.FieldOrganizationID)
  14398. }
  14399. return fields
  14400. }
  14401. // AddedField returns the numeric value that was incremented/decremented on a field
  14402. // with the given name. The second boolean return value indicates that this field
  14403. // was not set, or was not defined in the schema.
  14404. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  14405. switch name {
  14406. case messagerecords.FieldStatus:
  14407. return m.AddedStatus()
  14408. case messagerecords.FieldContactType:
  14409. return m.AddedContactType()
  14410. case messagerecords.FieldContentType:
  14411. return m.AddedContentType()
  14412. case messagerecords.FieldSourceType:
  14413. return m.AddedSourceType()
  14414. case messagerecords.FieldOrganizationID:
  14415. return m.AddedOrganizationID()
  14416. }
  14417. return nil, false
  14418. }
  14419. // AddField adds the value to the field with the given name. It returns an error if
  14420. // the field is not defined in the schema, or if the type mismatched the field
  14421. // type.
  14422. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  14423. switch name {
  14424. case messagerecords.FieldStatus:
  14425. v, ok := value.(int8)
  14426. if !ok {
  14427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14428. }
  14429. m.AddStatus(v)
  14430. return nil
  14431. case messagerecords.FieldContactType:
  14432. v, ok := value.(int)
  14433. if !ok {
  14434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14435. }
  14436. m.AddContactType(v)
  14437. return nil
  14438. case messagerecords.FieldContentType:
  14439. v, ok := value.(int)
  14440. if !ok {
  14441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14442. }
  14443. m.AddContentType(v)
  14444. return nil
  14445. case messagerecords.FieldSourceType:
  14446. v, ok := value.(int)
  14447. if !ok {
  14448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14449. }
  14450. m.AddSourceType(v)
  14451. return nil
  14452. case messagerecords.FieldOrganizationID:
  14453. v, ok := value.(int64)
  14454. if !ok {
  14455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14456. }
  14457. m.AddOrganizationID(v)
  14458. return nil
  14459. }
  14460. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  14461. }
  14462. // ClearedFields returns all nullable fields that were cleared during this
  14463. // mutation.
  14464. func (m *MessageRecordsMutation) ClearedFields() []string {
  14465. var fields []string
  14466. if m.FieldCleared(messagerecords.FieldStatus) {
  14467. fields = append(fields, messagerecords.FieldStatus)
  14468. }
  14469. if m.FieldCleared(messagerecords.FieldContactID) {
  14470. fields = append(fields, messagerecords.FieldContactID)
  14471. }
  14472. if m.FieldCleared(messagerecords.FieldMeta) {
  14473. fields = append(fields, messagerecords.FieldMeta)
  14474. }
  14475. if m.FieldCleared(messagerecords.FieldSendTime) {
  14476. fields = append(fields, messagerecords.FieldSendTime)
  14477. }
  14478. if m.FieldCleared(messagerecords.FieldSourceID) {
  14479. fields = append(fields, messagerecords.FieldSourceID)
  14480. }
  14481. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  14482. fields = append(fields, messagerecords.FieldSubSourceID)
  14483. }
  14484. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  14485. fields = append(fields, messagerecords.FieldOrganizationID)
  14486. }
  14487. return fields
  14488. }
  14489. // FieldCleared returns a boolean indicating if a field with the given name was
  14490. // cleared in this mutation.
  14491. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  14492. _, ok := m.clearedFields[name]
  14493. return ok
  14494. }
  14495. // ClearField clears the value of the field with the given name. It returns an
  14496. // error if the field is not defined in the schema.
  14497. func (m *MessageRecordsMutation) ClearField(name string) error {
  14498. switch name {
  14499. case messagerecords.FieldStatus:
  14500. m.ClearStatus()
  14501. return nil
  14502. case messagerecords.FieldContactID:
  14503. m.ClearContactID()
  14504. return nil
  14505. case messagerecords.FieldMeta:
  14506. m.ClearMeta()
  14507. return nil
  14508. case messagerecords.FieldSendTime:
  14509. m.ClearSendTime()
  14510. return nil
  14511. case messagerecords.FieldSourceID:
  14512. m.ClearSourceID()
  14513. return nil
  14514. case messagerecords.FieldSubSourceID:
  14515. m.ClearSubSourceID()
  14516. return nil
  14517. case messagerecords.FieldOrganizationID:
  14518. m.ClearOrganizationID()
  14519. return nil
  14520. }
  14521. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  14522. }
  14523. // ResetField resets all changes in the mutation for the field with the given name.
  14524. // It returns an error if the field is not defined in the schema.
  14525. func (m *MessageRecordsMutation) ResetField(name string) error {
  14526. switch name {
  14527. case messagerecords.FieldCreatedAt:
  14528. m.ResetCreatedAt()
  14529. return nil
  14530. case messagerecords.FieldUpdatedAt:
  14531. m.ResetUpdatedAt()
  14532. return nil
  14533. case messagerecords.FieldStatus:
  14534. m.ResetStatus()
  14535. return nil
  14536. case messagerecords.FieldBotWxid:
  14537. m.ResetBotWxid()
  14538. return nil
  14539. case messagerecords.FieldContactID:
  14540. m.ResetContactID()
  14541. return nil
  14542. case messagerecords.FieldContactType:
  14543. m.ResetContactType()
  14544. return nil
  14545. case messagerecords.FieldContactWxid:
  14546. m.ResetContactWxid()
  14547. return nil
  14548. case messagerecords.FieldContentType:
  14549. m.ResetContentType()
  14550. return nil
  14551. case messagerecords.FieldContent:
  14552. m.ResetContent()
  14553. return nil
  14554. case messagerecords.FieldMeta:
  14555. m.ResetMeta()
  14556. return nil
  14557. case messagerecords.FieldErrorDetail:
  14558. m.ResetErrorDetail()
  14559. return nil
  14560. case messagerecords.FieldSendTime:
  14561. m.ResetSendTime()
  14562. return nil
  14563. case messagerecords.FieldSourceType:
  14564. m.ResetSourceType()
  14565. return nil
  14566. case messagerecords.FieldSourceID:
  14567. m.ResetSourceID()
  14568. return nil
  14569. case messagerecords.FieldSubSourceID:
  14570. m.ResetSubSourceID()
  14571. return nil
  14572. case messagerecords.FieldOrganizationID:
  14573. m.ResetOrganizationID()
  14574. return nil
  14575. }
  14576. return fmt.Errorf("unknown MessageRecords field %s", name)
  14577. }
  14578. // AddedEdges returns all edge names that were set/added in this mutation.
  14579. func (m *MessageRecordsMutation) AddedEdges() []string {
  14580. edges := make([]string, 0, 3)
  14581. if m.sop_stage != nil {
  14582. edges = append(edges, messagerecords.EdgeSopStage)
  14583. }
  14584. if m.sop_node != nil {
  14585. edges = append(edges, messagerecords.EdgeSopNode)
  14586. }
  14587. if m.message_contact != nil {
  14588. edges = append(edges, messagerecords.EdgeMessageContact)
  14589. }
  14590. return edges
  14591. }
  14592. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14593. // name in this mutation.
  14594. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  14595. switch name {
  14596. case messagerecords.EdgeSopStage:
  14597. if id := m.sop_stage; id != nil {
  14598. return []ent.Value{*id}
  14599. }
  14600. case messagerecords.EdgeSopNode:
  14601. if id := m.sop_node; id != nil {
  14602. return []ent.Value{*id}
  14603. }
  14604. case messagerecords.EdgeMessageContact:
  14605. if id := m.message_contact; id != nil {
  14606. return []ent.Value{*id}
  14607. }
  14608. }
  14609. return nil
  14610. }
  14611. // RemovedEdges returns all edge names that were removed in this mutation.
  14612. func (m *MessageRecordsMutation) RemovedEdges() []string {
  14613. edges := make([]string, 0, 3)
  14614. return edges
  14615. }
  14616. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14617. // the given name in this mutation.
  14618. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  14619. return nil
  14620. }
  14621. // ClearedEdges returns all edge names that were cleared in this mutation.
  14622. func (m *MessageRecordsMutation) ClearedEdges() []string {
  14623. edges := make([]string, 0, 3)
  14624. if m.clearedsop_stage {
  14625. edges = append(edges, messagerecords.EdgeSopStage)
  14626. }
  14627. if m.clearedsop_node {
  14628. edges = append(edges, messagerecords.EdgeSopNode)
  14629. }
  14630. if m.clearedmessage_contact {
  14631. edges = append(edges, messagerecords.EdgeMessageContact)
  14632. }
  14633. return edges
  14634. }
  14635. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14636. // was cleared in this mutation.
  14637. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  14638. switch name {
  14639. case messagerecords.EdgeSopStage:
  14640. return m.clearedsop_stage
  14641. case messagerecords.EdgeSopNode:
  14642. return m.clearedsop_node
  14643. case messagerecords.EdgeMessageContact:
  14644. return m.clearedmessage_contact
  14645. }
  14646. return false
  14647. }
  14648. // ClearEdge clears the value of the edge with the given name. It returns an error
  14649. // if that edge is not defined in the schema.
  14650. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  14651. switch name {
  14652. case messagerecords.EdgeSopStage:
  14653. m.ClearSopStage()
  14654. return nil
  14655. case messagerecords.EdgeSopNode:
  14656. m.ClearSopNode()
  14657. return nil
  14658. case messagerecords.EdgeMessageContact:
  14659. m.ClearMessageContact()
  14660. return nil
  14661. }
  14662. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  14663. }
  14664. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14665. // It returns an error if the edge is not defined in the schema.
  14666. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  14667. switch name {
  14668. case messagerecords.EdgeSopStage:
  14669. m.ResetSopStage()
  14670. return nil
  14671. case messagerecords.EdgeSopNode:
  14672. m.ResetSopNode()
  14673. return nil
  14674. case messagerecords.EdgeMessageContact:
  14675. m.ResetMessageContact()
  14676. return nil
  14677. }
  14678. return fmt.Errorf("unknown MessageRecords edge %s", name)
  14679. }
  14680. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  14681. type MsgMutation struct {
  14682. config
  14683. op Op
  14684. typ string
  14685. id *uint64
  14686. created_at *time.Time
  14687. updated_at *time.Time
  14688. deleted_at *time.Time
  14689. status *uint8
  14690. addstatus *int8
  14691. fromwxid *string
  14692. toid *string
  14693. msgtype *int32
  14694. addmsgtype *int32
  14695. msg *string
  14696. batch_no *string
  14697. clearedFields map[string]struct{}
  14698. done bool
  14699. oldValue func(context.Context) (*Msg, error)
  14700. predicates []predicate.Msg
  14701. }
  14702. var _ ent.Mutation = (*MsgMutation)(nil)
  14703. // msgOption allows management of the mutation configuration using functional options.
  14704. type msgOption func(*MsgMutation)
  14705. // newMsgMutation creates new mutation for the Msg entity.
  14706. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  14707. m := &MsgMutation{
  14708. config: c,
  14709. op: op,
  14710. typ: TypeMsg,
  14711. clearedFields: make(map[string]struct{}),
  14712. }
  14713. for _, opt := range opts {
  14714. opt(m)
  14715. }
  14716. return m
  14717. }
  14718. // withMsgID sets the ID field of the mutation.
  14719. func withMsgID(id uint64) msgOption {
  14720. return func(m *MsgMutation) {
  14721. var (
  14722. err error
  14723. once sync.Once
  14724. value *Msg
  14725. )
  14726. m.oldValue = func(ctx context.Context) (*Msg, error) {
  14727. once.Do(func() {
  14728. if m.done {
  14729. err = errors.New("querying old values post mutation is not allowed")
  14730. } else {
  14731. value, err = m.Client().Msg.Get(ctx, id)
  14732. }
  14733. })
  14734. return value, err
  14735. }
  14736. m.id = &id
  14737. }
  14738. }
  14739. // withMsg sets the old Msg of the mutation.
  14740. func withMsg(node *Msg) msgOption {
  14741. return func(m *MsgMutation) {
  14742. m.oldValue = func(context.Context) (*Msg, error) {
  14743. return node, nil
  14744. }
  14745. m.id = &node.ID
  14746. }
  14747. }
  14748. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14749. // executed in a transaction (ent.Tx), a transactional client is returned.
  14750. func (m MsgMutation) Client() *Client {
  14751. client := &Client{config: m.config}
  14752. client.init()
  14753. return client
  14754. }
  14755. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14756. // it returns an error otherwise.
  14757. func (m MsgMutation) Tx() (*Tx, error) {
  14758. if _, ok := m.driver.(*txDriver); !ok {
  14759. return nil, errors.New("ent: mutation is not running in a transaction")
  14760. }
  14761. tx := &Tx{config: m.config}
  14762. tx.init()
  14763. return tx, nil
  14764. }
  14765. // SetID sets the value of the id field. Note that this
  14766. // operation is only accepted on creation of Msg entities.
  14767. func (m *MsgMutation) SetID(id uint64) {
  14768. m.id = &id
  14769. }
  14770. // ID returns the ID value in the mutation. Note that the ID is only available
  14771. // if it was provided to the builder or after it was returned from the database.
  14772. func (m *MsgMutation) ID() (id uint64, exists bool) {
  14773. if m.id == nil {
  14774. return
  14775. }
  14776. return *m.id, true
  14777. }
  14778. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14779. // That means, if the mutation is applied within a transaction with an isolation level such
  14780. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14781. // or updated by the mutation.
  14782. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  14783. switch {
  14784. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14785. id, exists := m.ID()
  14786. if exists {
  14787. return []uint64{id}, nil
  14788. }
  14789. fallthrough
  14790. case m.op.Is(OpUpdate | OpDelete):
  14791. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  14792. default:
  14793. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14794. }
  14795. }
  14796. // SetCreatedAt sets the "created_at" field.
  14797. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  14798. m.created_at = &t
  14799. }
  14800. // CreatedAt returns the value of the "created_at" field in the mutation.
  14801. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  14802. v := m.created_at
  14803. if v == nil {
  14804. return
  14805. }
  14806. return *v, true
  14807. }
  14808. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  14809. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14811. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14812. if !m.op.Is(OpUpdateOne) {
  14813. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14814. }
  14815. if m.id == nil || m.oldValue == nil {
  14816. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14817. }
  14818. oldValue, err := m.oldValue(ctx)
  14819. if err != nil {
  14820. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14821. }
  14822. return oldValue.CreatedAt, nil
  14823. }
  14824. // ResetCreatedAt resets all changes to the "created_at" field.
  14825. func (m *MsgMutation) ResetCreatedAt() {
  14826. m.created_at = nil
  14827. }
  14828. // SetUpdatedAt sets the "updated_at" field.
  14829. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  14830. m.updated_at = &t
  14831. }
  14832. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14833. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  14834. v := m.updated_at
  14835. if v == nil {
  14836. return
  14837. }
  14838. return *v, true
  14839. }
  14840. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  14841. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14843. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14844. if !m.op.Is(OpUpdateOne) {
  14845. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14846. }
  14847. if m.id == nil || m.oldValue == nil {
  14848. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14849. }
  14850. oldValue, err := m.oldValue(ctx)
  14851. if err != nil {
  14852. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14853. }
  14854. return oldValue.UpdatedAt, nil
  14855. }
  14856. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14857. func (m *MsgMutation) ResetUpdatedAt() {
  14858. m.updated_at = nil
  14859. }
  14860. // SetDeletedAt sets the "deleted_at" field.
  14861. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  14862. m.deleted_at = &t
  14863. }
  14864. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14865. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  14866. v := m.deleted_at
  14867. if v == nil {
  14868. return
  14869. }
  14870. return *v, true
  14871. }
  14872. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  14873. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14875. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14876. if !m.op.Is(OpUpdateOne) {
  14877. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14878. }
  14879. if m.id == nil || m.oldValue == nil {
  14880. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14881. }
  14882. oldValue, err := m.oldValue(ctx)
  14883. if err != nil {
  14884. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14885. }
  14886. return oldValue.DeletedAt, nil
  14887. }
  14888. // ClearDeletedAt clears the value of the "deleted_at" field.
  14889. func (m *MsgMutation) ClearDeletedAt() {
  14890. m.deleted_at = nil
  14891. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  14892. }
  14893. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14894. func (m *MsgMutation) DeletedAtCleared() bool {
  14895. _, ok := m.clearedFields[msg.FieldDeletedAt]
  14896. return ok
  14897. }
  14898. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14899. func (m *MsgMutation) ResetDeletedAt() {
  14900. m.deleted_at = nil
  14901. delete(m.clearedFields, msg.FieldDeletedAt)
  14902. }
  14903. // SetStatus sets the "status" field.
  14904. func (m *MsgMutation) SetStatus(u uint8) {
  14905. m.status = &u
  14906. m.addstatus = nil
  14907. }
  14908. // Status returns the value of the "status" field in the mutation.
  14909. func (m *MsgMutation) Status() (r uint8, exists bool) {
  14910. v := m.status
  14911. if v == nil {
  14912. return
  14913. }
  14914. return *v, true
  14915. }
  14916. // OldStatus returns the old "status" field's value of the Msg entity.
  14917. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14919. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14920. if !m.op.Is(OpUpdateOne) {
  14921. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14922. }
  14923. if m.id == nil || m.oldValue == nil {
  14924. return v, errors.New("OldStatus requires an ID field in the mutation")
  14925. }
  14926. oldValue, err := m.oldValue(ctx)
  14927. if err != nil {
  14928. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14929. }
  14930. return oldValue.Status, nil
  14931. }
  14932. // AddStatus adds u to the "status" field.
  14933. func (m *MsgMutation) AddStatus(u int8) {
  14934. if m.addstatus != nil {
  14935. *m.addstatus += u
  14936. } else {
  14937. m.addstatus = &u
  14938. }
  14939. }
  14940. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14941. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  14942. v := m.addstatus
  14943. if v == nil {
  14944. return
  14945. }
  14946. return *v, true
  14947. }
  14948. // ClearStatus clears the value of the "status" field.
  14949. func (m *MsgMutation) ClearStatus() {
  14950. m.status = nil
  14951. m.addstatus = nil
  14952. m.clearedFields[msg.FieldStatus] = struct{}{}
  14953. }
  14954. // StatusCleared returns if the "status" field was cleared in this mutation.
  14955. func (m *MsgMutation) StatusCleared() bool {
  14956. _, ok := m.clearedFields[msg.FieldStatus]
  14957. return ok
  14958. }
  14959. // ResetStatus resets all changes to the "status" field.
  14960. func (m *MsgMutation) ResetStatus() {
  14961. m.status = nil
  14962. m.addstatus = nil
  14963. delete(m.clearedFields, msg.FieldStatus)
  14964. }
  14965. // SetFromwxid sets the "fromwxid" field.
  14966. func (m *MsgMutation) SetFromwxid(s string) {
  14967. m.fromwxid = &s
  14968. }
  14969. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  14970. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  14971. v := m.fromwxid
  14972. if v == nil {
  14973. return
  14974. }
  14975. return *v, true
  14976. }
  14977. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  14978. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14980. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  14981. if !m.op.Is(OpUpdateOne) {
  14982. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  14983. }
  14984. if m.id == nil || m.oldValue == nil {
  14985. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  14986. }
  14987. oldValue, err := m.oldValue(ctx)
  14988. if err != nil {
  14989. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  14990. }
  14991. return oldValue.Fromwxid, nil
  14992. }
  14993. // ClearFromwxid clears the value of the "fromwxid" field.
  14994. func (m *MsgMutation) ClearFromwxid() {
  14995. m.fromwxid = nil
  14996. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  14997. }
  14998. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  14999. func (m *MsgMutation) FromwxidCleared() bool {
  15000. _, ok := m.clearedFields[msg.FieldFromwxid]
  15001. return ok
  15002. }
  15003. // ResetFromwxid resets all changes to the "fromwxid" field.
  15004. func (m *MsgMutation) ResetFromwxid() {
  15005. m.fromwxid = nil
  15006. delete(m.clearedFields, msg.FieldFromwxid)
  15007. }
  15008. // SetToid sets the "toid" field.
  15009. func (m *MsgMutation) SetToid(s string) {
  15010. m.toid = &s
  15011. }
  15012. // Toid returns the value of the "toid" field in the mutation.
  15013. func (m *MsgMutation) Toid() (r string, exists bool) {
  15014. v := m.toid
  15015. if v == nil {
  15016. return
  15017. }
  15018. return *v, true
  15019. }
  15020. // OldToid returns the old "toid" field's value of the Msg entity.
  15021. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15023. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  15024. if !m.op.Is(OpUpdateOne) {
  15025. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  15026. }
  15027. if m.id == nil || m.oldValue == nil {
  15028. return v, errors.New("OldToid requires an ID field in the mutation")
  15029. }
  15030. oldValue, err := m.oldValue(ctx)
  15031. if err != nil {
  15032. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  15033. }
  15034. return oldValue.Toid, nil
  15035. }
  15036. // ClearToid clears the value of the "toid" field.
  15037. func (m *MsgMutation) ClearToid() {
  15038. m.toid = nil
  15039. m.clearedFields[msg.FieldToid] = struct{}{}
  15040. }
  15041. // ToidCleared returns if the "toid" field was cleared in this mutation.
  15042. func (m *MsgMutation) ToidCleared() bool {
  15043. _, ok := m.clearedFields[msg.FieldToid]
  15044. return ok
  15045. }
  15046. // ResetToid resets all changes to the "toid" field.
  15047. func (m *MsgMutation) ResetToid() {
  15048. m.toid = nil
  15049. delete(m.clearedFields, msg.FieldToid)
  15050. }
  15051. // SetMsgtype sets the "msgtype" field.
  15052. func (m *MsgMutation) SetMsgtype(i int32) {
  15053. m.msgtype = &i
  15054. m.addmsgtype = nil
  15055. }
  15056. // Msgtype returns the value of the "msgtype" field in the mutation.
  15057. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  15058. v := m.msgtype
  15059. if v == nil {
  15060. return
  15061. }
  15062. return *v, true
  15063. }
  15064. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  15065. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15067. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  15068. if !m.op.Is(OpUpdateOne) {
  15069. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  15070. }
  15071. if m.id == nil || m.oldValue == nil {
  15072. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  15073. }
  15074. oldValue, err := m.oldValue(ctx)
  15075. if err != nil {
  15076. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  15077. }
  15078. return oldValue.Msgtype, nil
  15079. }
  15080. // AddMsgtype adds i to the "msgtype" field.
  15081. func (m *MsgMutation) AddMsgtype(i int32) {
  15082. if m.addmsgtype != nil {
  15083. *m.addmsgtype += i
  15084. } else {
  15085. m.addmsgtype = &i
  15086. }
  15087. }
  15088. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  15089. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  15090. v := m.addmsgtype
  15091. if v == nil {
  15092. return
  15093. }
  15094. return *v, true
  15095. }
  15096. // ClearMsgtype clears the value of the "msgtype" field.
  15097. func (m *MsgMutation) ClearMsgtype() {
  15098. m.msgtype = nil
  15099. m.addmsgtype = nil
  15100. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  15101. }
  15102. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  15103. func (m *MsgMutation) MsgtypeCleared() bool {
  15104. _, ok := m.clearedFields[msg.FieldMsgtype]
  15105. return ok
  15106. }
  15107. // ResetMsgtype resets all changes to the "msgtype" field.
  15108. func (m *MsgMutation) ResetMsgtype() {
  15109. m.msgtype = nil
  15110. m.addmsgtype = nil
  15111. delete(m.clearedFields, msg.FieldMsgtype)
  15112. }
  15113. // SetMsg sets the "msg" field.
  15114. func (m *MsgMutation) SetMsg(s string) {
  15115. m.msg = &s
  15116. }
  15117. // Msg returns the value of the "msg" field in the mutation.
  15118. func (m *MsgMutation) Msg() (r string, exists bool) {
  15119. v := m.msg
  15120. if v == nil {
  15121. return
  15122. }
  15123. return *v, true
  15124. }
  15125. // OldMsg returns the old "msg" field's value of the Msg entity.
  15126. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15128. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  15129. if !m.op.Is(OpUpdateOne) {
  15130. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  15131. }
  15132. if m.id == nil || m.oldValue == nil {
  15133. return v, errors.New("OldMsg requires an ID field in the mutation")
  15134. }
  15135. oldValue, err := m.oldValue(ctx)
  15136. if err != nil {
  15137. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  15138. }
  15139. return oldValue.Msg, nil
  15140. }
  15141. // ClearMsg clears the value of the "msg" field.
  15142. func (m *MsgMutation) ClearMsg() {
  15143. m.msg = nil
  15144. m.clearedFields[msg.FieldMsg] = struct{}{}
  15145. }
  15146. // MsgCleared returns if the "msg" field was cleared in this mutation.
  15147. func (m *MsgMutation) MsgCleared() bool {
  15148. _, ok := m.clearedFields[msg.FieldMsg]
  15149. return ok
  15150. }
  15151. // ResetMsg resets all changes to the "msg" field.
  15152. func (m *MsgMutation) ResetMsg() {
  15153. m.msg = nil
  15154. delete(m.clearedFields, msg.FieldMsg)
  15155. }
  15156. // SetBatchNo sets the "batch_no" field.
  15157. func (m *MsgMutation) SetBatchNo(s string) {
  15158. m.batch_no = &s
  15159. }
  15160. // BatchNo returns the value of the "batch_no" field in the mutation.
  15161. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  15162. v := m.batch_no
  15163. if v == nil {
  15164. return
  15165. }
  15166. return *v, true
  15167. }
  15168. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  15169. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15171. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  15172. if !m.op.Is(OpUpdateOne) {
  15173. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  15174. }
  15175. if m.id == nil || m.oldValue == nil {
  15176. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  15177. }
  15178. oldValue, err := m.oldValue(ctx)
  15179. if err != nil {
  15180. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  15181. }
  15182. return oldValue.BatchNo, nil
  15183. }
  15184. // ClearBatchNo clears the value of the "batch_no" field.
  15185. func (m *MsgMutation) ClearBatchNo() {
  15186. m.batch_no = nil
  15187. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  15188. }
  15189. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  15190. func (m *MsgMutation) BatchNoCleared() bool {
  15191. _, ok := m.clearedFields[msg.FieldBatchNo]
  15192. return ok
  15193. }
  15194. // ResetBatchNo resets all changes to the "batch_no" field.
  15195. func (m *MsgMutation) ResetBatchNo() {
  15196. m.batch_no = nil
  15197. delete(m.clearedFields, msg.FieldBatchNo)
  15198. }
  15199. // Where appends a list predicates to the MsgMutation builder.
  15200. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  15201. m.predicates = append(m.predicates, ps...)
  15202. }
  15203. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  15204. // users can use type-assertion to append predicates that do not depend on any generated package.
  15205. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  15206. p := make([]predicate.Msg, len(ps))
  15207. for i := range ps {
  15208. p[i] = ps[i]
  15209. }
  15210. m.Where(p...)
  15211. }
  15212. // Op returns the operation name.
  15213. func (m *MsgMutation) Op() Op {
  15214. return m.op
  15215. }
  15216. // SetOp allows setting the mutation operation.
  15217. func (m *MsgMutation) SetOp(op Op) {
  15218. m.op = op
  15219. }
  15220. // Type returns the node type of this mutation (Msg).
  15221. func (m *MsgMutation) Type() string {
  15222. return m.typ
  15223. }
  15224. // Fields returns all fields that were changed during this mutation. Note that in
  15225. // order to get all numeric fields that were incremented/decremented, call
  15226. // AddedFields().
  15227. func (m *MsgMutation) Fields() []string {
  15228. fields := make([]string, 0, 9)
  15229. if m.created_at != nil {
  15230. fields = append(fields, msg.FieldCreatedAt)
  15231. }
  15232. if m.updated_at != nil {
  15233. fields = append(fields, msg.FieldUpdatedAt)
  15234. }
  15235. if m.deleted_at != nil {
  15236. fields = append(fields, msg.FieldDeletedAt)
  15237. }
  15238. if m.status != nil {
  15239. fields = append(fields, msg.FieldStatus)
  15240. }
  15241. if m.fromwxid != nil {
  15242. fields = append(fields, msg.FieldFromwxid)
  15243. }
  15244. if m.toid != nil {
  15245. fields = append(fields, msg.FieldToid)
  15246. }
  15247. if m.msgtype != nil {
  15248. fields = append(fields, msg.FieldMsgtype)
  15249. }
  15250. if m.msg != nil {
  15251. fields = append(fields, msg.FieldMsg)
  15252. }
  15253. if m.batch_no != nil {
  15254. fields = append(fields, msg.FieldBatchNo)
  15255. }
  15256. return fields
  15257. }
  15258. // Field returns the value of a field with the given name. The second boolean
  15259. // return value indicates that this field was not set, or was not defined in the
  15260. // schema.
  15261. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  15262. switch name {
  15263. case msg.FieldCreatedAt:
  15264. return m.CreatedAt()
  15265. case msg.FieldUpdatedAt:
  15266. return m.UpdatedAt()
  15267. case msg.FieldDeletedAt:
  15268. return m.DeletedAt()
  15269. case msg.FieldStatus:
  15270. return m.Status()
  15271. case msg.FieldFromwxid:
  15272. return m.Fromwxid()
  15273. case msg.FieldToid:
  15274. return m.Toid()
  15275. case msg.FieldMsgtype:
  15276. return m.Msgtype()
  15277. case msg.FieldMsg:
  15278. return m.Msg()
  15279. case msg.FieldBatchNo:
  15280. return m.BatchNo()
  15281. }
  15282. return nil, false
  15283. }
  15284. // OldField returns the old value of the field from the database. An error is
  15285. // returned if the mutation operation is not UpdateOne, or the query to the
  15286. // database failed.
  15287. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15288. switch name {
  15289. case msg.FieldCreatedAt:
  15290. return m.OldCreatedAt(ctx)
  15291. case msg.FieldUpdatedAt:
  15292. return m.OldUpdatedAt(ctx)
  15293. case msg.FieldDeletedAt:
  15294. return m.OldDeletedAt(ctx)
  15295. case msg.FieldStatus:
  15296. return m.OldStatus(ctx)
  15297. case msg.FieldFromwxid:
  15298. return m.OldFromwxid(ctx)
  15299. case msg.FieldToid:
  15300. return m.OldToid(ctx)
  15301. case msg.FieldMsgtype:
  15302. return m.OldMsgtype(ctx)
  15303. case msg.FieldMsg:
  15304. return m.OldMsg(ctx)
  15305. case msg.FieldBatchNo:
  15306. return m.OldBatchNo(ctx)
  15307. }
  15308. return nil, fmt.Errorf("unknown Msg field %s", name)
  15309. }
  15310. // SetField sets the value of a field with the given name. It returns an error if
  15311. // the field is not defined in the schema, or if the type mismatched the field
  15312. // type.
  15313. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  15314. switch name {
  15315. case msg.FieldCreatedAt:
  15316. v, ok := value.(time.Time)
  15317. if !ok {
  15318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15319. }
  15320. m.SetCreatedAt(v)
  15321. return nil
  15322. case msg.FieldUpdatedAt:
  15323. v, ok := value.(time.Time)
  15324. if !ok {
  15325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15326. }
  15327. m.SetUpdatedAt(v)
  15328. return nil
  15329. case msg.FieldDeletedAt:
  15330. v, ok := value.(time.Time)
  15331. if !ok {
  15332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15333. }
  15334. m.SetDeletedAt(v)
  15335. return nil
  15336. case msg.FieldStatus:
  15337. v, ok := value.(uint8)
  15338. if !ok {
  15339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15340. }
  15341. m.SetStatus(v)
  15342. return nil
  15343. case msg.FieldFromwxid:
  15344. v, ok := value.(string)
  15345. if !ok {
  15346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15347. }
  15348. m.SetFromwxid(v)
  15349. return nil
  15350. case msg.FieldToid:
  15351. v, ok := value.(string)
  15352. if !ok {
  15353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15354. }
  15355. m.SetToid(v)
  15356. return nil
  15357. case msg.FieldMsgtype:
  15358. v, ok := value.(int32)
  15359. if !ok {
  15360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15361. }
  15362. m.SetMsgtype(v)
  15363. return nil
  15364. case msg.FieldMsg:
  15365. v, ok := value.(string)
  15366. if !ok {
  15367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15368. }
  15369. m.SetMsg(v)
  15370. return nil
  15371. case msg.FieldBatchNo:
  15372. v, ok := value.(string)
  15373. if !ok {
  15374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15375. }
  15376. m.SetBatchNo(v)
  15377. return nil
  15378. }
  15379. return fmt.Errorf("unknown Msg field %s", name)
  15380. }
  15381. // AddedFields returns all numeric fields that were incremented/decremented during
  15382. // this mutation.
  15383. func (m *MsgMutation) AddedFields() []string {
  15384. var fields []string
  15385. if m.addstatus != nil {
  15386. fields = append(fields, msg.FieldStatus)
  15387. }
  15388. if m.addmsgtype != nil {
  15389. fields = append(fields, msg.FieldMsgtype)
  15390. }
  15391. return fields
  15392. }
  15393. // AddedField returns the numeric value that was incremented/decremented on a field
  15394. // with the given name. The second boolean return value indicates that this field
  15395. // was not set, or was not defined in the schema.
  15396. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  15397. switch name {
  15398. case msg.FieldStatus:
  15399. return m.AddedStatus()
  15400. case msg.FieldMsgtype:
  15401. return m.AddedMsgtype()
  15402. }
  15403. return nil, false
  15404. }
  15405. // AddField adds the value to the field with the given name. It returns an error if
  15406. // the field is not defined in the schema, or if the type mismatched the field
  15407. // type.
  15408. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  15409. switch name {
  15410. case msg.FieldStatus:
  15411. v, ok := value.(int8)
  15412. if !ok {
  15413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15414. }
  15415. m.AddStatus(v)
  15416. return nil
  15417. case msg.FieldMsgtype:
  15418. v, ok := value.(int32)
  15419. if !ok {
  15420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15421. }
  15422. m.AddMsgtype(v)
  15423. return nil
  15424. }
  15425. return fmt.Errorf("unknown Msg numeric field %s", name)
  15426. }
  15427. // ClearedFields returns all nullable fields that were cleared during this
  15428. // mutation.
  15429. func (m *MsgMutation) ClearedFields() []string {
  15430. var fields []string
  15431. if m.FieldCleared(msg.FieldDeletedAt) {
  15432. fields = append(fields, msg.FieldDeletedAt)
  15433. }
  15434. if m.FieldCleared(msg.FieldStatus) {
  15435. fields = append(fields, msg.FieldStatus)
  15436. }
  15437. if m.FieldCleared(msg.FieldFromwxid) {
  15438. fields = append(fields, msg.FieldFromwxid)
  15439. }
  15440. if m.FieldCleared(msg.FieldToid) {
  15441. fields = append(fields, msg.FieldToid)
  15442. }
  15443. if m.FieldCleared(msg.FieldMsgtype) {
  15444. fields = append(fields, msg.FieldMsgtype)
  15445. }
  15446. if m.FieldCleared(msg.FieldMsg) {
  15447. fields = append(fields, msg.FieldMsg)
  15448. }
  15449. if m.FieldCleared(msg.FieldBatchNo) {
  15450. fields = append(fields, msg.FieldBatchNo)
  15451. }
  15452. return fields
  15453. }
  15454. // FieldCleared returns a boolean indicating if a field with the given name was
  15455. // cleared in this mutation.
  15456. func (m *MsgMutation) FieldCleared(name string) bool {
  15457. _, ok := m.clearedFields[name]
  15458. return ok
  15459. }
  15460. // ClearField clears the value of the field with the given name. It returns an
  15461. // error if the field is not defined in the schema.
  15462. func (m *MsgMutation) ClearField(name string) error {
  15463. switch name {
  15464. case msg.FieldDeletedAt:
  15465. m.ClearDeletedAt()
  15466. return nil
  15467. case msg.FieldStatus:
  15468. m.ClearStatus()
  15469. return nil
  15470. case msg.FieldFromwxid:
  15471. m.ClearFromwxid()
  15472. return nil
  15473. case msg.FieldToid:
  15474. m.ClearToid()
  15475. return nil
  15476. case msg.FieldMsgtype:
  15477. m.ClearMsgtype()
  15478. return nil
  15479. case msg.FieldMsg:
  15480. m.ClearMsg()
  15481. return nil
  15482. case msg.FieldBatchNo:
  15483. m.ClearBatchNo()
  15484. return nil
  15485. }
  15486. return fmt.Errorf("unknown Msg nullable field %s", name)
  15487. }
  15488. // ResetField resets all changes in the mutation for the field with the given name.
  15489. // It returns an error if the field is not defined in the schema.
  15490. func (m *MsgMutation) ResetField(name string) error {
  15491. switch name {
  15492. case msg.FieldCreatedAt:
  15493. m.ResetCreatedAt()
  15494. return nil
  15495. case msg.FieldUpdatedAt:
  15496. m.ResetUpdatedAt()
  15497. return nil
  15498. case msg.FieldDeletedAt:
  15499. m.ResetDeletedAt()
  15500. return nil
  15501. case msg.FieldStatus:
  15502. m.ResetStatus()
  15503. return nil
  15504. case msg.FieldFromwxid:
  15505. m.ResetFromwxid()
  15506. return nil
  15507. case msg.FieldToid:
  15508. m.ResetToid()
  15509. return nil
  15510. case msg.FieldMsgtype:
  15511. m.ResetMsgtype()
  15512. return nil
  15513. case msg.FieldMsg:
  15514. m.ResetMsg()
  15515. return nil
  15516. case msg.FieldBatchNo:
  15517. m.ResetBatchNo()
  15518. return nil
  15519. }
  15520. return fmt.Errorf("unknown Msg field %s", name)
  15521. }
  15522. // AddedEdges returns all edge names that were set/added in this mutation.
  15523. func (m *MsgMutation) AddedEdges() []string {
  15524. edges := make([]string, 0, 0)
  15525. return edges
  15526. }
  15527. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15528. // name in this mutation.
  15529. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  15530. return nil
  15531. }
  15532. // RemovedEdges returns all edge names that were removed in this mutation.
  15533. func (m *MsgMutation) RemovedEdges() []string {
  15534. edges := make([]string, 0, 0)
  15535. return edges
  15536. }
  15537. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15538. // the given name in this mutation.
  15539. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  15540. return nil
  15541. }
  15542. // ClearedEdges returns all edge names that were cleared in this mutation.
  15543. func (m *MsgMutation) ClearedEdges() []string {
  15544. edges := make([]string, 0, 0)
  15545. return edges
  15546. }
  15547. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15548. // was cleared in this mutation.
  15549. func (m *MsgMutation) EdgeCleared(name string) bool {
  15550. return false
  15551. }
  15552. // ClearEdge clears the value of the edge with the given name. It returns an error
  15553. // if that edge is not defined in the schema.
  15554. func (m *MsgMutation) ClearEdge(name string) error {
  15555. return fmt.Errorf("unknown Msg unique edge %s", name)
  15556. }
  15557. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15558. // It returns an error if the edge is not defined in the schema.
  15559. func (m *MsgMutation) ResetEdge(name string) error {
  15560. return fmt.Errorf("unknown Msg edge %s", name)
  15561. }
  15562. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  15563. type ServerMutation struct {
  15564. config
  15565. op Op
  15566. typ string
  15567. id *uint64
  15568. created_at *time.Time
  15569. updated_at *time.Time
  15570. status *uint8
  15571. addstatus *int8
  15572. deleted_at *time.Time
  15573. name *string
  15574. public_ip *string
  15575. private_ip *string
  15576. admin_port *string
  15577. clearedFields map[string]struct{}
  15578. wxs map[uint64]struct{}
  15579. removedwxs map[uint64]struct{}
  15580. clearedwxs bool
  15581. done bool
  15582. oldValue func(context.Context) (*Server, error)
  15583. predicates []predicate.Server
  15584. }
  15585. var _ ent.Mutation = (*ServerMutation)(nil)
  15586. // serverOption allows management of the mutation configuration using functional options.
  15587. type serverOption func(*ServerMutation)
  15588. // newServerMutation creates new mutation for the Server entity.
  15589. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  15590. m := &ServerMutation{
  15591. config: c,
  15592. op: op,
  15593. typ: TypeServer,
  15594. clearedFields: make(map[string]struct{}),
  15595. }
  15596. for _, opt := range opts {
  15597. opt(m)
  15598. }
  15599. return m
  15600. }
  15601. // withServerID sets the ID field of the mutation.
  15602. func withServerID(id uint64) serverOption {
  15603. return func(m *ServerMutation) {
  15604. var (
  15605. err error
  15606. once sync.Once
  15607. value *Server
  15608. )
  15609. m.oldValue = func(ctx context.Context) (*Server, error) {
  15610. once.Do(func() {
  15611. if m.done {
  15612. err = errors.New("querying old values post mutation is not allowed")
  15613. } else {
  15614. value, err = m.Client().Server.Get(ctx, id)
  15615. }
  15616. })
  15617. return value, err
  15618. }
  15619. m.id = &id
  15620. }
  15621. }
  15622. // withServer sets the old Server of the mutation.
  15623. func withServer(node *Server) serverOption {
  15624. return func(m *ServerMutation) {
  15625. m.oldValue = func(context.Context) (*Server, error) {
  15626. return node, nil
  15627. }
  15628. m.id = &node.ID
  15629. }
  15630. }
  15631. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15632. // executed in a transaction (ent.Tx), a transactional client is returned.
  15633. func (m ServerMutation) Client() *Client {
  15634. client := &Client{config: m.config}
  15635. client.init()
  15636. return client
  15637. }
  15638. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15639. // it returns an error otherwise.
  15640. func (m ServerMutation) Tx() (*Tx, error) {
  15641. if _, ok := m.driver.(*txDriver); !ok {
  15642. return nil, errors.New("ent: mutation is not running in a transaction")
  15643. }
  15644. tx := &Tx{config: m.config}
  15645. tx.init()
  15646. return tx, nil
  15647. }
  15648. // SetID sets the value of the id field. Note that this
  15649. // operation is only accepted on creation of Server entities.
  15650. func (m *ServerMutation) SetID(id uint64) {
  15651. m.id = &id
  15652. }
  15653. // ID returns the ID value in the mutation. Note that the ID is only available
  15654. // if it was provided to the builder or after it was returned from the database.
  15655. func (m *ServerMutation) ID() (id uint64, exists bool) {
  15656. if m.id == nil {
  15657. return
  15658. }
  15659. return *m.id, true
  15660. }
  15661. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15662. // That means, if the mutation is applied within a transaction with an isolation level such
  15663. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15664. // or updated by the mutation.
  15665. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  15666. switch {
  15667. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15668. id, exists := m.ID()
  15669. if exists {
  15670. return []uint64{id}, nil
  15671. }
  15672. fallthrough
  15673. case m.op.Is(OpUpdate | OpDelete):
  15674. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  15675. default:
  15676. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15677. }
  15678. }
  15679. // SetCreatedAt sets the "created_at" field.
  15680. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  15681. m.created_at = &t
  15682. }
  15683. // CreatedAt returns the value of the "created_at" field in the mutation.
  15684. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  15685. v := m.created_at
  15686. if v == nil {
  15687. return
  15688. }
  15689. return *v, true
  15690. }
  15691. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  15692. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15694. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15695. if !m.op.Is(OpUpdateOne) {
  15696. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15697. }
  15698. if m.id == nil || m.oldValue == nil {
  15699. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15700. }
  15701. oldValue, err := m.oldValue(ctx)
  15702. if err != nil {
  15703. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15704. }
  15705. return oldValue.CreatedAt, nil
  15706. }
  15707. // ResetCreatedAt resets all changes to the "created_at" field.
  15708. func (m *ServerMutation) ResetCreatedAt() {
  15709. m.created_at = nil
  15710. }
  15711. // SetUpdatedAt sets the "updated_at" field.
  15712. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  15713. m.updated_at = &t
  15714. }
  15715. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15716. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  15717. v := m.updated_at
  15718. if v == nil {
  15719. return
  15720. }
  15721. return *v, true
  15722. }
  15723. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  15724. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15726. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15727. if !m.op.Is(OpUpdateOne) {
  15728. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15729. }
  15730. if m.id == nil || m.oldValue == nil {
  15731. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15732. }
  15733. oldValue, err := m.oldValue(ctx)
  15734. if err != nil {
  15735. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15736. }
  15737. return oldValue.UpdatedAt, nil
  15738. }
  15739. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15740. func (m *ServerMutation) ResetUpdatedAt() {
  15741. m.updated_at = nil
  15742. }
  15743. // SetStatus sets the "status" field.
  15744. func (m *ServerMutation) SetStatus(u uint8) {
  15745. m.status = &u
  15746. m.addstatus = nil
  15747. }
  15748. // Status returns the value of the "status" field in the mutation.
  15749. func (m *ServerMutation) Status() (r uint8, exists bool) {
  15750. v := m.status
  15751. if v == nil {
  15752. return
  15753. }
  15754. return *v, true
  15755. }
  15756. // OldStatus returns the old "status" field's value of the Server entity.
  15757. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15759. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15760. if !m.op.Is(OpUpdateOne) {
  15761. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15762. }
  15763. if m.id == nil || m.oldValue == nil {
  15764. return v, errors.New("OldStatus requires an ID field in the mutation")
  15765. }
  15766. oldValue, err := m.oldValue(ctx)
  15767. if err != nil {
  15768. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15769. }
  15770. return oldValue.Status, nil
  15771. }
  15772. // AddStatus adds u to the "status" field.
  15773. func (m *ServerMutation) AddStatus(u int8) {
  15774. if m.addstatus != nil {
  15775. *m.addstatus += u
  15776. } else {
  15777. m.addstatus = &u
  15778. }
  15779. }
  15780. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15781. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  15782. v := m.addstatus
  15783. if v == nil {
  15784. return
  15785. }
  15786. return *v, true
  15787. }
  15788. // ClearStatus clears the value of the "status" field.
  15789. func (m *ServerMutation) ClearStatus() {
  15790. m.status = nil
  15791. m.addstatus = nil
  15792. m.clearedFields[server.FieldStatus] = struct{}{}
  15793. }
  15794. // StatusCleared returns if the "status" field was cleared in this mutation.
  15795. func (m *ServerMutation) StatusCleared() bool {
  15796. _, ok := m.clearedFields[server.FieldStatus]
  15797. return ok
  15798. }
  15799. // ResetStatus resets all changes to the "status" field.
  15800. func (m *ServerMutation) ResetStatus() {
  15801. m.status = nil
  15802. m.addstatus = nil
  15803. delete(m.clearedFields, server.FieldStatus)
  15804. }
  15805. // SetDeletedAt sets the "deleted_at" field.
  15806. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  15807. m.deleted_at = &t
  15808. }
  15809. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15810. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  15811. v := m.deleted_at
  15812. if v == nil {
  15813. return
  15814. }
  15815. return *v, true
  15816. }
  15817. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  15818. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15820. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15821. if !m.op.Is(OpUpdateOne) {
  15822. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15823. }
  15824. if m.id == nil || m.oldValue == nil {
  15825. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15826. }
  15827. oldValue, err := m.oldValue(ctx)
  15828. if err != nil {
  15829. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15830. }
  15831. return oldValue.DeletedAt, nil
  15832. }
  15833. // ClearDeletedAt clears the value of the "deleted_at" field.
  15834. func (m *ServerMutation) ClearDeletedAt() {
  15835. m.deleted_at = nil
  15836. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  15837. }
  15838. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15839. func (m *ServerMutation) DeletedAtCleared() bool {
  15840. _, ok := m.clearedFields[server.FieldDeletedAt]
  15841. return ok
  15842. }
  15843. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15844. func (m *ServerMutation) ResetDeletedAt() {
  15845. m.deleted_at = nil
  15846. delete(m.clearedFields, server.FieldDeletedAt)
  15847. }
  15848. // SetName sets the "name" field.
  15849. func (m *ServerMutation) SetName(s string) {
  15850. m.name = &s
  15851. }
  15852. // Name returns the value of the "name" field in the mutation.
  15853. func (m *ServerMutation) Name() (r string, exists bool) {
  15854. v := m.name
  15855. if v == nil {
  15856. return
  15857. }
  15858. return *v, true
  15859. }
  15860. // OldName returns the old "name" field's value of the Server entity.
  15861. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15863. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  15864. if !m.op.Is(OpUpdateOne) {
  15865. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15866. }
  15867. if m.id == nil || m.oldValue == nil {
  15868. return v, errors.New("OldName requires an ID field in the mutation")
  15869. }
  15870. oldValue, err := m.oldValue(ctx)
  15871. if err != nil {
  15872. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15873. }
  15874. return oldValue.Name, nil
  15875. }
  15876. // ResetName resets all changes to the "name" field.
  15877. func (m *ServerMutation) ResetName() {
  15878. m.name = nil
  15879. }
  15880. // SetPublicIP sets the "public_ip" field.
  15881. func (m *ServerMutation) SetPublicIP(s string) {
  15882. m.public_ip = &s
  15883. }
  15884. // PublicIP returns the value of the "public_ip" field in the mutation.
  15885. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  15886. v := m.public_ip
  15887. if v == nil {
  15888. return
  15889. }
  15890. return *v, true
  15891. }
  15892. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  15893. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15895. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  15896. if !m.op.Is(OpUpdateOne) {
  15897. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  15898. }
  15899. if m.id == nil || m.oldValue == nil {
  15900. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  15901. }
  15902. oldValue, err := m.oldValue(ctx)
  15903. if err != nil {
  15904. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  15905. }
  15906. return oldValue.PublicIP, nil
  15907. }
  15908. // ResetPublicIP resets all changes to the "public_ip" field.
  15909. func (m *ServerMutation) ResetPublicIP() {
  15910. m.public_ip = nil
  15911. }
  15912. // SetPrivateIP sets the "private_ip" field.
  15913. func (m *ServerMutation) SetPrivateIP(s string) {
  15914. m.private_ip = &s
  15915. }
  15916. // PrivateIP returns the value of the "private_ip" field in the mutation.
  15917. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  15918. v := m.private_ip
  15919. if v == nil {
  15920. return
  15921. }
  15922. return *v, true
  15923. }
  15924. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  15925. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15927. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  15928. if !m.op.Is(OpUpdateOne) {
  15929. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  15930. }
  15931. if m.id == nil || m.oldValue == nil {
  15932. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  15933. }
  15934. oldValue, err := m.oldValue(ctx)
  15935. if err != nil {
  15936. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  15937. }
  15938. return oldValue.PrivateIP, nil
  15939. }
  15940. // ResetPrivateIP resets all changes to the "private_ip" field.
  15941. func (m *ServerMutation) ResetPrivateIP() {
  15942. m.private_ip = nil
  15943. }
  15944. // SetAdminPort sets the "admin_port" field.
  15945. func (m *ServerMutation) SetAdminPort(s string) {
  15946. m.admin_port = &s
  15947. }
  15948. // AdminPort returns the value of the "admin_port" field in the mutation.
  15949. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  15950. v := m.admin_port
  15951. if v == nil {
  15952. return
  15953. }
  15954. return *v, true
  15955. }
  15956. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  15957. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15959. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  15960. if !m.op.Is(OpUpdateOne) {
  15961. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  15962. }
  15963. if m.id == nil || m.oldValue == nil {
  15964. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  15965. }
  15966. oldValue, err := m.oldValue(ctx)
  15967. if err != nil {
  15968. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  15969. }
  15970. return oldValue.AdminPort, nil
  15971. }
  15972. // ResetAdminPort resets all changes to the "admin_port" field.
  15973. func (m *ServerMutation) ResetAdminPort() {
  15974. m.admin_port = nil
  15975. }
  15976. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  15977. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  15978. if m.wxs == nil {
  15979. m.wxs = make(map[uint64]struct{})
  15980. }
  15981. for i := range ids {
  15982. m.wxs[ids[i]] = struct{}{}
  15983. }
  15984. }
  15985. // ClearWxs clears the "wxs" edge to the Wx entity.
  15986. func (m *ServerMutation) ClearWxs() {
  15987. m.clearedwxs = true
  15988. }
  15989. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  15990. func (m *ServerMutation) WxsCleared() bool {
  15991. return m.clearedwxs
  15992. }
  15993. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  15994. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  15995. if m.removedwxs == nil {
  15996. m.removedwxs = make(map[uint64]struct{})
  15997. }
  15998. for i := range ids {
  15999. delete(m.wxs, ids[i])
  16000. m.removedwxs[ids[i]] = struct{}{}
  16001. }
  16002. }
  16003. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  16004. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  16005. for id := range m.removedwxs {
  16006. ids = append(ids, id)
  16007. }
  16008. return
  16009. }
  16010. // WxsIDs returns the "wxs" edge IDs in the mutation.
  16011. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  16012. for id := range m.wxs {
  16013. ids = append(ids, id)
  16014. }
  16015. return
  16016. }
  16017. // ResetWxs resets all changes to the "wxs" edge.
  16018. func (m *ServerMutation) ResetWxs() {
  16019. m.wxs = nil
  16020. m.clearedwxs = false
  16021. m.removedwxs = nil
  16022. }
  16023. // Where appends a list predicates to the ServerMutation builder.
  16024. func (m *ServerMutation) Where(ps ...predicate.Server) {
  16025. m.predicates = append(m.predicates, ps...)
  16026. }
  16027. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  16028. // users can use type-assertion to append predicates that do not depend on any generated package.
  16029. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  16030. p := make([]predicate.Server, len(ps))
  16031. for i := range ps {
  16032. p[i] = ps[i]
  16033. }
  16034. m.Where(p...)
  16035. }
  16036. // Op returns the operation name.
  16037. func (m *ServerMutation) Op() Op {
  16038. return m.op
  16039. }
  16040. // SetOp allows setting the mutation operation.
  16041. func (m *ServerMutation) SetOp(op Op) {
  16042. m.op = op
  16043. }
  16044. // Type returns the node type of this mutation (Server).
  16045. func (m *ServerMutation) Type() string {
  16046. return m.typ
  16047. }
  16048. // Fields returns all fields that were changed during this mutation. Note that in
  16049. // order to get all numeric fields that were incremented/decremented, call
  16050. // AddedFields().
  16051. func (m *ServerMutation) Fields() []string {
  16052. fields := make([]string, 0, 8)
  16053. if m.created_at != nil {
  16054. fields = append(fields, server.FieldCreatedAt)
  16055. }
  16056. if m.updated_at != nil {
  16057. fields = append(fields, server.FieldUpdatedAt)
  16058. }
  16059. if m.status != nil {
  16060. fields = append(fields, server.FieldStatus)
  16061. }
  16062. if m.deleted_at != nil {
  16063. fields = append(fields, server.FieldDeletedAt)
  16064. }
  16065. if m.name != nil {
  16066. fields = append(fields, server.FieldName)
  16067. }
  16068. if m.public_ip != nil {
  16069. fields = append(fields, server.FieldPublicIP)
  16070. }
  16071. if m.private_ip != nil {
  16072. fields = append(fields, server.FieldPrivateIP)
  16073. }
  16074. if m.admin_port != nil {
  16075. fields = append(fields, server.FieldAdminPort)
  16076. }
  16077. return fields
  16078. }
  16079. // Field returns the value of a field with the given name. The second boolean
  16080. // return value indicates that this field was not set, or was not defined in the
  16081. // schema.
  16082. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  16083. switch name {
  16084. case server.FieldCreatedAt:
  16085. return m.CreatedAt()
  16086. case server.FieldUpdatedAt:
  16087. return m.UpdatedAt()
  16088. case server.FieldStatus:
  16089. return m.Status()
  16090. case server.FieldDeletedAt:
  16091. return m.DeletedAt()
  16092. case server.FieldName:
  16093. return m.Name()
  16094. case server.FieldPublicIP:
  16095. return m.PublicIP()
  16096. case server.FieldPrivateIP:
  16097. return m.PrivateIP()
  16098. case server.FieldAdminPort:
  16099. return m.AdminPort()
  16100. }
  16101. return nil, false
  16102. }
  16103. // OldField returns the old value of the field from the database. An error is
  16104. // returned if the mutation operation is not UpdateOne, or the query to the
  16105. // database failed.
  16106. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16107. switch name {
  16108. case server.FieldCreatedAt:
  16109. return m.OldCreatedAt(ctx)
  16110. case server.FieldUpdatedAt:
  16111. return m.OldUpdatedAt(ctx)
  16112. case server.FieldStatus:
  16113. return m.OldStatus(ctx)
  16114. case server.FieldDeletedAt:
  16115. return m.OldDeletedAt(ctx)
  16116. case server.FieldName:
  16117. return m.OldName(ctx)
  16118. case server.FieldPublicIP:
  16119. return m.OldPublicIP(ctx)
  16120. case server.FieldPrivateIP:
  16121. return m.OldPrivateIP(ctx)
  16122. case server.FieldAdminPort:
  16123. return m.OldAdminPort(ctx)
  16124. }
  16125. return nil, fmt.Errorf("unknown Server field %s", name)
  16126. }
  16127. // SetField sets the value of a field with the given name. It returns an error if
  16128. // the field is not defined in the schema, or if the type mismatched the field
  16129. // type.
  16130. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  16131. switch name {
  16132. case server.FieldCreatedAt:
  16133. v, ok := value.(time.Time)
  16134. if !ok {
  16135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16136. }
  16137. m.SetCreatedAt(v)
  16138. return nil
  16139. case server.FieldUpdatedAt:
  16140. v, ok := value.(time.Time)
  16141. if !ok {
  16142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16143. }
  16144. m.SetUpdatedAt(v)
  16145. return nil
  16146. case server.FieldStatus:
  16147. v, ok := value.(uint8)
  16148. if !ok {
  16149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16150. }
  16151. m.SetStatus(v)
  16152. return nil
  16153. case server.FieldDeletedAt:
  16154. v, ok := value.(time.Time)
  16155. if !ok {
  16156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16157. }
  16158. m.SetDeletedAt(v)
  16159. return nil
  16160. case server.FieldName:
  16161. v, ok := value.(string)
  16162. if !ok {
  16163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16164. }
  16165. m.SetName(v)
  16166. return nil
  16167. case server.FieldPublicIP:
  16168. v, ok := value.(string)
  16169. if !ok {
  16170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16171. }
  16172. m.SetPublicIP(v)
  16173. return nil
  16174. case server.FieldPrivateIP:
  16175. v, ok := value.(string)
  16176. if !ok {
  16177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16178. }
  16179. m.SetPrivateIP(v)
  16180. return nil
  16181. case server.FieldAdminPort:
  16182. v, ok := value.(string)
  16183. if !ok {
  16184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16185. }
  16186. m.SetAdminPort(v)
  16187. return nil
  16188. }
  16189. return fmt.Errorf("unknown Server field %s", name)
  16190. }
  16191. // AddedFields returns all numeric fields that were incremented/decremented during
  16192. // this mutation.
  16193. func (m *ServerMutation) AddedFields() []string {
  16194. var fields []string
  16195. if m.addstatus != nil {
  16196. fields = append(fields, server.FieldStatus)
  16197. }
  16198. return fields
  16199. }
  16200. // AddedField returns the numeric value that was incremented/decremented on a field
  16201. // with the given name. The second boolean return value indicates that this field
  16202. // was not set, or was not defined in the schema.
  16203. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  16204. switch name {
  16205. case server.FieldStatus:
  16206. return m.AddedStatus()
  16207. }
  16208. return nil, false
  16209. }
  16210. // AddField adds the value to the field with the given name. It returns an error if
  16211. // the field is not defined in the schema, or if the type mismatched the field
  16212. // type.
  16213. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  16214. switch name {
  16215. case server.FieldStatus:
  16216. v, ok := value.(int8)
  16217. if !ok {
  16218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16219. }
  16220. m.AddStatus(v)
  16221. return nil
  16222. }
  16223. return fmt.Errorf("unknown Server numeric field %s", name)
  16224. }
  16225. // ClearedFields returns all nullable fields that were cleared during this
  16226. // mutation.
  16227. func (m *ServerMutation) ClearedFields() []string {
  16228. var fields []string
  16229. if m.FieldCleared(server.FieldStatus) {
  16230. fields = append(fields, server.FieldStatus)
  16231. }
  16232. if m.FieldCleared(server.FieldDeletedAt) {
  16233. fields = append(fields, server.FieldDeletedAt)
  16234. }
  16235. return fields
  16236. }
  16237. // FieldCleared returns a boolean indicating if a field with the given name was
  16238. // cleared in this mutation.
  16239. func (m *ServerMutation) FieldCleared(name string) bool {
  16240. _, ok := m.clearedFields[name]
  16241. return ok
  16242. }
  16243. // ClearField clears the value of the field with the given name. It returns an
  16244. // error if the field is not defined in the schema.
  16245. func (m *ServerMutation) ClearField(name string) error {
  16246. switch name {
  16247. case server.FieldStatus:
  16248. m.ClearStatus()
  16249. return nil
  16250. case server.FieldDeletedAt:
  16251. m.ClearDeletedAt()
  16252. return nil
  16253. }
  16254. return fmt.Errorf("unknown Server nullable field %s", name)
  16255. }
  16256. // ResetField resets all changes in the mutation for the field with the given name.
  16257. // It returns an error if the field is not defined in the schema.
  16258. func (m *ServerMutation) ResetField(name string) error {
  16259. switch name {
  16260. case server.FieldCreatedAt:
  16261. m.ResetCreatedAt()
  16262. return nil
  16263. case server.FieldUpdatedAt:
  16264. m.ResetUpdatedAt()
  16265. return nil
  16266. case server.FieldStatus:
  16267. m.ResetStatus()
  16268. return nil
  16269. case server.FieldDeletedAt:
  16270. m.ResetDeletedAt()
  16271. return nil
  16272. case server.FieldName:
  16273. m.ResetName()
  16274. return nil
  16275. case server.FieldPublicIP:
  16276. m.ResetPublicIP()
  16277. return nil
  16278. case server.FieldPrivateIP:
  16279. m.ResetPrivateIP()
  16280. return nil
  16281. case server.FieldAdminPort:
  16282. m.ResetAdminPort()
  16283. return nil
  16284. }
  16285. return fmt.Errorf("unknown Server field %s", name)
  16286. }
  16287. // AddedEdges returns all edge names that were set/added in this mutation.
  16288. func (m *ServerMutation) AddedEdges() []string {
  16289. edges := make([]string, 0, 1)
  16290. if m.wxs != nil {
  16291. edges = append(edges, server.EdgeWxs)
  16292. }
  16293. return edges
  16294. }
  16295. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16296. // name in this mutation.
  16297. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  16298. switch name {
  16299. case server.EdgeWxs:
  16300. ids := make([]ent.Value, 0, len(m.wxs))
  16301. for id := range m.wxs {
  16302. ids = append(ids, id)
  16303. }
  16304. return ids
  16305. }
  16306. return nil
  16307. }
  16308. // RemovedEdges returns all edge names that were removed in this mutation.
  16309. func (m *ServerMutation) RemovedEdges() []string {
  16310. edges := make([]string, 0, 1)
  16311. if m.removedwxs != nil {
  16312. edges = append(edges, server.EdgeWxs)
  16313. }
  16314. return edges
  16315. }
  16316. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16317. // the given name in this mutation.
  16318. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  16319. switch name {
  16320. case server.EdgeWxs:
  16321. ids := make([]ent.Value, 0, len(m.removedwxs))
  16322. for id := range m.removedwxs {
  16323. ids = append(ids, id)
  16324. }
  16325. return ids
  16326. }
  16327. return nil
  16328. }
  16329. // ClearedEdges returns all edge names that were cleared in this mutation.
  16330. func (m *ServerMutation) ClearedEdges() []string {
  16331. edges := make([]string, 0, 1)
  16332. if m.clearedwxs {
  16333. edges = append(edges, server.EdgeWxs)
  16334. }
  16335. return edges
  16336. }
  16337. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16338. // was cleared in this mutation.
  16339. func (m *ServerMutation) EdgeCleared(name string) bool {
  16340. switch name {
  16341. case server.EdgeWxs:
  16342. return m.clearedwxs
  16343. }
  16344. return false
  16345. }
  16346. // ClearEdge clears the value of the edge with the given name. It returns an error
  16347. // if that edge is not defined in the schema.
  16348. func (m *ServerMutation) ClearEdge(name string) error {
  16349. switch name {
  16350. }
  16351. return fmt.Errorf("unknown Server unique edge %s", name)
  16352. }
  16353. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16354. // It returns an error if the edge is not defined in the schema.
  16355. func (m *ServerMutation) ResetEdge(name string) error {
  16356. switch name {
  16357. case server.EdgeWxs:
  16358. m.ResetWxs()
  16359. return nil
  16360. }
  16361. return fmt.Errorf("unknown Server edge %s", name)
  16362. }
  16363. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  16364. type SopNodeMutation struct {
  16365. config
  16366. op Op
  16367. typ string
  16368. id *uint64
  16369. created_at *time.Time
  16370. updated_at *time.Time
  16371. status *uint8
  16372. addstatus *int8
  16373. deleted_at *time.Time
  16374. parent_id *uint64
  16375. addparent_id *int64
  16376. name *string
  16377. condition_type *int
  16378. addcondition_type *int
  16379. condition_list *[]string
  16380. appendcondition_list []string
  16381. no_reply_condition *uint64
  16382. addno_reply_condition *int64
  16383. no_reply_unit *string
  16384. action_message *[]custom_types.Action
  16385. appendaction_message []custom_types.Action
  16386. action_label_add *[]uint64
  16387. appendaction_label_add []uint64
  16388. action_label_del *[]uint64
  16389. appendaction_label_del []uint64
  16390. action_forward **custom_types.ActionForward
  16391. clearedFields map[string]struct{}
  16392. sop_stage *uint64
  16393. clearedsop_stage bool
  16394. node_messages map[uint64]struct{}
  16395. removednode_messages map[uint64]struct{}
  16396. clearednode_messages bool
  16397. done bool
  16398. oldValue func(context.Context) (*SopNode, error)
  16399. predicates []predicate.SopNode
  16400. }
  16401. var _ ent.Mutation = (*SopNodeMutation)(nil)
  16402. // sopnodeOption allows management of the mutation configuration using functional options.
  16403. type sopnodeOption func(*SopNodeMutation)
  16404. // newSopNodeMutation creates new mutation for the SopNode entity.
  16405. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  16406. m := &SopNodeMutation{
  16407. config: c,
  16408. op: op,
  16409. typ: TypeSopNode,
  16410. clearedFields: make(map[string]struct{}),
  16411. }
  16412. for _, opt := range opts {
  16413. opt(m)
  16414. }
  16415. return m
  16416. }
  16417. // withSopNodeID sets the ID field of the mutation.
  16418. func withSopNodeID(id uint64) sopnodeOption {
  16419. return func(m *SopNodeMutation) {
  16420. var (
  16421. err error
  16422. once sync.Once
  16423. value *SopNode
  16424. )
  16425. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  16426. once.Do(func() {
  16427. if m.done {
  16428. err = errors.New("querying old values post mutation is not allowed")
  16429. } else {
  16430. value, err = m.Client().SopNode.Get(ctx, id)
  16431. }
  16432. })
  16433. return value, err
  16434. }
  16435. m.id = &id
  16436. }
  16437. }
  16438. // withSopNode sets the old SopNode of the mutation.
  16439. func withSopNode(node *SopNode) sopnodeOption {
  16440. return func(m *SopNodeMutation) {
  16441. m.oldValue = func(context.Context) (*SopNode, error) {
  16442. return node, nil
  16443. }
  16444. m.id = &node.ID
  16445. }
  16446. }
  16447. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16448. // executed in a transaction (ent.Tx), a transactional client is returned.
  16449. func (m SopNodeMutation) Client() *Client {
  16450. client := &Client{config: m.config}
  16451. client.init()
  16452. return client
  16453. }
  16454. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16455. // it returns an error otherwise.
  16456. func (m SopNodeMutation) Tx() (*Tx, error) {
  16457. if _, ok := m.driver.(*txDriver); !ok {
  16458. return nil, errors.New("ent: mutation is not running in a transaction")
  16459. }
  16460. tx := &Tx{config: m.config}
  16461. tx.init()
  16462. return tx, nil
  16463. }
  16464. // SetID sets the value of the id field. Note that this
  16465. // operation is only accepted on creation of SopNode entities.
  16466. func (m *SopNodeMutation) SetID(id uint64) {
  16467. m.id = &id
  16468. }
  16469. // ID returns the ID value in the mutation. Note that the ID is only available
  16470. // if it was provided to the builder or after it was returned from the database.
  16471. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  16472. if m.id == nil {
  16473. return
  16474. }
  16475. return *m.id, true
  16476. }
  16477. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16478. // That means, if the mutation is applied within a transaction with an isolation level such
  16479. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16480. // or updated by the mutation.
  16481. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16482. switch {
  16483. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16484. id, exists := m.ID()
  16485. if exists {
  16486. return []uint64{id}, nil
  16487. }
  16488. fallthrough
  16489. case m.op.Is(OpUpdate | OpDelete):
  16490. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  16491. default:
  16492. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16493. }
  16494. }
  16495. // SetCreatedAt sets the "created_at" field.
  16496. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  16497. m.created_at = &t
  16498. }
  16499. // CreatedAt returns the value of the "created_at" field in the mutation.
  16500. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  16501. v := m.created_at
  16502. if v == nil {
  16503. return
  16504. }
  16505. return *v, true
  16506. }
  16507. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  16508. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16510. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16511. if !m.op.Is(OpUpdateOne) {
  16512. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16513. }
  16514. if m.id == nil || m.oldValue == nil {
  16515. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16516. }
  16517. oldValue, err := m.oldValue(ctx)
  16518. if err != nil {
  16519. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16520. }
  16521. return oldValue.CreatedAt, nil
  16522. }
  16523. // ResetCreatedAt resets all changes to the "created_at" field.
  16524. func (m *SopNodeMutation) ResetCreatedAt() {
  16525. m.created_at = nil
  16526. }
  16527. // SetUpdatedAt sets the "updated_at" field.
  16528. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  16529. m.updated_at = &t
  16530. }
  16531. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16532. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  16533. v := m.updated_at
  16534. if v == nil {
  16535. return
  16536. }
  16537. return *v, true
  16538. }
  16539. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  16540. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16542. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16543. if !m.op.Is(OpUpdateOne) {
  16544. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16545. }
  16546. if m.id == nil || m.oldValue == nil {
  16547. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16548. }
  16549. oldValue, err := m.oldValue(ctx)
  16550. if err != nil {
  16551. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16552. }
  16553. return oldValue.UpdatedAt, nil
  16554. }
  16555. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16556. func (m *SopNodeMutation) ResetUpdatedAt() {
  16557. m.updated_at = nil
  16558. }
  16559. // SetStatus sets the "status" field.
  16560. func (m *SopNodeMutation) SetStatus(u uint8) {
  16561. m.status = &u
  16562. m.addstatus = nil
  16563. }
  16564. // Status returns the value of the "status" field in the mutation.
  16565. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  16566. v := m.status
  16567. if v == nil {
  16568. return
  16569. }
  16570. return *v, true
  16571. }
  16572. // OldStatus returns the old "status" field's value of the SopNode entity.
  16573. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16575. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16576. if !m.op.Is(OpUpdateOne) {
  16577. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16578. }
  16579. if m.id == nil || m.oldValue == nil {
  16580. return v, errors.New("OldStatus requires an ID field in the mutation")
  16581. }
  16582. oldValue, err := m.oldValue(ctx)
  16583. if err != nil {
  16584. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16585. }
  16586. return oldValue.Status, nil
  16587. }
  16588. // AddStatus adds u to the "status" field.
  16589. func (m *SopNodeMutation) AddStatus(u int8) {
  16590. if m.addstatus != nil {
  16591. *m.addstatus += u
  16592. } else {
  16593. m.addstatus = &u
  16594. }
  16595. }
  16596. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16597. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  16598. v := m.addstatus
  16599. if v == nil {
  16600. return
  16601. }
  16602. return *v, true
  16603. }
  16604. // ClearStatus clears the value of the "status" field.
  16605. func (m *SopNodeMutation) ClearStatus() {
  16606. m.status = nil
  16607. m.addstatus = nil
  16608. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  16609. }
  16610. // StatusCleared returns if the "status" field was cleared in this mutation.
  16611. func (m *SopNodeMutation) StatusCleared() bool {
  16612. _, ok := m.clearedFields[sopnode.FieldStatus]
  16613. return ok
  16614. }
  16615. // ResetStatus resets all changes to the "status" field.
  16616. func (m *SopNodeMutation) ResetStatus() {
  16617. m.status = nil
  16618. m.addstatus = nil
  16619. delete(m.clearedFields, sopnode.FieldStatus)
  16620. }
  16621. // SetDeletedAt sets the "deleted_at" field.
  16622. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  16623. m.deleted_at = &t
  16624. }
  16625. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16626. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  16627. v := m.deleted_at
  16628. if v == nil {
  16629. return
  16630. }
  16631. return *v, true
  16632. }
  16633. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  16634. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16636. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16637. if !m.op.Is(OpUpdateOne) {
  16638. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16639. }
  16640. if m.id == nil || m.oldValue == nil {
  16641. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16642. }
  16643. oldValue, err := m.oldValue(ctx)
  16644. if err != nil {
  16645. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16646. }
  16647. return oldValue.DeletedAt, nil
  16648. }
  16649. // ClearDeletedAt clears the value of the "deleted_at" field.
  16650. func (m *SopNodeMutation) ClearDeletedAt() {
  16651. m.deleted_at = nil
  16652. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  16653. }
  16654. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16655. func (m *SopNodeMutation) DeletedAtCleared() bool {
  16656. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  16657. return ok
  16658. }
  16659. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16660. func (m *SopNodeMutation) ResetDeletedAt() {
  16661. m.deleted_at = nil
  16662. delete(m.clearedFields, sopnode.FieldDeletedAt)
  16663. }
  16664. // SetStageID sets the "stage_id" field.
  16665. func (m *SopNodeMutation) SetStageID(u uint64) {
  16666. m.sop_stage = &u
  16667. }
  16668. // StageID returns the value of the "stage_id" field in the mutation.
  16669. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  16670. v := m.sop_stage
  16671. if v == nil {
  16672. return
  16673. }
  16674. return *v, true
  16675. }
  16676. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  16677. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16679. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  16680. if !m.op.Is(OpUpdateOne) {
  16681. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  16682. }
  16683. if m.id == nil || m.oldValue == nil {
  16684. return v, errors.New("OldStageID requires an ID field in the mutation")
  16685. }
  16686. oldValue, err := m.oldValue(ctx)
  16687. if err != nil {
  16688. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  16689. }
  16690. return oldValue.StageID, nil
  16691. }
  16692. // ResetStageID resets all changes to the "stage_id" field.
  16693. func (m *SopNodeMutation) ResetStageID() {
  16694. m.sop_stage = nil
  16695. }
  16696. // SetParentID sets the "parent_id" field.
  16697. func (m *SopNodeMutation) SetParentID(u uint64) {
  16698. m.parent_id = &u
  16699. m.addparent_id = nil
  16700. }
  16701. // ParentID returns the value of the "parent_id" field in the mutation.
  16702. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  16703. v := m.parent_id
  16704. if v == nil {
  16705. return
  16706. }
  16707. return *v, true
  16708. }
  16709. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  16710. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16712. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  16713. if !m.op.Is(OpUpdateOne) {
  16714. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  16715. }
  16716. if m.id == nil || m.oldValue == nil {
  16717. return v, errors.New("OldParentID requires an ID field in the mutation")
  16718. }
  16719. oldValue, err := m.oldValue(ctx)
  16720. if err != nil {
  16721. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  16722. }
  16723. return oldValue.ParentID, nil
  16724. }
  16725. // AddParentID adds u to the "parent_id" field.
  16726. func (m *SopNodeMutation) AddParentID(u int64) {
  16727. if m.addparent_id != nil {
  16728. *m.addparent_id += u
  16729. } else {
  16730. m.addparent_id = &u
  16731. }
  16732. }
  16733. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  16734. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  16735. v := m.addparent_id
  16736. if v == nil {
  16737. return
  16738. }
  16739. return *v, true
  16740. }
  16741. // ResetParentID resets all changes to the "parent_id" field.
  16742. func (m *SopNodeMutation) ResetParentID() {
  16743. m.parent_id = nil
  16744. m.addparent_id = nil
  16745. }
  16746. // SetName sets the "name" field.
  16747. func (m *SopNodeMutation) SetName(s string) {
  16748. m.name = &s
  16749. }
  16750. // Name returns the value of the "name" field in the mutation.
  16751. func (m *SopNodeMutation) Name() (r string, exists bool) {
  16752. v := m.name
  16753. if v == nil {
  16754. return
  16755. }
  16756. return *v, true
  16757. }
  16758. // OldName returns the old "name" field's value of the SopNode entity.
  16759. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16761. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  16762. if !m.op.Is(OpUpdateOne) {
  16763. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16764. }
  16765. if m.id == nil || m.oldValue == nil {
  16766. return v, errors.New("OldName requires an ID field in the mutation")
  16767. }
  16768. oldValue, err := m.oldValue(ctx)
  16769. if err != nil {
  16770. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16771. }
  16772. return oldValue.Name, nil
  16773. }
  16774. // ResetName resets all changes to the "name" field.
  16775. func (m *SopNodeMutation) ResetName() {
  16776. m.name = nil
  16777. }
  16778. // SetConditionType sets the "condition_type" field.
  16779. func (m *SopNodeMutation) SetConditionType(i int) {
  16780. m.condition_type = &i
  16781. m.addcondition_type = nil
  16782. }
  16783. // ConditionType returns the value of the "condition_type" field in the mutation.
  16784. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  16785. v := m.condition_type
  16786. if v == nil {
  16787. return
  16788. }
  16789. return *v, true
  16790. }
  16791. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  16792. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16794. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  16795. if !m.op.Is(OpUpdateOne) {
  16796. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  16797. }
  16798. if m.id == nil || m.oldValue == nil {
  16799. return v, errors.New("OldConditionType requires an ID field in the mutation")
  16800. }
  16801. oldValue, err := m.oldValue(ctx)
  16802. if err != nil {
  16803. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  16804. }
  16805. return oldValue.ConditionType, nil
  16806. }
  16807. // AddConditionType adds i to the "condition_type" field.
  16808. func (m *SopNodeMutation) AddConditionType(i int) {
  16809. if m.addcondition_type != nil {
  16810. *m.addcondition_type += i
  16811. } else {
  16812. m.addcondition_type = &i
  16813. }
  16814. }
  16815. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  16816. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  16817. v := m.addcondition_type
  16818. if v == nil {
  16819. return
  16820. }
  16821. return *v, true
  16822. }
  16823. // ResetConditionType resets all changes to the "condition_type" field.
  16824. func (m *SopNodeMutation) ResetConditionType() {
  16825. m.condition_type = nil
  16826. m.addcondition_type = nil
  16827. }
  16828. // SetConditionList sets the "condition_list" field.
  16829. func (m *SopNodeMutation) SetConditionList(s []string) {
  16830. m.condition_list = &s
  16831. m.appendcondition_list = nil
  16832. }
  16833. // ConditionList returns the value of the "condition_list" field in the mutation.
  16834. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  16835. v := m.condition_list
  16836. if v == nil {
  16837. return
  16838. }
  16839. return *v, true
  16840. }
  16841. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  16842. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16844. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  16845. if !m.op.Is(OpUpdateOne) {
  16846. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  16847. }
  16848. if m.id == nil || m.oldValue == nil {
  16849. return v, errors.New("OldConditionList requires an ID field in the mutation")
  16850. }
  16851. oldValue, err := m.oldValue(ctx)
  16852. if err != nil {
  16853. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  16854. }
  16855. return oldValue.ConditionList, nil
  16856. }
  16857. // AppendConditionList adds s to the "condition_list" field.
  16858. func (m *SopNodeMutation) AppendConditionList(s []string) {
  16859. m.appendcondition_list = append(m.appendcondition_list, s...)
  16860. }
  16861. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  16862. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  16863. if len(m.appendcondition_list) == 0 {
  16864. return nil, false
  16865. }
  16866. return m.appendcondition_list, true
  16867. }
  16868. // ClearConditionList clears the value of the "condition_list" field.
  16869. func (m *SopNodeMutation) ClearConditionList() {
  16870. m.condition_list = nil
  16871. m.appendcondition_list = nil
  16872. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  16873. }
  16874. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  16875. func (m *SopNodeMutation) ConditionListCleared() bool {
  16876. _, ok := m.clearedFields[sopnode.FieldConditionList]
  16877. return ok
  16878. }
  16879. // ResetConditionList resets all changes to the "condition_list" field.
  16880. func (m *SopNodeMutation) ResetConditionList() {
  16881. m.condition_list = nil
  16882. m.appendcondition_list = nil
  16883. delete(m.clearedFields, sopnode.FieldConditionList)
  16884. }
  16885. // SetNoReplyCondition sets the "no_reply_condition" field.
  16886. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  16887. m.no_reply_condition = &u
  16888. m.addno_reply_condition = nil
  16889. }
  16890. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  16891. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  16892. v := m.no_reply_condition
  16893. if v == nil {
  16894. return
  16895. }
  16896. return *v, true
  16897. }
  16898. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  16899. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16901. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  16902. if !m.op.Is(OpUpdateOne) {
  16903. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  16904. }
  16905. if m.id == nil || m.oldValue == nil {
  16906. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  16907. }
  16908. oldValue, err := m.oldValue(ctx)
  16909. if err != nil {
  16910. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  16911. }
  16912. return oldValue.NoReplyCondition, nil
  16913. }
  16914. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  16915. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  16916. if m.addno_reply_condition != nil {
  16917. *m.addno_reply_condition += u
  16918. } else {
  16919. m.addno_reply_condition = &u
  16920. }
  16921. }
  16922. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  16923. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  16924. v := m.addno_reply_condition
  16925. if v == nil {
  16926. return
  16927. }
  16928. return *v, true
  16929. }
  16930. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  16931. func (m *SopNodeMutation) ResetNoReplyCondition() {
  16932. m.no_reply_condition = nil
  16933. m.addno_reply_condition = nil
  16934. }
  16935. // SetNoReplyUnit sets the "no_reply_unit" field.
  16936. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  16937. m.no_reply_unit = &s
  16938. }
  16939. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  16940. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  16941. v := m.no_reply_unit
  16942. if v == nil {
  16943. return
  16944. }
  16945. return *v, true
  16946. }
  16947. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  16948. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16950. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  16951. if !m.op.Is(OpUpdateOne) {
  16952. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  16953. }
  16954. if m.id == nil || m.oldValue == nil {
  16955. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  16956. }
  16957. oldValue, err := m.oldValue(ctx)
  16958. if err != nil {
  16959. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  16960. }
  16961. return oldValue.NoReplyUnit, nil
  16962. }
  16963. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  16964. func (m *SopNodeMutation) ResetNoReplyUnit() {
  16965. m.no_reply_unit = nil
  16966. }
  16967. // SetActionMessage sets the "action_message" field.
  16968. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  16969. m.action_message = &ct
  16970. m.appendaction_message = nil
  16971. }
  16972. // ActionMessage returns the value of the "action_message" field in the mutation.
  16973. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  16974. v := m.action_message
  16975. if v == nil {
  16976. return
  16977. }
  16978. return *v, true
  16979. }
  16980. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  16981. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16983. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  16984. if !m.op.Is(OpUpdateOne) {
  16985. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  16986. }
  16987. if m.id == nil || m.oldValue == nil {
  16988. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  16989. }
  16990. oldValue, err := m.oldValue(ctx)
  16991. if err != nil {
  16992. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  16993. }
  16994. return oldValue.ActionMessage, nil
  16995. }
  16996. // AppendActionMessage adds ct to the "action_message" field.
  16997. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  16998. m.appendaction_message = append(m.appendaction_message, ct...)
  16999. }
  17000. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  17001. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  17002. if len(m.appendaction_message) == 0 {
  17003. return nil, false
  17004. }
  17005. return m.appendaction_message, true
  17006. }
  17007. // ClearActionMessage clears the value of the "action_message" field.
  17008. func (m *SopNodeMutation) ClearActionMessage() {
  17009. m.action_message = nil
  17010. m.appendaction_message = nil
  17011. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  17012. }
  17013. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17014. func (m *SopNodeMutation) ActionMessageCleared() bool {
  17015. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  17016. return ok
  17017. }
  17018. // ResetActionMessage resets all changes to the "action_message" field.
  17019. func (m *SopNodeMutation) ResetActionMessage() {
  17020. m.action_message = nil
  17021. m.appendaction_message = nil
  17022. delete(m.clearedFields, sopnode.FieldActionMessage)
  17023. }
  17024. // SetActionLabelAdd sets the "action_label_add" field.
  17025. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  17026. m.action_label_add = &u
  17027. m.appendaction_label_add = nil
  17028. }
  17029. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17030. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17031. v := m.action_label_add
  17032. if v == nil {
  17033. return
  17034. }
  17035. return *v, true
  17036. }
  17037. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  17038. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17040. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17041. if !m.op.Is(OpUpdateOne) {
  17042. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17043. }
  17044. if m.id == nil || m.oldValue == nil {
  17045. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17046. }
  17047. oldValue, err := m.oldValue(ctx)
  17048. if err != nil {
  17049. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17050. }
  17051. return oldValue.ActionLabelAdd, nil
  17052. }
  17053. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17054. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  17055. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17056. }
  17057. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17058. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17059. if len(m.appendaction_label_add) == 0 {
  17060. return nil, false
  17061. }
  17062. return m.appendaction_label_add, true
  17063. }
  17064. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17065. func (m *SopNodeMutation) ClearActionLabelAdd() {
  17066. m.action_label_add = nil
  17067. m.appendaction_label_add = nil
  17068. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  17069. }
  17070. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17071. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  17072. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  17073. return ok
  17074. }
  17075. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17076. func (m *SopNodeMutation) ResetActionLabelAdd() {
  17077. m.action_label_add = nil
  17078. m.appendaction_label_add = nil
  17079. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  17080. }
  17081. // SetActionLabelDel sets the "action_label_del" field.
  17082. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  17083. m.action_label_del = &u
  17084. m.appendaction_label_del = nil
  17085. }
  17086. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17087. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  17088. v := m.action_label_del
  17089. if v == nil {
  17090. return
  17091. }
  17092. return *v, true
  17093. }
  17094. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  17095. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17097. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17098. if !m.op.Is(OpUpdateOne) {
  17099. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17100. }
  17101. if m.id == nil || m.oldValue == nil {
  17102. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17103. }
  17104. oldValue, err := m.oldValue(ctx)
  17105. if err != nil {
  17106. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17107. }
  17108. return oldValue.ActionLabelDel, nil
  17109. }
  17110. // AppendActionLabelDel adds u to the "action_label_del" field.
  17111. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  17112. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17113. }
  17114. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17115. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17116. if len(m.appendaction_label_del) == 0 {
  17117. return nil, false
  17118. }
  17119. return m.appendaction_label_del, true
  17120. }
  17121. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17122. func (m *SopNodeMutation) ClearActionLabelDel() {
  17123. m.action_label_del = nil
  17124. m.appendaction_label_del = nil
  17125. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  17126. }
  17127. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17128. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  17129. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  17130. return ok
  17131. }
  17132. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17133. func (m *SopNodeMutation) ResetActionLabelDel() {
  17134. m.action_label_del = nil
  17135. m.appendaction_label_del = nil
  17136. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  17137. }
  17138. // SetActionForward sets the "action_forward" field.
  17139. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17140. m.action_forward = &ctf
  17141. }
  17142. // ActionForward returns the value of the "action_forward" field in the mutation.
  17143. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17144. v := m.action_forward
  17145. if v == nil {
  17146. return
  17147. }
  17148. return *v, true
  17149. }
  17150. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  17151. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17153. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17154. if !m.op.Is(OpUpdateOne) {
  17155. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17156. }
  17157. if m.id == nil || m.oldValue == nil {
  17158. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17159. }
  17160. oldValue, err := m.oldValue(ctx)
  17161. if err != nil {
  17162. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17163. }
  17164. return oldValue.ActionForward, nil
  17165. }
  17166. // ClearActionForward clears the value of the "action_forward" field.
  17167. func (m *SopNodeMutation) ClearActionForward() {
  17168. m.action_forward = nil
  17169. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  17170. }
  17171. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17172. func (m *SopNodeMutation) ActionForwardCleared() bool {
  17173. _, ok := m.clearedFields[sopnode.FieldActionForward]
  17174. return ok
  17175. }
  17176. // ResetActionForward resets all changes to the "action_forward" field.
  17177. func (m *SopNodeMutation) ResetActionForward() {
  17178. m.action_forward = nil
  17179. delete(m.clearedFields, sopnode.FieldActionForward)
  17180. }
  17181. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17182. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  17183. m.sop_stage = &id
  17184. }
  17185. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17186. func (m *SopNodeMutation) ClearSopStage() {
  17187. m.clearedsop_stage = true
  17188. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  17189. }
  17190. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17191. func (m *SopNodeMutation) SopStageCleared() bool {
  17192. return m.clearedsop_stage
  17193. }
  17194. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17195. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  17196. if m.sop_stage != nil {
  17197. return *m.sop_stage, true
  17198. }
  17199. return
  17200. }
  17201. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17202. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17203. // SopStageID instead. It exists only for internal usage by the builders.
  17204. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  17205. if id := m.sop_stage; id != nil {
  17206. ids = append(ids, *id)
  17207. }
  17208. return
  17209. }
  17210. // ResetSopStage resets all changes to the "sop_stage" edge.
  17211. func (m *SopNodeMutation) ResetSopStage() {
  17212. m.sop_stage = nil
  17213. m.clearedsop_stage = false
  17214. }
  17215. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  17216. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  17217. if m.node_messages == nil {
  17218. m.node_messages = make(map[uint64]struct{})
  17219. }
  17220. for i := range ids {
  17221. m.node_messages[ids[i]] = struct{}{}
  17222. }
  17223. }
  17224. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  17225. func (m *SopNodeMutation) ClearNodeMessages() {
  17226. m.clearednode_messages = true
  17227. }
  17228. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  17229. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  17230. return m.clearednode_messages
  17231. }
  17232. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  17233. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  17234. if m.removednode_messages == nil {
  17235. m.removednode_messages = make(map[uint64]struct{})
  17236. }
  17237. for i := range ids {
  17238. delete(m.node_messages, ids[i])
  17239. m.removednode_messages[ids[i]] = struct{}{}
  17240. }
  17241. }
  17242. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  17243. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  17244. for id := range m.removednode_messages {
  17245. ids = append(ids, id)
  17246. }
  17247. return
  17248. }
  17249. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  17250. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  17251. for id := range m.node_messages {
  17252. ids = append(ids, id)
  17253. }
  17254. return
  17255. }
  17256. // ResetNodeMessages resets all changes to the "node_messages" edge.
  17257. func (m *SopNodeMutation) ResetNodeMessages() {
  17258. m.node_messages = nil
  17259. m.clearednode_messages = false
  17260. m.removednode_messages = nil
  17261. }
  17262. // Where appends a list predicates to the SopNodeMutation builder.
  17263. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  17264. m.predicates = append(m.predicates, ps...)
  17265. }
  17266. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  17267. // users can use type-assertion to append predicates that do not depend on any generated package.
  17268. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  17269. p := make([]predicate.SopNode, len(ps))
  17270. for i := range ps {
  17271. p[i] = ps[i]
  17272. }
  17273. m.Where(p...)
  17274. }
  17275. // Op returns the operation name.
  17276. func (m *SopNodeMutation) Op() Op {
  17277. return m.op
  17278. }
  17279. // SetOp allows setting the mutation operation.
  17280. func (m *SopNodeMutation) SetOp(op Op) {
  17281. m.op = op
  17282. }
  17283. // Type returns the node type of this mutation (SopNode).
  17284. func (m *SopNodeMutation) Type() string {
  17285. return m.typ
  17286. }
  17287. // Fields returns all fields that were changed during this mutation. Note that in
  17288. // order to get all numeric fields that were incremented/decremented, call
  17289. // AddedFields().
  17290. func (m *SopNodeMutation) Fields() []string {
  17291. fields := make([]string, 0, 15)
  17292. if m.created_at != nil {
  17293. fields = append(fields, sopnode.FieldCreatedAt)
  17294. }
  17295. if m.updated_at != nil {
  17296. fields = append(fields, sopnode.FieldUpdatedAt)
  17297. }
  17298. if m.status != nil {
  17299. fields = append(fields, sopnode.FieldStatus)
  17300. }
  17301. if m.deleted_at != nil {
  17302. fields = append(fields, sopnode.FieldDeletedAt)
  17303. }
  17304. if m.sop_stage != nil {
  17305. fields = append(fields, sopnode.FieldStageID)
  17306. }
  17307. if m.parent_id != nil {
  17308. fields = append(fields, sopnode.FieldParentID)
  17309. }
  17310. if m.name != nil {
  17311. fields = append(fields, sopnode.FieldName)
  17312. }
  17313. if m.condition_type != nil {
  17314. fields = append(fields, sopnode.FieldConditionType)
  17315. }
  17316. if m.condition_list != nil {
  17317. fields = append(fields, sopnode.FieldConditionList)
  17318. }
  17319. if m.no_reply_condition != nil {
  17320. fields = append(fields, sopnode.FieldNoReplyCondition)
  17321. }
  17322. if m.no_reply_unit != nil {
  17323. fields = append(fields, sopnode.FieldNoReplyUnit)
  17324. }
  17325. if m.action_message != nil {
  17326. fields = append(fields, sopnode.FieldActionMessage)
  17327. }
  17328. if m.action_label_add != nil {
  17329. fields = append(fields, sopnode.FieldActionLabelAdd)
  17330. }
  17331. if m.action_label_del != nil {
  17332. fields = append(fields, sopnode.FieldActionLabelDel)
  17333. }
  17334. if m.action_forward != nil {
  17335. fields = append(fields, sopnode.FieldActionForward)
  17336. }
  17337. return fields
  17338. }
  17339. // Field returns the value of a field with the given name. The second boolean
  17340. // return value indicates that this field was not set, or was not defined in the
  17341. // schema.
  17342. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  17343. switch name {
  17344. case sopnode.FieldCreatedAt:
  17345. return m.CreatedAt()
  17346. case sopnode.FieldUpdatedAt:
  17347. return m.UpdatedAt()
  17348. case sopnode.FieldStatus:
  17349. return m.Status()
  17350. case sopnode.FieldDeletedAt:
  17351. return m.DeletedAt()
  17352. case sopnode.FieldStageID:
  17353. return m.StageID()
  17354. case sopnode.FieldParentID:
  17355. return m.ParentID()
  17356. case sopnode.FieldName:
  17357. return m.Name()
  17358. case sopnode.FieldConditionType:
  17359. return m.ConditionType()
  17360. case sopnode.FieldConditionList:
  17361. return m.ConditionList()
  17362. case sopnode.FieldNoReplyCondition:
  17363. return m.NoReplyCondition()
  17364. case sopnode.FieldNoReplyUnit:
  17365. return m.NoReplyUnit()
  17366. case sopnode.FieldActionMessage:
  17367. return m.ActionMessage()
  17368. case sopnode.FieldActionLabelAdd:
  17369. return m.ActionLabelAdd()
  17370. case sopnode.FieldActionLabelDel:
  17371. return m.ActionLabelDel()
  17372. case sopnode.FieldActionForward:
  17373. return m.ActionForward()
  17374. }
  17375. return nil, false
  17376. }
  17377. // OldField returns the old value of the field from the database. An error is
  17378. // returned if the mutation operation is not UpdateOne, or the query to the
  17379. // database failed.
  17380. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17381. switch name {
  17382. case sopnode.FieldCreatedAt:
  17383. return m.OldCreatedAt(ctx)
  17384. case sopnode.FieldUpdatedAt:
  17385. return m.OldUpdatedAt(ctx)
  17386. case sopnode.FieldStatus:
  17387. return m.OldStatus(ctx)
  17388. case sopnode.FieldDeletedAt:
  17389. return m.OldDeletedAt(ctx)
  17390. case sopnode.FieldStageID:
  17391. return m.OldStageID(ctx)
  17392. case sopnode.FieldParentID:
  17393. return m.OldParentID(ctx)
  17394. case sopnode.FieldName:
  17395. return m.OldName(ctx)
  17396. case sopnode.FieldConditionType:
  17397. return m.OldConditionType(ctx)
  17398. case sopnode.FieldConditionList:
  17399. return m.OldConditionList(ctx)
  17400. case sopnode.FieldNoReplyCondition:
  17401. return m.OldNoReplyCondition(ctx)
  17402. case sopnode.FieldNoReplyUnit:
  17403. return m.OldNoReplyUnit(ctx)
  17404. case sopnode.FieldActionMessage:
  17405. return m.OldActionMessage(ctx)
  17406. case sopnode.FieldActionLabelAdd:
  17407. return m.OldActionLabelAdd(ctx)
  17408. case sopnode.FieldActionLabelDel:
  17409. return m.OldActionLabelDel(ctx)
  17410. case sopnode.FieldActionForward:
  17411. return m.OldActionForward(ctx)
  17412. }
  17413. return nil, fmt.Errorf("unknown SopNode field %s", name)
  17414. }
  17415. // SetField sets the value of a field with the given name. It returns an error if
  17416. // the field is not defined in the schema, or if the type mismatched the field
  17417. // type.
  17418. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  17419. switch name {
  17420. case sopnode.FieldCreatedAt:
  17421. v, ok := value.(time.Time)
  17422. if !ok {
  17423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17424. }
  17425. m.SetCreatedAt(v)
  17426. return nil
  17427. case sopnode.FieldUpdatedAt:
  17428. v, ok := value.(time.Time)
  17429. if !ok {
  17430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17431. }
  17432. m.SetUpdatedAt(v)
  17433. return nil
  17434. case sopnode.FieldStatus:
  17435. v, ok := value.(uint8)
  17436. if !ok {
  17437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17438. }
  17439. m.SetStatus(v)
  17440. return nil
  17441. case sopnode.FieldDeletedAt:
  17442. v, ok := value.(time.Time)
  17443. if !ok {
  17444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17445. }
  17446. m.SetDeletedAt(v)
  17447. return nil
  17448. case sopnode.FieldStageID:
  17449. v, ok := value.(uint64)
  17450. if !ok {
  17451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17452. }
  17453. m.SetStageID(v)
  17454. return nil
  17455. case sopnode.FieldParentID:
  17456. v, ok := value.(uint64)
  17457. if !ok {
  17458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17459. }
  17460. m.SetParentID(v)
  17461. return nil
  17462. case sopnode.FieldName:
  17463. v, ok := value.(string)
  17464. if !ok {
  17465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17466. }
  17467. m.SetName(v)
  17468. return nil
  17469. case sopnode.FieldConditionType:
  17470. v, ok := value.(int)
  17471. if !ok {
  17472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17473. }
  17474. m.SetConditionType(v)
  17475. return nil
  17476. case sopnode.FieldConditionList:
  17477. v, ok := value.([]string)
  17478. if !ok {
  17479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17480. }
  17481. m.SetConditionList(v)
  17482. return nil
  17483. case sopnode.FieldNoReplyCondition:
  17484. v, ok := value.(uint64)
  17485. if !ok {
  17486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17487. }
  17488. m.SetNoReplyCondition(v)
  17489. return nil
  17490. case sopnode.FieldNoReplyUnit:
  17491. v, ok := value.(string)
  17492. if !ok {
  17493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17494. }
  17495. m.SetNoReplyUnit(v)
  17496. return nil
  17497. case sopnode.FieldActionMessage:
  17498. v, ok := value.([]custom_types.Action)
  17499. if !ok {
  17500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17501. }
  17502. m.SetActionMessage(v)
  17503. return nil
  17504. case sopnode.FieldActionLabelAdd:
  17505. v, ok := value.([]uint64)
  17506. if !ok {
  17507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17508. }
  17509. m.SetActionLabelAdd(v)
  17510. return nil
  17511. case sopnode.FieldActionLabelDel:
  17512. v, ok := value.([]uint64)
  17513. if !ok {
  17514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17515. }
  17516. m.SetActionLabelDel(v)
  17517. return nil
  17518. case sopnode.FieldActionForward:
  17519. v, ok := value.(*custom_types.ActionForward)
  17520. if !ok {
  17521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17522. }
  17523. m.SetActionForward(v)
  17524. return nil
  17525. }
  17526. return fmt.Errorf("unknown SopNode field %s", name)
  17527. }
  17528. // AddedFields returns all numeric fields that were incremented/decremented during
  17529. // this mutation.
  17530. func (m *SopNodeMutation) AddedFields() []string {
  17531. var fields []string
  17532. if m.addstatus != nil {
  17533. fields = append(fields, sopnode.FieldStatus)
  17534. }
  17535. if m.addparent_id != nil {
  17536. fields = append(fields, sopnode.FieldParentID)
  17537. }
  17538. if m.addcondition_type != nil {
  17539. fields = append(fields, sopnode.FieldConditionType)
  17540. }
  17541. if m.addno_reply_condition != nil {
  17542. fields = append(fields, sopnode.FieldNoReplyCondition)
  17543. }
  17544. return fields
  17545. }
  17546. // AddedField returns the numeric value that was incremented/decremented on a field
  17547. // with the given name. The second boolean return value indicates that this field
  17548. // was not set, or was not defined in the schema.
  17549. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  17550. switch name {
  17551. case sopnode.FieldStatus:
  17552. return m.AddedStatus()
  17553. case sopnode.FieldParentID:
  17554. return m.AddedParentID()
  17555. case sopnode.FieldConditionType:
  17556. return m.AddedConditionType()
  17557. case sopnode.FieldNoReplyCondition:
  17558. return m.AddedNoReplyCondition()
  17559. }
  17560. return nil, false
  17561. }
  17562. // AddField adds the value to the field with the given name. It returns an error if
  17563. // the field is not defined in the schema, or if the type mismatched the field
  17564. // type.
  17565. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  17566. switch name {
  17567. case sopnode.FieldStatus:
  17568. v, ok := value.(int8)
  17569. if !ok {
  17570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17571. }
  17572. m.AddStatus(v)
  17573. return nil
  17574. case sopnode.FieldParentID:
  17575. v, ok := value.(int64)
  17576. if !ok {
  17577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17578. }
  17579. m.AddParentID(v)
  17580. return nil
  17581. case sopnode.FieldConditionType:
  17582. v, ok := value.(int)
  17583. if !ok {
  17584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17585. }
  17586. m.AddConditionType(v)
  17587. return nil
  17588. case sopnode.FieldNoReplyCondition:
  17589. v, ok := value.(int64)
  17590. if !ok {
  17591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17592. }
  17593. m.AddNoReplyCondition(v)
  17594. return nil
  17595. }
  17596. return fmt.Errorf("unknown SopNode numeric field %s", name)
  17597. }
  17598. // ClearedFields returns all nullable fields that were cleared during this
  17599. // mutation.
  17600. func (m *SopNodeMutation) ClearedFields() []string {
  17601. var fields []string
  17602. if m.FieldCleared(sopnode.FieldStatus) {
  17603. fields = append(fields, sopnode.FieldStatus)
  17604. }
  17605. if m.FieldCleared(sopnode.FieldDeletedAt) {
  17606. fields = append(fields, sopnode.FieldDeletedAt)
  17607. }
  17608. if m.FieldCleared(sopnode.FieldConditionList) {
  17609. fields = append(fields, sopnode.FieldConditionList)
  17610. }
  17611. if m.FieldCleared(sopnode.FieldActionMessage) {
  17612. fields = append(fields, sopnode.FieldActionMessage)
  17613. }
  17614. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  17615. fields = append(fields, sopnode.FieldActionLabelAdd)
  17616. }
  17617. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  17618. fields = append(fields, sopnode.FieldActionLabelDel)
  17619. }
  17620. if m.FieldCleared(sopnode.FieldActionForward) {
  17621. fields = append(fields, sopnode.FieldActionForward)
  17622. }
  17623. return fields
  17624. }
  17625. // FieldCleared returns a boolean indicating if a field with the given name was
  17626. // cleared in this mutation.
  17627. func (m *SopNodeMutation) FieldCleared(name string) bool {
  17628. _, ok := m.clearedFields[name]
  17629. return ok
  17630. }
  17631. // ClearField clears the value of the field with the given name. It returns an
  17632. // error if the field is not defined in the schema.
  17633. func (m *SopNodeMutation) ClearField(name string) error {
  17634. switch name {
  17635. case sopnode.FieldStatus:
  17636. m.ClearStatus()
  17637. return nil
  17638. case sopnode.FieldDeletedAt:
  17639. m.ClearDeletedAt()
  17640. return nil
  17641. case sopnode.FieldConditionList:
  17642. m.ClearConditionList()
  17643. return nil
  17644. case sopnode.FieldActionMessage:
  17645. m.ClearActionMessage()
  17646. return nil
  17647. case sopnode.FieldActionLabelAdd:
  17648. m.ClearActionLabelAdd()
  17649. return nil
  17650. case sopnode.FieldActionLabelDel:
  17651. m.ClearActionLabelDel()
  17652. return nil
  17653. case sopnode.FieldActionForward:
  17654. m.ClearActionForward()
  17655. return nil
  17656. }
  17657. return fmt.Errorf("unknown SopNode nullable field %s", name)
  17658. }
  17659. // ResetField resets all changes in the mutation for the field with the given name.
  17660. // It returns an error if the field is not defined in the schema.
  17661. func (m *SopNodeMutation) ResetField(name string) error {
  17662. switch name {
  17663. case sopnode.FieldCreatedAt:
  17664. m.ResetCreatedAt()
  17665. return nil
  17666. case sopnode.FieldUpdatedAt:
  17667. m.ResetUpdatedAt()
  17668. return nil
  17669. case sopnode.FieldStatus:
  17670. m.ResetStatus()
  17671. return nil
  17672. case sopnode.FieldDeletedAt:
  17673. m.ResetDeletedAt()
  17674. return nil
  17675. case sopnode.FieldStageID:
  17676. m.ResetStageID()
  17677. return nil
  17678. case sopnode.FieldParentID:
  17679. m.ResetParentID()
  17680. return nil
  17681. case sopnode.FieldName:
  17682. m.ResetName()
  17683. return nil
  17684. case sopnode.FieldConditionType:
  17685. m.ResetConditionType()
  17686. return nil
  17687. case sopnode.FieldConditionList:
  17688. m.ResetConditionList()
  17689. return nil
  17690. case sopnode.FieldNoReplyCondition:
  17691. m.ResetNoReplyCondition()
  17692. return nil
  17693. case sopnode.FieldNoReplyUnit:
  17694. m.ResetNoReplyUnit()
  17695. return nil
  17696. case sopnode.FieldActionMessage:
  17697. m.ResetActionMessage()
  17698. return nil
  17699. case sopnode.FieldActionLabelAdd:
  17700. m.ResetActionLabelAdd()
  17701. return nil
  17702. case sopnode.FieldActionLabelDel:
  17703. m.ResetActionLabelDel()
  17704. return nil
  17705. case sopnode.FieldActionForward:
  17706. m.ResetActionForward()
  17707. return nil
  17708. }
  17709. return fmt.Errorf("unknown SopNode field %s", name)
  17710. }
  17711. // AddedEdges returns all edge names that were set/added in this mutation.
  17712. func (m *SopNodeMutation) AddedEdges() []string {
  17713. edges := make([]string, 0, 2)
  17714. if m.sop_stage != nil {
  17715. edges = append(edges, sopnode.EdgeSopStage)
  17716. }
  17717. if m.node_messages != nil {
  17718. edges = append(edges, sopnode.EdgeNodeMessages)
  17719. }
  17720. return edges
  17721. }
  17722. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17723. // name in this mutation.
  17724. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  17725. switch name {
  17726. case sopnode.EdgeSopStage:
  17727. if id := m.sop_stage; id != nil {
  17728. return []ent.Value{*id}
  17729. }
  17730. case sopnode.EdgeNodeMessages:
  17731. ids := make([]ent.Value, 0, len(m.node_messages))
  17732. for id := range m.node_messages {
  17733. ids = append(ids, id)
  17734. }
  17735. return ids
  17736. }
  17737. return nil
  17738. }
  17739. // RemovedEdges returns all edge names that were removed in this mutation.
  17740. func (m *SopNodeMutation) RemovedEdges() []string {
  17741. edges := make([]string, 0, 2)
  17742. if m.removednode_messages != nil {
  17743. edges = append(edges, sopnode.EdgeNodeMessages)
  17744. }
  17745. return edges
  17746. }
  17747. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17748. // the given name in this mutation.
  17749. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  17750. switch name {
  17751. case sopnode.EdgeNodeMessages:
  17752. ids := make([]ent.Value, 0, len(m.removednode_messages))
  17753. for id := range m.removednode_messages {
  17754. ids = append(ids, id)
  17755. }
  17756. return ids
  17757. }
  17758. return nil
  17759. }
  17760. // ClearedEdges returns all edge names that were cleared in this mutation.
  17761. func (m *SopNodeMutation) ClearedEdges() []string {
  17762. edges := make([]string, 0, 2)
  17763. if m.clearedsop_stage {
  17764. edges = append(edges, sopnode.EdgeSopStage)
  17765. }
  17766. if m.clearednode_messages {
  17767. edges = append(edges, sopnode.EdgeNodeMessages)
  17768. }
  17769. return edges
  17770. }
  17771. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17772. // was cleared in this mutation.
  17773. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  17774. switch name {
  17775. case sopnode.EdgeSopStage:
  17776. return m.clearedsop_stage
  17777. case sopnode.EdgeNodeMessages:
  17778. return m.clearednode_messages
  17779. }
  17780. return false
  17781. }
  17782. // ClearEdge clears the value of the edge with the given name. It returns an error
  17783. // if that edge is not defined in the schema.
  17784. func (m *SopNodeMutation) ClearEdge(name string) error {
  17785. switch name {
  17786. case sopnode.EdgeSopStage:
  17787. m.ClearSopStage()
  17788. return nil
  17789. }
  17790. return fmt.Errorf("unknown SopNode unique edge %s", name)
  17791. }
  17792. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17793. // It returns an error if the edge is not defined in the schema.
  17794. func (m *SopNodeMutation) ResetEdge(name string) error {
  17795. switch name {
  17796. case sopnode.EdgeSopStage:
  17797. m.ResetSopStage()
  17798. return nil
  17799. case sopnode.EdgeNodeMessages:
  17800. m.ResetNodeMessages()
  17801. return nil
  17802. }
  17803. return fmt.Errorf("unknown SopNode edge %s", name)
  17804. }
  17805. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  17806. type SopStageMutation struct {
  17807. config
  17808. op Op
  17809. typ string
  17810. id *uint64
  17811. created_at *time.Time
  17812. updated_at *time.Time
  17813. status *uint8
  17814. addstatus *int8
  17815. deleted_at *time.Time
  17816. name *string
  17817. condition_type *int
  17818. addcondition_type *int
  17819. condition_operator *int
  17820. addcondition_operator *int
  17821. condition_list *[]custom_types.Condition
  17822. appendcondition_list []custom_types.Condition
  17823. action_message *[]custom_types.Action
  17824. appendaction_message []custom_types.Action
  17825. action_label_add *[]uint64
  17826. appendaction_label_add []uint64
  17827. action_label_del *[]uint64
  17828. appendaction_label_del []uint64
  17829. action_forward **custom_types.ActionForward
  17830. index_sort *int
  17831. addindex_sort *int
  17832. clearedFields map[string]struct{}
  17833. sop_task *uint64
  17834. clearedsop_task bool
  17835. stage_nodes map[uint64]struct{}
  17836. removedstage_nodes map[uint64]struct{}
  17837. clearedstage_nodes bool
  17838. stage_messages map[uint64]struct{}
  17839. removedstage_messages map[uint64]struct{}
  17840. clearedstage_messages bool
  17841. done bool
  17842. oldValue func(context.Context) (*SopStage, error)
  17843. predicates []predicate.SopStage
  17844. }
  17845. var _ ent.Mutation = (*SopStageMutation)(nil)
  17846. // sopstageOption allows management of the mutation configuration using functional options.
  17847. type sopstageOption func(*SopStageMutation)
  17848. // newSopStageMutation creates new mutation for the SopStage entity.
  17849. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  17850. m := &SopStageMutation{
  17851. config: c,
  17852. op: op,
  17853. typ: TypeSopStage,
  17854. clearedFields: make(map[string]struct{}),
  17855. }
  17856. for _, opt := range opts {
  17857. opt(m)
  17858. }
  17859. return m
  17860. }
  17861. // withSopStageID sets the ID field of the mutation.
  17862. func withSopStageID(id uint64) sopstageOption {
  17863. return func(m *SopStageMutation) {
  17864. var (
  17865. err error
  17866. once sync.Once
  17867. value *SopStage
  17868. )
  17869. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  17870. once.Do(func() {
  17871. if m.done {
  17872. err = errors.New("querying old values post mutation is not allowed")
  17873. } else {
  17874. value, err = m.Client().SopStage.Get(ctx, id)
  17875. }
  17876. })
  17877. return value, err
  17878. }
  17879. m.id = &id
  17880. }
  17881. }
  17882. // withSopStage sets the old SopStage of the mutation.
  17883. func withSopStage(node *SopStage) sopstageOption {
  17884. return func(m *SopStageMutation) {
  17885. m.oldValue = func(context.Context) (*SopStage, error) {
  17886. return node, nil
  17887. }
  17888. m.id = &node.ID
  17889. }
  17890. }
  17891. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17892. // executed in a transaction (ent.Tx), a transactional client is returned.
  17893. func (m SopStageMutation) Client() *Client {
  17894. client := &Client{config: m.config}
  17895. client.init()
  17896. return client
  17897. }
  17898. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17899. // it returns an error otherwise.
  17900. func (m SopStageMutation) Tx() (*Tx, error) {
  17901. if _, ok := m.driver.(*txDriver); !ok {
  17902. return nil, errors.New("ent: mutation is not running in a transaction")
  17903. }
  17904. tx := &Tx{config: m.config}
  17905. tx.init()
  17906. return tx, nil
  17907. }
  17908. // SetID sets the value of the id field. Note that this
  17909. // operation is only accepted on creation of SopStage entities.
  17910. func (m *SopStageMutation) SetID(id uint64) {
  17911. m.id = &id
  17912. }
  17913. // ID returns the ID value in the mutation. Note that the ID is only available
  17914. // if it was provided to the builder or after it was returned from the database.
  17915. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  17916. if m.id == nil {
  17917. return
  17918. }
  17919. return *m.id, true
  17920. }
  17921. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17922. // That means, if the mutation is applied within a transaction with an isolation level such
  17923. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17924. // or updated by the mutation.
  17925. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  17926. switch {
  17927. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17928. id, exists := m.ID()
  17929. if exists {
  17930. return []uint64{id}, nil
  17931. }
  17932. fallthrough
  17933. case m.op.Is(OpUpdate | OpDelete):
  17934. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  17935. default:
  17936. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17937. }
  17938. }
  17939. // SetCreatedAt sets the "created_at" field.
  17940. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  17941. m.created_at = &t
  17942. }
  17943. // CreatedAt returns the value of the "created_at" field in the mutation.
  17944. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  17945. v := m.created_at
  17946. if v == nil {
  17947. return
  17948. }
  17949. return *v, true
  17950. }
  17951. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  17952. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17954. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17955. if !m.op.Is(OpUpdateOne) {
  17956. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17957. }
  17958. if m.id == nil || m.oldValue == nil {
  17959. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17960. }
  17961. oldValue, err := m.oldValue(ctx)
  17962. if err != nil {
  17963. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17964. }
  17965. return oldValue.CreatedAt, nil
  17966. }
  17967. // ResetCreatedAt resets all changes to the "created_at" field.
  17968. func (m *SopStageMutation) ResetCreatedAt() {
  17969. m.created_at = nil
  17970. }
  17971. // SetUpdatedAt sets the "updated_at" field.
  17972. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  17973. m.updated_at = &t
  17974. }
  17975. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17976. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  17977. v := m.updated_at
  17978. if v == nil {
  17979. return
  17980. }
  17981. return *v, true
  17982. }
  17983. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  17984. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17986. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17987. if !m.op.Is(OpUpdateOne) {
  17988. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17989. }
  17990. if m.id == nil || m.oldValue == nil {
  17991. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17992. }
  17993. oldValue, err := m.oldValue(ctx)
  17994. if err != nil {
  17995. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17996. }
  17997. return oldValue.UpdatedAt, nil
  17998. }
  17999. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18000. func (m *SopStageMutation) ResetUpdatedAt() {
  18001. m.updated_at = nil
  18002. }
  18003. // SetStatus sets the "status" field.
  18004. func (m *SopStageMutation) SetStatus(u uint8) {
  18005. m.status = &u
  18006. m.addstatus = nil
  18007. }
  18008. // Status returns the value of the "status" field in the mutation.
  18009. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  18010. v := m.status
  18011. if v == nil {
  18012. return
  18013. }
  18014. return *v, true
  18015. }
  18016. // OldStatus returns the old "status" field's value of the SopStage entity.
  18017. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18019. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18020. if !m.op.Is(OpUpdateOne) {
  18021. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18022. }
  18023. if m.id == nil || m.oldValue == nil {
  18024. return v, errors.New("OldStatus requires an ID field in the mutation")
  18025. }
  18026. oldValue, err := m.oldValue(ctx)
  18027. if err != nil {
  18028. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18029. }
  18030. return oldValue.Status, nil
  18031. }
  18032. // AddStatus adds u to the "status" field.
  18033. func (m *SopStageMutation) AddStatus(u int8) {
  18034. if m.addstatus != nil {
  18035. *m.addstatus += u
  18036. } else {
  18037. m.addstatus = &u
  18038. }
  18039. }
  18040. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18041. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  18042. v := m.addstatus
  18043. if v == nil {
  18044. return
  18045. }
  18046. return *v, true
  18047. }
  18048. // ClearStatus clears the value of the "status" field.
  18049. func (m *SopStageMutation) ClearStatus() {
  18050. m.status = nil
  18051. m.addstatus = nil
  18052. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  18053. }
  18054. // StatusCleared returns if the "status" field was cleared in this mutation.
  18055. func (m *SopStageMutation) StatusCleared() bool {
  18056. _, ok := m.clearedFields[sopstage.FieldStatus]
  18057. return ok
  18058. }
  18059. // ResetStatus resets all changes to the "status" field.
  18060. func (m *SopStageMutation) ResetStatus() {
  18061. m.status = nil
  18062. m.addstatus = nil
  18063. delete(m.clearedFields, sopstage.FieldStatus)
  18064. }
  18065. // SetDeletedAt sets the "deleted_at" field.
  18066. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  18067. m.deleted_at = &t
  18068. }
  18069. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18070. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  18071. v := m.deleted_at
  18072. if v == nil {
  18073. return
  18074. }
  18075. return *v, true
  18076. }
  18077. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  18078. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18080. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18081. if !m.op.Is(OpUpdateOne) {
  18082. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18083. }
  18084. if m.id == nil || m.oldValue == nil {
  18085. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18086. }
  18087. oldValue, err := m.oldValue(ctx)
  18088. if err != nil {
  18089. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18090. }
  18091. return oldValue.DeletedAt, nil
  18092. }
  18093. // ClearDeletedAt clears the value of the "deleted_at" field.
  18094. func (m *SopStageMutation) ClearDeletedAt() {
  18095. m.deleted_at = nil
  18096. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  18097. }
  18098. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18099. func (m *SopStageMutation) DeletedAtCleared() bool {
  18100. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  18101. return ok
  18102. }
  18103. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18104. func (m *SopStageMutation) ResetDeletedAt() {
  18105. m.deleted_at = nil
  18106. delete(m.clearedFields, sopstage.FieldDeletedAt)
  18107. }
  18108. // SetTaskID sets the "task_id" field.
  18109. func (m *SopStageMutation) SetTaskID(u uint64) {
  18110. m.sop_task = &u
  18111. }
  18112. // TaskID returns the value of the "task_id" field in the mutation.
  18113. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  18114. v := m.sop_task
  18115. if v == nil {
  18116. return
  18117. }
  18118. return *v, true
  18119. }
  18120. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  18121. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18123. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  18124. if !m.op.Is(OpUpdateOne) {
  18125. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  18126. }
  18127. if m.id == nil || m.oldValue == nil {
  18128. return v, errors.New("OldTaskID requires an ID field in the mutation")
  18129. }
  18130. oldValue, err := m.oldValue(ctx)
  18131. if err != nil {
  18132. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  18133. }
  18134. return oldValue.TaskID, nil
  18135. }
  18136. // ResetTaskID resets all changes to the "task_id" field.
  18137. func (m *SopStageMutation) ResetTaskID() {
  18138. m.sop_task = nil
  18139. }
  18140. // SetName sets the "name" field.
  18141. func (m *SopStageMutation) SetName(s string) {
  18142. m.name = &s
  18143. }
  18144. // Name returns the value of the "name" field in the mutation.
  18145. func (m *SopStageMutation) Name() (r string, exists bool) {
  18146. v := m.name
  18147. if v == nil {
  18148. return
  18149. }
  18150. return *v, true
  18151. }
  18152. // OldName returns the old "name" field's value of the SopStage entity.
  18153. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18155. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  18156. if !m.op.Is(OpUpdateOne) {
  18157. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18158. }
  18159. if m.id == nil || m.oldValue == nil {
  18160. return v, errors.New("OldName requires an ID field in the mutation")
  18161. }
  18162. oldValue, err := m.oldValue(ctx)
  18163. if err != nil {
  18164. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18165. }
  18166. return oldValue.Name, nil
  18167. }
  18168. // ResetName resets all changes to the "name" field.
  18169. func (m *SopStageMutation) ResetName() {
  18170. m.name = nil
  18171. }
  18172. // SetConditionType sets the "condition_type" field.
  18173. func (m *SopStageMutation) SetConditionType(i int) {
  18174. m.condition_type = &i
  18175. m.addcondition_type = nil
  18176. }
  18177. // ConditionType returns the value of the "condition_type" field in the mutation.
  18178. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  18179. v := m.condition_type
  18180. if v == nil {
  18181. return
  18182. }
  18183. return *v, true
  18184. }
  18185. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  18186. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18188. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18189. if !m.op.Is(OpUpdateOne) {
  18190. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18191. }
  18192. if m.id == nil || m.oldValue == nil {
  18193. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18194. }
  18195. oldValue, err := m.oldValue(ctx)
  18196. if err != nil {
  18197. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18198. }
  18199. return oldValue.ConditionType, nil
  18200. }
  18201. // AddConditionType adds i to the "condition_type" field.
  18202. func (m *SopStageMutation) AddConditionType(i int) {
  18203. if m.addcondition_type != nil {
  18204. *m.addcondition_type += i
  18205. } else {
  18206. m.addcondition_type = &i
  18207. }
  18208. }
  18209. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18210. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  18211. v := m.addcondition_type
  18212. if v == nil {
  18213. return
  18214. }
  18215. return *v, true
  18216. }
  18217. // ResetConditionType resets all changes to the "condition_type" field.
  18218. func (m *SopStageMutation) ResetConditionType() {
  18219. m.condition_type = nil
  18220. m.addcondition_type = nil
  18221. }
  18222. // SetConditionOperator sets the "condition_operator" field.
  18223. func (m *SopStageMutation) SetConditionOperator(i int) {
  18224. m.condition_operator = &i
  18225. m.addcondition_operator = nil
  18226. }
  18227. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  18228. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  18229. v := m.condition_operator
  18230. if v == nil {
  18231. return
  18232. }
  18233. return *v, true
  18234. }
  18235. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  18236. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18238. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  18239. if !m.op.Is(OpUpdateOne) {
  18240. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  18241. }
  18242. if m.id == nil || m.oldValue == nil {
  18243. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  18244. }
  18245. oldValue, err := m.oldValue(ctx)
  18246. if err != nil {
  18247. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  18248. }
  18249. return oldValue.ConditionOperator, nil
  18250. }
  18251. // AddConditionOperator adds i to the "condition_operator" field.
  18252. func (m *SopStageMutation) AddConditionOperator(i int) {
  18253. if m.addcondition_operator != nil {
  18254. *m.addcondition_operator += i
  18255. } else {
  18256. m.addcondition_operator = &i
  18257. }
  18258. }
  18259. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  18260. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  18261. v := m.addcondition_operator
  18262. if v == nil {
  18263. return
  18264. }
  18265. return *v, true
  18266. }
  18267. // ResetConditionOperator resets all changes to the "condition_operator" field.
  18268. func (m *SopStageMutation) ResetConditionOperator() {
  18269. m.condition_operator = nil
  18270. m.addcondition_operator = nil
  18271. }
  18272. // SetConditionList sets the "condition_list" field.
  18273. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  18274. m.condition_list = &ct
  18275. m.appendcondition_list = nil
  18276. }
  18277. // ConditionList returns the value of the "condition_list" field in the mutation.
  18278. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  18279. v := m.condition_list
  18280. if v == nil {
  18281. return
  18282. }
  18283. return *v, true
  18284. }
  18285. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  18286. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18288. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  18289. if !m.op.Is(OpUpdateOne) {
  18290. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  18291. }
  18292. if m.id == nil || m.oldValue == nil {
  18293. return v, errors.New("OldConditionList requires an ID field in the mutation")
  18294. }
  18295. oldValue, err := m.oldValue(ctx)
  18296. if err != nil {
  18297. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  18298. }
  18299. return oldValue.ConditionList, nil
  18300. }
  18301. // AppendConditionList adds ct to the "condition_list" field.
  18302. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  18303. m.appendcondition_list = append(m.appendcondition_list, ct...)
  18304. }
  18305. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  18306. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  18307. if len(m.appendcondition_list) == 0 {
  18308. return nil, false
  18309. }
  18310. return m.appendcondition_list, true
  18311. }
  18312. // ResetConditionList resets all changes to the "condition_list" field.
  18313. func (m *SopStageMutation) ResetConditionList() {
  18314. m.condition_list = nil
  18315. m.appendcondition_list = nil
  18316. }
  18317. // SetActionMessage sets the "action_message" field.
  18318. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  18319. m.action_message = &ct
  18320. m.appendaction_message = nil
  18321. }
  18322. // ActionMessage returns the value of the "action_message" field in the mutation.
  18323. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  18324. v := m.action_message
  18325. if v == nil {
  18326. return
  18327. }
  18328. return *v, true
  18329. }
  18330. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  18331. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18333. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  18334. if !m.op.Is(OpUpdateOne) {
  18335. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  18336. }
  18337. if m.id == nil || m.oldValue == nil {
  18338. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  18339. }
  18340. oldValue, err := m.oldValue(ctx)
  18341. if err != nil {
  18342. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  18343. }
  18344. return oldValue.ActionMessage, nil
  18345. }
  18346. // AppendActionMessage adds ct to the "action_message" field.
  18347. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  18348. m.appendaction_message = append(m.appendaction_message, ct...)
  18349. }
  18350. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  18351. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  18352. if len(m.appendaction_message) == 0 {
  18353. return nil, false
  18354. }
  18355. return m.appendaction_message, true
  18356. }
  18357. // ClearActionMessage clears the value of the "action_message" field.
  18358. func (m *SopStageMutation) ClearActionMessage() {
  18359. m.action_message = nil
  18360. m.appendaction_message = nil
  18361. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  18362. }
  18363. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  18364. func (m *SopStageMutation) ActionMessageCleared() bool {
  18365. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  18366. return ok
  18367. }
  18368. // ResetActionMessage resets all changes to the "action_message" field.
  18369. func (m *SopStageMutation) ResetActionMessage() {
  18370. m.action_message = nil
  18371. m.appendaction_message = nil
  18372. delete(m.clearedFields, sopstage.FieldActionMessage)
  18373. }
  18374. // SetActionLabelAdd sets the "action_label_add" field.
  18375. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  18376. m.action_label_add = &u
  18377. m.appendaction_label_add = nil
  18378. }
  18379. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18380. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18381. v := m.action_label_add
  18382. if v == nil {
  18383. return
  18384. }
  18385. return *v, true
  18386. }
  18387. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  18388. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18390. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18391. if !m.op.Is(OpUpdateOne) {
  18392. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18393. }
  18394. if m.id == nil || m.oldValue == nil {
  18395. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18396. }
  18397. oldValue, err := m.oldValue(ctx)
  18398. if err != nil {
  18399. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18400. }
  18401. return oldValue.ActionLabelAdd, nil
  18402. }
  18403. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18404. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  18405. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18406. }
  18407. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18408. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18409. if len(m.appendaction_label_add) == 0 {
  18410. return nil, false
  18411. }
  18412. return m.appendaction_label_add, true
  18413. }
  18414. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18415. func (m *SopStageMutation) ClearActionLabelAdd() {
  18416. m.action_label_add = nil
  18417. m.appendaction_label_add = nil
  18418. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  18419. }
  18420. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18421. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  18422. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  18423. return ok
  18424. }
  18425. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18426. func (m *SopStageMutation) ResetActionLabelAdd() {
  18427. m.action_label_add = nil
  18428. m.appendaction_label_add = nil
  18429. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  18430. }
  18431. // SetActionLabelDel sets the "action_label_del" field.
  18432. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  18433. m.action_label_del = &u
  18434. m.appendaction_label_del = nil
  18435. }
  18436. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18437. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  18438. v := m.action_label_del
  18439. if v == nil {
  18440. return
  18441. }
  18442. return *v, true
  18443. }
  18444. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  18445. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18447. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18448. if !m.op.Is(OpUpdateOne) {
  18449. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18450. }
  18451. if m.id == nil || m.oldValue == nil {
  18452. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18453. }
  18454. oldValue, err := m.oldValue(ctx)
  18455. if err != nil {
  18456. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18457. }
  18458. return oldValue.ActionLabelDel, nil
  18459. }
  18460. // AppendActionLabelDel adds u to the "action_label_del" field.
  18461. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  18462. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18463. }
  18464. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18465. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18466. if len(m.appendaction_label_del) == 0 {
  18467. return nil, false
  18468. }
  18469. return m.appendaction_label_del, true
  18470. }
  18471. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18472. func (m *SopStageMutation) ClearActionLabelDel() {
  18473. m.action_label_del = nil
  18474. m.appendaction_label_del = nil
  18475. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  18476. }
  18477. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18478. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  18479. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  18480. return ok
  18481. }
  18482. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18483. func (m *SopStageMutation) ResetActionLabelDel() {
  18484. m.action_label_del = nil
  18485. m.appendaction_label_del = nil
  18486. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  18487. }
  18488. // SetActionForward sets the "action_forward" field.
  18489. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18490. m.action_forward = &ctf
  18491. }
  18492. // ActionForward returns the value of the "action_forward" field in the mutation.
  18493. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18494. v := m.action_forward
  18495. if v == nil {
  18496. return
  18497. }
  18498. return *v, true
  18499. }
  18500. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  18501. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18503. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18504. if !m.op.Is(OpUpdateOne) {
  18505. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18506. }
  18507. if m.id == nil || m.oldValue == nil {
  18508. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18509. }
  18510. oldValue, err := m.oldValue(ctx)
  18511. if err != nil {
  18512. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18513. }
  18514. return oldValue.ActionForward, nil
  18515. }
  18516. // ClearActionForward clears the value of the "action_forward" field.
  18517. func (m *SopStageMutation) ClearActionForward() {
  18518. m.action_forward = nil
  18519. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  18520. }
  18521. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18522. func (m *SopStageMutation) ActionForwardCleared() bool {
  18523. _, ok := m.clearedFields[sopstage.FieldActionForward]
  18524. return ok
  18525. }
  18526. // ResetActionForward resets all changes to the "action_forward" field.
  18527. func (m *SopStageMutation) ResetActionForward() {
  18528. m.action_forward = nil
  18529. delete(m.clearedFields, sopstage.FieldActionForward)
  18530. }
  18531. // SetIndexSort sets the "index_sort" field.
  18532. func (m *SopStageMutation) SetIndexSort(i int) {
  18533. m.index_sort = &i
  18534. m.addindex_sort = nil
  18535. }
  18536. // IndexSort returns the value of the "index_sort" field in the mutation.
  18537. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  18538. v := m.index_sort
  18539. if v == nil {
  18540. return
  18541. }
  18542. return *v, true
  18543. }
  18544. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  18545. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18547. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  18548. if !m.op.Is(OpUpdateOne) {
  18549. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  18550. }
  18551. if m.id == nil || m.oldValue == nil {
  18552. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  18553. }
  18554. oldValue, err := m.oldValue(ctx)
  18555. if err != nil {
  18556. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  18557. }
  18558. return oldValue.IndexSort, nil
  18559. }
  18560. // AddIndexSort adds i to the "index_sort" field.
  18561. func (m *SopStageMutation) AddIndexSort(i int) {
  18562. if m.addindex_sort != nil {
  18563. *m.addindex_sort += i
  18564. } else {
  18565. m.addindex_sort = &i
  18566. }
  18567. }
  18568. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  18569. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  18570. v := m.addindex_sort
  18571. if v == nil {
  18572. return
  18573. }
  18574. return *v, true
  18575. }
  18576. // ClearIndexSort clears the value of the "index_sort" field.
  18577. func (m *SopStageMutation) ClearIndexSort() {
  18578. m.index_sort = nil
  18579. m.addindex_sort = nil
  18580. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  18581. }
  18582. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  18583. func (m *SopStageMutation) IndexSortCleared() bool {
  18584. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  18585. return ok
  18586. }
  18587. // ResetIndexSort resets all changes to the "index_sort" field.
  18588. func (m *SopStageMutation) ResetIndexSort() {
  18589. m.index_sort = nil
  18590. m.addindex_sort = nil
  18591. delete(m.clearedFields, sopstage.FieldIndexSort)
  18592. }
  18593. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  18594. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  18595. m.sop_task = &id
  18596. }
  18597. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  18598. func (m *SopStageMutation) ClearSopTask() {
  18599. m.clearedsop_task = true
  18600. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  18601. }
  18602. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  18603. func (m *SopStageMutation) SopTaskCleared() bool {
  18604. return m.clearedsop_task
  18605. }
  18606. // SopTaskID returns the "sop_task" edge ID in the mutation.
  18607. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  18608. if m.sop_task != nil {
  18609. return *m.sop_task, true
  18610. }
  18611. return
  18612. }
  18613. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  18614. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18615. // SopTaskID instead. It exists only for internal usage by the builders.
  18616. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  18617. if id := m.sop_task; id != nil {
  18618. ids = append(ids, *id)
  18619. }
  18620. return
  18621. }
  18622. // ResetSopTask resets all changes to the "sop_task" edge.
  18623. func (m *SopStageMutation) ResetSopTask() {
  18624. m.sop_task = nil
  18625. m.clearedsop_task = false
  18626. }
  18627. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  18628. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  18629. if m.stage_nodes == nil {
  18630. m.stage_nodes = make(map[uint64]struct{})
  18631. }
  18632. for i := range ids {
  18633. m.stage_nodes[ids[i]] = struct{}{}
  18634. }
  18635. }
  18636. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  18637. func (m *SopStageMutation) ClearStageNodes() {
  18638. m.clearedstage_nodes = true
  18639. }
  18640. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  18641. func (m *SopStageMutation) StageNodesCleared() bool {
  18642. return m.clearedstage_nodes
  18643. }
  18644. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  18645. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  18646. if m.removedstage_nodes == nil {
  18647. m.removedstage_nodes = make(map[uint64]struct{})
  18648. }
  18649. for i := range ids {
  18650. delete(m.stage_nodes, ids[i])
  18651. m.removedstage_nodes[ids[i]] = struct{}{}
  18652. }
  18653. }
  18654. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  18655. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  18656. for id := range m.removedstage_nodes {
  18657. ids = append(ids, id)
  18658. }
  18659. return
  18660. }
  18661. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  18662. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  18663. for id := range m.stage_nodes {
  18664. ids = append(ids, id)
  18665. }
  18666. return
  18667. }
  18668. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  18669. func (m *SopStageMutation) ResetStageNodes() {
  18670. m.stage_nodes = nil
  18671. m.clearedstage_nodes = false
  18672. m.removedstage_nodes = nil
  18673. }
  18674. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  18675. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  18676. if m.stage_messages == nil {
  18677. m.stage_messages = make(map[uint64]struct{})
  18678. }
  18679. for i := range ids {
  18680. m.stage_messages[ids[i]] = struct{}{}
  18681. }
  18682. }
  18683. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  18684. func (m *SopStageMutation) ClearStageMessages() {
  18685. m.clearedstage_messages = true
  18686. }
  18687. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  18688. func (m *SopStageMutation) StageMessagesCleared() bool {
  18689. return m.clearedstage_messages
  18690. }
  18691. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  18692. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  18693. if m.removedstage_messages == nil {
  18694. m.removedstage_messages = make(map[uint64]struct{})
  18695. }
  18696. for i := range ids {
  18697. delete(m.stage_messages, ids[i])
  18698. m.removedstage_messages[ids[i]] = struct{}{}
  18699. }
  18700. }
  18701. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  18702. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  18703. for id := range m.removedstage_messages {
  18704. ids = append(ids, id)
  18705. }
  18706. return
  18707. }
  18708. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  18709. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  18710. for id := range m.stage_messages {
  18711. ids = append(ids, id)
  18712. }
  18713. return
  18714. }
  18715. // ResetStageMessages resets all changes to the "stage_messages" edge.
  18716. func (m *SopStageMutation) ResetStageMessages() {
  18717. m.stage_messages = nil
  18718. m.clearedstage_messages = false
  18719. m.removedstage_messages = nil
  18720. }
  18721. // Where appends a list predicates to the SopStageMutation builder.
  18722. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  18723. m.predicates = append(m.predicates, ps...)
  18724. }
  18725. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  18726. // users can use type-assertion to append predicates that do not depend on any generated package.
  18727. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  18728. p := make([]predicate.SopStage, len(ps))
  18729. for i := range ps {
  18730. p[i] = ps[i]
  18731. }
  18732. m.Where(p...)
  18733. }
  18734. // Op returns the operation name.
  18735. func (m *SopStageMutation) Op() Op {
  18736. return m.op
  18737. }
  18738. // SetOp allows setting the mutation operation.
  18739. func (m *SopStageMutation) SetOp(op Op) {
  18740. m.op = op
  18741. }
  18742. // Type returns the node type of this mutation (SopStage).
  18743. func (m *SopStageMutation) Type() string {
  18744. return m.typ
  18745. }
  18746. // Fields returns all fields that were changed during this mutation. Note that in
  18747. // order to get all numeric fields that were incremented/decremented, call
  18748. // AddedFields().
  18749. func (m *SopStageMutation) Fields() []string {
  18750. fields := make([]string, 0, 14)
  18751. if m.created_at != nil {
  18752. fields = append(fields, sopstage.FieldCreatedAt)
  18753. }
  18754. if m.updated_at != nil {
  18755. fields = append(fields, sopstage.FieldUpdatedAt)
  18756. }
  18757. if m.status != nil {
  18758. fields = append(fields, sopstage.FieldStatus)
  18759. }
  18760. if m.deleted_at != nil {
  18761. fields = append(fields, sopstage.FieldDeletedAt)
  18762. }
  18763. if m.sop_task != nil {
  18764. fields = append(fields, sopstage.FieldTaskID)
  18765. }
  18766. if m.name != nil {
  18767. fields = append(fields, sopstage.FieldName)
  18768. }
  18769. if m.condition_type != nil {
  18770. fields = append(fields, sopstage.FieldConditionType)
  18771. }
  18772. if m.condition_operator != nil {
  18773. fields = append(fields, sopstage.FieldConditionOperator)
  18774. }
  18775. if m.condition_list != nil {
  18776. fields = append(fields, sopstage.FieldConditionList)
  18777. }
  18778. if m.action_message != nil {
  18779. fields = append(fields, sopstage.FieldActionMessage)
  18780. }
  18781. if m.action_label_add != nil {
  18782. fields = append(fields, sopstage.FieldActionLabelAdd)
  18783. }
  18784. if m.action_label_del != nil {
  18785. fields = append(fields, sopstage.FieldActionLabelDel)
  18786. }
  18787. if m.action_forward != nil {
  18788. fields = append(fields, sopstage.FieldActionForward)
  18789. }
  18790. if m.index_sort != nil {
  18791. fields = append(fields, sopstage.FieldIndexSort)
  18792. }
  18793. return fields
  18794. }
  18795. // Field returns the value of a field with the given name. The second boolean
  18796. // return value indicates that this field was not set, or was not defined in the
  18797. // schema.
  18798. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  18799. switch name {
  18800. case sopstage.FieldCreatedAt:
  18801. return m.CreatedAt()
  18802. case sopstage.FieldUpdatedAt:
  18803. return m.UpdatedAt()
  18804. case sopstage.FieldStatus:
  18805. return m.Status()
  18806. case sopstage.FieldDeletedAt:
  18807. return m.DeletedAt()
  18808. case sopstage.FieldTaskID:
  18809. return m.TaskID()
  18810. case sopstage.FieldName:
  18811. return m.Name()
  18812. case sopstage.FieldConditionType:
  18813. return m.ConditionType()
  18814. case sopstage.FieldConditionOperator:
  18815. return m.ConditionOperator()
  18816. case sopstage.FieldConditionList:
  18817. return m.ConditionList()
  18818. case sopstage.FieldActionMessage:
  18819. return m.ActionMessage()
  18820. case sopstage.FieldActionLabelAdd:
  18821. return m.ActionLabelAdd()
  18822. case sopstage.FieldActionLabelDel:
  18823. return m.ActionLabelDel()
  18824. case sopstage.FieldActionForward:
  18825. return m.ActionForward()
  18826. case sopstage.FieldIndexSort:
  18827. return m.IndexSort()
  18828. }
  18829. return nil, false
  18830. }
  18831. // OldField returns the old value of the field from the database. An error is
  18832. // returned if the mutation operation is not UpdateOne, or the query to the
  18833. // database failed.
  18834. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18835. switch name {
  18836. case sopstage.FieldCreatedAt:
  18837. return m.OldCreatedAt(ctx)
  18838. case sopstage.FieldUpdatedAt:
  18839. return m.OldUpdatedAt(ctx)
  18840. case sopstage.FieldStatus:
  18841. return m.OldStatus(ctx)
  18842. case sopstage.FieldDeletedAt:
  18843. return m.OldDeletedAt(ctx)
  18844. case sopstage.FieldTaskID:
  18845. return m.OldTaskID(ctx)
  18846. case sopstage.FieldName:
  18847. return m.OldName(ctx)
  18848. case sopstage.FieldConditionType:
  18849. return m.OldConditionType(ctx)
  18850. case sopstage.FieldConditionOperator:
  18851. return m.OldConditionOperator(ctx)
  18852. case sopstage.FieldConditionList:
  18853. return m.OldConditionList(ctx)
  18854. case sopstage.FieldActionMessage:
  18855. return m.OldActionMessage(ctx)
  18856. case sopstage.FieldActionLabelAdd:
  18857. return m.OldActionLabelAdd(ctx)
  18858. case sopstage.FieldActionLabelDel:
  18859. return m.OldActionLabelDel(ctx)
  18860. case sopstage.FieldActionForward:
  18861. return m.OldActionForward(ctx)
  18862. case sopstage.FieldIndexSort:
  18863. return m.OldIndexSort(ctx)
  18864. }
  18865. return nil, fmt.Errorf("unknown SopStage field %s", name)
  18866. }
  18867. // SetField sets the value of a field with the given name. It returns an error if
  18868. // the field is not defined in the schema, or if the type mismatched the field
  18869. // type.
  18870. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  18871. switch name {
  18872. case sopstage.FieldCreatedAt:
  18873. v, ok := value.(time.Time)
  18874. if !ok {
  18875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18876. }
  18877. m.SetCreatedAt(v)
  18878. return nil
  18879. case sopstage.FieldUpdatedAt:
  18880. v, ok := value.(time.Time)
  18881. if !ok {
  18882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18883. }
  18884. m.SetUpdatedAt(v)
  18885. return nil
  18886. case sopstage.FieldStatus:
  18887. v, ok := value.(uint8)
  18888. if !ok {
  18889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18890. }
  18891. m.SetStatus(v)
  18892. return nil
  18893. case sopstage.FieldDeletedAt:
  18894. v, ok := value.(time.Time)
  18895. if !ok {
  18896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18897. }
  18898. m.SetDeletedAt(v)
  18899. return nil
  18900. case sopstage.FieldTaskID:
  18901. v, ok := value.(uint64)
  18902. if !ok {
  18903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18904. }
  18905. m.SetTaskID(v)
  18906. return nil
  18907. case sopstage.FieldName:
  18908. v, ok := value.(string)
  18909. if !ok {
  18910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18911. }
  18912. m.SetName(v)
  18913. return nil
  18914. case sopstage.FieldConditionType:
  18915. v, ok := value.(int)
  18916. if !ok {
  18917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18918. }
  18919. m.SetConditionType(v)
  18920. return nil
  18921. case sopstage.FieldConditionOperator:
  18922. v, ok := value.(int)
  18923. if !ok {
  18924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18925. }
  18926. m.SetConditionOperator(v)
  18927. return nil
  18928. case sopstage.FieldConditionList:
  18929. v, ok := value.([]custom_types.Condition)
  18930. if !ok {
  18931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18932. }
  18933. m.SetConditionList(v)
  18934. return nil
  18935. case sopstage.FieldActionMessage:
  18936. v, ok := value.([]custom_types.Action)
  18937. if !ok {
  18938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18939. }
  18940. m.SetActionMessage(v)
  18941. return nil
  18942. case sopstage.FieldActionLabelAdd:
  18943. v, ok := value.([]uint64)
  18944. if !ok {
  18945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18946. }
  18947. m.SetActionLabelAdd(v)
  18948. return nil
  18949. case sopstage.FieldActionLabelDel:
  18950. v, ok := value.([]uint64)
  18951. if !ok {
  18952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18953. }
  18954. m.SetActionLabelDel(v)
  18955. return nil
  18956. case sopstage.FieldActionForward:
  18957. v, ok := value.(*custom_types.ActionForward)
  18958. if !ok {
  18959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18960. }
  18961. m.SetActionForward(v)
  18962. return nil
  18963. case sopstage.FieldIndexSort:
  18964. v, ok := value.(int)
  18965. if !ok {
  18966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18967. }
  18968. m.SetIndexSort(v)
  18969. return nil
  18970. }
  18971. return fmt.Errorf("unknown SopStage field %s", name)
  18972. }
  18973. // AddedFields returns all numeric fields that were incremented/decremented during
  18974. // this mutation.
  18975. func (m *SopStageMutation) AddedFields() []string {
  18976. var fields []string
  18977. if m.addstatus != nil {
  18978. fields = append(fields, sopstage.FieldStatus)
  18979. }
  18980. if m.addcondition_type != nil {
  18981. fields = append(fields, sopstage.FieldConditionType)
  18982. }
  18983. if m.addcondition_operator != nil {
  18984. fields = append(fields, sopstage.FieldConditionOperator)
  18985. }
  18986. if m.addindex_sort != nil {
  18987. fields = append(fields, sopstage.FieldIndexSort)
  18988. }
  18989. return fields
  18990. }
  18991. // AddedField returns the numeric value that was incremented/decremented on a field
  18992. // with the given name. The second boolean return value indicates that this field
  18993. // was not set, or was not defined in the schema.
  18994. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  18995. switch name {
  18996. case sopstage.FieldStatus:
  18997. return m.AddedStatus()
  18998. case sopstage.FieldConditionType:
  18999. return m.AddedConditionType()
  19000. case sopstage.FieldConditionOperator:
  19001. return m.AddedConditionOperator()
  19002. case sopstage.FieldIndexSort:
  19003. return m.AddedIndexSort()
  19004. }
  19005. return nil, false
  19006. }
  19007. // AddField adds the value to the field with the given name. It returns an error if
  19008. // the field is not defined in the schema, or if the type mismatched the field
  19009. // type.
  19010. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  19011. switch name {
  19012. case sopstage.FieldStatus:
  19013. v, ok := value.(int8)
  19014. if !ok {
  19015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19016. }
  19017. m.AddStatus(v)
  19018. return nil
  19019. case sopstage.FieldConditionType:
  19020. v, ok := value.(int)
  19021. if !ok {
  19022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19023. }
  19024. m.AddConditionType(v)
  19025. return nil
  19026. case sopstage.FieldConditionOperator:
  19027. v, ok := value.(int)
  19028. if !ok {
  19029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19030. }
  19031. m.AddConditionOperator(v)
  19032. return nil
  19033. case sopstage.FieldIndexSort:
  19034. v, ok := value.(int)
  19035. if !ok {
  19036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19037. }
  19038. m.AddIndexSort(v)
  19039. return nil
  19040. }
  19041. return fmt.Errorf("unknown SopStage numeric field %s", name)
  19042. }
  19043. // ClearedFields returns all nullable fields that were cleared during this
  19044. // mutation.
  19045. func (m *SopStageMutation) ClearedFields() []string {
  19046. var fields []string
  19047. if m.FieldCleared(sopstage.FieldStatus) {
  19048. fields = append(fields, sopstage.FieldStatus)
  19049. }
  19050. if m.FieldCleared(sopstage.FieldDeletedAt) {
  19051. fields = append(fields, sopstage.FieldDeletedAt)
  19052. }
  19053. if m.FieldCleared(sopstage.FieldActionMessage) {
  19054. fields = append(fields, sopstage.FieldActionMessage)
  19055. }
  19056. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  19057. fields = append(fields, sopstage.FieldActionLabelAdd)
  19058. }
  19059. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  19060. fields = append(fields, sopstage.FieldActionLabelDel)
  19061. }
  19062. if m.FieldCleared(sopstage.FieldActionForward) {
  19063. fields = append(fields, sopstage.FieldActionForward)
  19064. }
  19065. if m.FieldCleared(sopstage.FieldIndexSort) {
  19066. fields = append(fields, sopstage.FieldIndexSort)
  19067. }
  19068. return fields
  19069. }
  19070. // FieldCleared returns a boolean indicating if a field with the given name was
  19071. // cleared in this mutation.
  19072. func (m *SopStageMutation) FieldCleared(name string) bool {
  19073. _, ok := m.clearedFields[name]
  19074. return ok
  19075. }
  19076. // ClearField clears the value of the field with the given name. It returns an
  19077. // error if the field is not defined in the schema.
  19078. func (m *SopStageMutation) ClearField(name string) error {
  19079. switch name {
  19080. case sopstage.FieldStatus:
  19081. m.ClearStatus()
  19082. return nil
  19083. case sopstage.FieldDeletedAt:
  19084. m.ClearDeletedAt()
  19085. return nil
  19086. case sopstage.FieldActionMessage:
  19087. m.ClearActionMessage()
  19088. return nil
  19089. case sopstage.FieldActionLabelAdd:
  19090. m.ClearActionLabelAdd()
  19091. return nil
  19092. case sopstage.FieldActionLabelDel:
  19093. m.ClearActionLabelDel()
  19094. return nil
  19095. case sopstage.FieldActionForward:
  19096. m.ClearActionForward()
  19097. return nil
  19098. case sopstage.FieldIndexSort:
  19099. m.ClearIndexSort()
  19100. return nil
  19101. }
  19102. return fmt.Errorf("unknown SopStage nullable field %s", name)
  19103. }
  19104. // ResetField resets all changes in the mutation for the field with the given name.
  19105. // It returns an error if the field is not defined in the schema.
  19106. func (m *SopStageMutation) ResetField(name string) error {
  19107. switch name {
  19108. case sopstage.FieldCreatedAt:
  19109. m.ResetCreatedAt()
  19110. return nil
  19111. case sopstage.FieldUpdatedAt:
  19112. m.ResetUpdatedAt()
  19113. return nil
  19114. case sopstage.FieldStatus:
  19115. m.ResetStatus()
  19116. return nil
  19117. case sopstage.FieldDeletedAt:
  19118. m.ResetDeletedAt()
  19119. return nil
  19120. case sopstage.FieldTaskID:
  19121. m.ResetTaskID()
  19122. return nil
  19123. case sopstage.FieldName:
  19124. m.ResetName()
  19125. return nil
  19126. case sopstage.FieldConditionType:
  19127. m.ResetConditionType()
  19128. return nil
  19129. case sopstage.FieldConditionOperator:
  19130. m.ResetConditionOperator()
  19131. return nil
  19132. case sopstage.FieldConditionList:
  19133. m.ResetConditionList()
  19134. return nil
  19135. case sopstage.FieldActionMessage:
  19136. m.ResetActionMessage()
  19137. return nil
  19138. case sopstage.FieldActionLabelAdd:
  19139. m.ResetActionLabelAdd()
  19140. return nil
  19141. case sopstage.FieldActionLabelDel:
  19142. m.ResetActionLabelDel()
  19143. return nil
  19144. case sopstage.FieldActionForward:
  19145. m.ResetActionForward()
  19146. return nil
  19147. case sopstage.FieldIndexSort:
  19148. m.ResetIndexSort()
  19149. return nil
  19150. }
  19151. return fmt.Errorf("unknown SopStage field %s", name)
  19152. }
  19153. // AddedEdges returns all edge names that were set/added in this mutation.
  19154. func (m *SopStageMutation) AddedEdges() []string {
  19155. edges := make([]string, 0, 3)
  19156. if m.sop_task != nil {
  19157. edges = append(edges, sopstage.EdgeSopTask)
  19158. }
  19159. if m.stage_nodes != nil {
  19160. edges = append(edges, sopstage.EdgeStageNodes)
  19161. }
  19162. if m.stage_messages != nil {
  19163. edges = append(edges, sopstage.EdgeStageMessages)
  19164. }
  19165. return edges
  19166. }
  19167. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19168. // name in this mutation.
  19169. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  19170. switch name {
  19171. case sopstage.EdgeSopTask:
  19172. if id := m.sop_task; id != nil {
  19173. return []ent.Value{*id}
  19174. }
  19175. case sopstage.EdgeStageNodes:
  19176. ids := make([]ent.Value, 0, len(m.stage_nodes))
  19177. for id := range m.stage_nodes {
  19178. ids = append(ids, id)
  19179. }
  19180. return ids
  19181. case sopstage.EdgeStageMessages:
  19182. ids := make([]ent.Value, 0, len(m.stage_messages))
  19183. for id := range m.stage_messages {
  19184. ids = append(ids, id)
  19185. }
  19186. return ids
  19187. }
  19188. return nil
  19189. }
  19190. // RemovedEdges returns all edge names that were removed in this mutation.
  19191. func (m *SopStageMutation) RemovedEdges() []string {
  19192. edges := make([]string, 0, 3)
  19193. if m.removedstage_nodes != nil {
  19194. edges = append(edges, sopstage.EdgeStageNodes)
  19195. }
  19196. if m.removedstage_messages != nil {
  19197. edges = append(edges, sopstage.EdgeStageMessages)
  19198. }
  19199. return edges
  19200. }
  19201. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19202. // the given name in this mutation.
  19203. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  19204. switch name {
  19205. case sopstage.EdgeStageNodes:
  19206. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  19207. for id := range m.removedstage_nodes {
  19208. ids = append(ids, id)
  19209. }
  19210. return ids
  19211. case sopstage.EdgeStageMessages:
  19212. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  19213. for id := range m.removedstage_messages {
  19214. ids = append(ids, id)
  19215. }
  19216. return ids
  19217. }
  19218. return nil
  19219. }
  19220. // ClearedEdges returns all edge names that were cleared in this mutation.
  19221. func (m *SopStageMutation) ClearedEdges() []string {
  19222. edges := make([]string, 0, 3)
  19223. if m.clearedsop_task {
  19224. edges = append(edges, sopstage.EdgeSopTask)
  19225. }
  19226. if m.clearedstage_nodes {
  19227. edges = append(edges, sopstage.EdgeStageNodes)
  19228. }
  19229. if m.clearedstage_messages {
  19230. edges = append(edges, sopstage.EdgeStageMessages)
  19231. }
  19232. return edges
  19233. }
  19234. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19235. // was cleared in this mutation.
  19236. func (m *SopStageMutation) EdgeCleared(name string) bool {
  19237. switch name {
  19238. case sopstage.EdgeSopTask:
  19239. return m.clearedsop_task
  19240. case sopstage.EdgeStageNodes:
  19241. return m.clearedstage_nodes
  19242. case sopstage.EdgeStageMessages:
  19243. return m.clearedstage_messages
  19244. }
  19245. return false
  19246. }
  19247. // ClearEdge clears the value of the edge with the given name. It returns an error
  19248. // if that edge is not defined in the schema.
  19249. func (m *SopStageMutation) ClearEdge(name string) error {
  19250. switch name {
  19251. case sopstage.EdgeSopTask:
  19252. m.ClearSopTask()
  19253. return nil
  19254. }
  19255. return fmt.Errorf("unknown SopStage unique edge %s", name)
  19256. }
  19257. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19258. // It returns an error if the edge is not defined in the schema.
  19259. func (m *SopStageMutation) ResetEdge(name string) error {
  19260. switch name {
  19261. case sopstage.EdgeSopTask:
  19262. m.ResetSopTask()
  19263. return nil
  19264. case sopstage.EdgeStageNodes:
  19265. m.ResetStageNodes()
  19266. return nil
  19267. case sopstage.EdgeStageMessages:
  19268. m.ResetStageMessages()
  19269. return nil
  19270. }
  19271. return fmt.Errorf("unknown SopStage edge %s", name)
  19272. }
  19273. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  19274. type SopTaskMutation struct {
  19275. config
  19276. op Op
  19277. typ string
  19278. id *uint64
  19279. created_at *time.Time
  19280. updated_at *time.Time
  19281. status *uint8
  19282. addstatus *int8
  19283. deleted_at *time.Time
  19284. name *string
  19285. bot_wxid_list *[]string
  19286. appendbot_wxid_list []string
  19287. _type *int
  19288. add_type *int
  19289. plan_start_time *time.Time
  19290. plan_end_time *time.Time
  19291. creator_id *string
  19292. organization_id *uint64
  19293. addorganization_id *int64
  19294. token *[]string
  19295. appendtoken []string
  19296. clearedFields map[string]struct{}
  19297. task_stages map[uint64]struct{}
  19298. removedtask_stages map[uint64]struct{}
  19299. clearedtask_stages bool
  19300. done bool
  19301. oldValue func(context.Context) (*SopTask, error)
  19302. predicates []predicate.SopTask
  19303. }
  19304. var _ ent.Mutation = (*SopTaskMutation)(nil)
  19305. // soptaskOption allows management of the mutation configuration using functional options.
  19306. type soptaskOption func(*SopTaskMutation)
  19307. // newSopTaskMutation creates new mutation for the SopTask entity.
  19308. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  19309. m := &SopTaskMutation{
  19310. config: c,
  19311. op: op,
  19312. typ: TypeSopTask,
  19313. clearedFields: make(map[string]struct{}),
  19314. }
  19315. for _, opt := range opts {
  19316. opt(m)
  19317. }
  19318. return m
  19319. }
  19320. // withSopTaskID sets the ID field of the mutation.
  19321. func withSopTaskID(id uint64) soptaskOption {
  19322. return func(m *SopTaskMutation) {
  19323. var (
  19324. err error
  19325. once sync.Once
  19326. value *SopTask
  19327. )
  19328. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  19329. once.Do(func() {
  19330. if m.done {
  19331. err = errors.New("querying old values post mutation is not allowed")
  19332. } else {
  19333. value, err = m.Client().SopTask.Get(ctx, id)
  19334. }
  19335. })
  19336. return value, err
  19337. }
  19338. m.id = &id
  19339. }
  19340. }
  19341. // withSopTask sets the old SopTask of the mutation.
  19342. func withSopTask(node *SopTask) soptaskOption {
  19343. return func(m *SopTaskMutation) {
  19344. m.oldValue = func(context.Context) (*SopTask, error) {
  19345. return node, nil
  19346. }
  19347. m.id = &node.ID
  19348. }
  19349. }
  19350. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19351. // executed in a transaction (ent.Tx), a transactional client is returned.
  19352. func (m SopTaskMutation) Client() *Client {
  19353. client := &Client{config: m.config}
  19354. client.init()
  19355. return client
  19356. }
  19357. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19358. // it returns an error otherwise.
  19359. func (m SopTaskMutation) Tx() (*Tx, error) {
  19360. if _, ok := m.driver.(*txDriver); !ok {
  19361. return nil, errors.New("ent: mutation is not running in a transaction")
  19362. }
  19363. tx := &Tx{config: m.config}
  19364. tx.init()
  19365. return tx, nil
  19366. }
  19367. // SetID sets the value of the id field. Note that this
  19368. // operation is only accepted on creation of SopTask entities.
  19369. func (m *SopTaskMutation) SetID(id uint64) {
  19370. m.id = &id
  19371. }
  19372. // ID returns the ID value in the mutation. Note that the ID is only available
  19373. // if it was provided to the builder or after it was returned from the database.
  19374. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  19375. if m.id == nil {
  19376. return
  19377. }
  19378. return *m.id, true
  19379. }
  19380. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19381. // That means, if the mutation is applied within a transaction with an isolation level such
  19382. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19383. // or updated by the mutation.
  19384. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  19385. switch {
  19386. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19387. id, exists := m.ID()
  19388. if exists {
  19389. return []uint64{id}, nil
  19390. }
  19391. fallthrough
  19392. case m.op.Is(OpUpdate | OpDelete):
  19393. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  19394. default:
  19395. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19396. }
  19397. }
  19398. // SetCreatedAt sets the "created_at" field.
  19399. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  19400. m.created_at = &t
  19401. }
  19402. // CreatedAt returns the value of the "created_at" field in the mutation.
  19403. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  19404. v := m.created_at
  19405. if v == nil {
  19406. return
  19407. }
  19408. return *v, true
  19409. }
  19410. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  19411. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19413. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19414. if !m.op.Is(OpUpdateOne) {
  19415. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19416. }
  19417. if m.id == nil || m.oldValue == nil {
  19418. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19419. }
  19420. oldValue, err := m.oldValue(ctx)
  19421. if err != nil {
  19422. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19423. }
  19424. return oldValue.CreatedAt, nil
  19425. }
  19426. // ResetCreatedAt resets all changes to the "created_at" field.
  19427. func (m *SopTaskMutation) ResetCreatedAt() {
  19428. m.created_at = nil
  19429. }
  19430. // SetUpdatedAt sets the "updated_at" field.
  19431. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  19432. m.updated_at = &t
  19433. }
  19434. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19435. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  19436. v := m.updated_at
  19437. if v == nil {
  19438. return
  19439. }
  19440. return *v, true
  19441. }
  19442. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  19443. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19445. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19446. if !m.op.Is(OpUpdateOne) {
  19447. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19448. }
  19449. if m.id == nil || m.oldValue == nil {
  19450. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19451. }
  19452. oldValue, err := m.oldValue(ctx)
  19453. if err != nil {
  19454. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19455. }
  19456. return oldValue.UpdatedAt, nil
  19457. }
  19458. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19459. func (m *SopTaskMutation) ResetUpdatedAt() {
  19460. m.updated_at = nil
  19461. }
  19462. // SetStatus sets the "status" field.
  19463. func (m *SopTaskMutation) SetStatus(u uint8) {
  19464. m.status = &u
  19465. m.addstatus = nil
  19466. }
  19467. // Status returns the value of the "status" field in the mutation.
  19468. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  19469. v := m.status
  19470. if v == nil {
  19471. return
  19472. }
  19473. return *v, true
  19474. }
  19475. // OldStatus returns the old "status" field's value of the SopTask entity.
  19476. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19478. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19479. if !m.op.Is(OpUpdateOne) {
  19480. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19481. }
  19482. if m.id == nil || m.oldValue == nil {
  19483. return v, errors.New("OldStatus requires an ID field in the mutation")
  19484. }
  19485. oldValue, err := m.oldValue(ctx)
  19486. if err != nil {
  19487. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19488. }
  19489. return oldValue.Status, nil
  19490. }
  19491. // AddStatus adds u to the "status" field.
  19492. func (m *SopTaskMutation) AddStatus(u int8) {
  19493. if m.addstatus != nil {
  19494. *m.addstatus += u
  19495. } else {
  19496. m.addstatus = &u
  19497. }
  19498. }
  19499. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19500. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  19501. v := m.addstatus
  19502. if v == nil {
  19503. return
  19504. }
  19505. return *v, true
  19506. }
  19507. // ClearStatus clears the value of the "status" field.
  19508. func (m *SopTaskMutation) ClearStatus() {
  19509. m.status = nil
  19510. m.addstatus = nil
  19511. m.clearedFields[soptask.FieldStatus] = struct{}{}
  19512. }
  19513. // StatusCleared returns if the "status" field was cleared in this mutation.
  19514. func (m *SopTaskMutation) StatusCleared() bool {
  19515. _, ok := m.clearedFields[soptask.FieldStatus]
  19516. return ok
  19517. }
  19518. // ResetStatus resets all changes to the "status" field.
  19519. func (m *SopTaskMutation) ResetStatus() {
  19520. m.status = nil
  19521. m.addstatus = nil
  19522. delete(m.clearedFields, soptask.FieldStatus)
  19523. }
  19524. // SetDeletedAt sets the "deleted_at" field.
  19525. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  19526. m.deleted_at = &t
  19527. }
  19528. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19529. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  19530. v := m.deleted_at
  19531. if v == nil {
  19532. return
  19533. }
  19534. return *v, true
  19535. }
  19536. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  19537. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19539. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19540. if !m.op.Is(OpUpdateOne) {
  19541. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19542. }
  19543. if m.id == nil || m.oldValue == nil {
  19544. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19545. }
  19546. oldValue, err := m.oldValue(ctx)
  19547. if err != nil {
  19548. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19549. }
  19550. return oldValue.DeletedAt, nil
  19551. }
  19552. // ClearDeletedAt clears the value of the "deleted_at" field.
  19553. func (m *SopTaskMutation) ClearDeletedAt() {
  19554. m.deleted_at = nil
  19555. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  19556. }
  19557. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19558. func (m *SopTaskMutation) DeletedAtCleared() bool {
  19559. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  19560. return ok
  19561. }
  19562. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19563. func (m *SopTaskMutation) ResetDeletedAt() {
  19564. m.deleted_at = nil
  19565. delete(m.clearedFields, soptask.FieldDeletedAt)
  19566. }
  19567. // SetName sets the "name" field.
  19568. func (m *SopTaskMutation) SetName(s string) {
  19569. m.name = &s
  19570. }
  19571. // Name returns the value of the "name" field in the mutation.
  19572. func (m *SopTaskMutation) Name() (r string, exists bool) {
  19573. v := m.name
  19574. if v == nil {
  19575. return
  19576. }
  19577. return *v, true
  19578. }
  19579. // OldName returns the old "name" field's value of the SopTask entity.
  19580. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19582. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  19583. if !m.op.Is(OpUpdateOne) {
  19584. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19585. }
  19586. if m.id == nil || m.oldValue == nil {
  19587. return v, errors.New("OldName requires an ID field in the mutation")
  19588. }
  19589. oldValue, err := m.oldValue(ctx)
  19590. if err != nil {
  19591. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19592. }
  19593. return oldValue.Name, nil
  19594. }
  19595. // ResetName resets all changes to the "name" field.
  19596. func (m *SopTaskMutation) ResetName() {
  19597. m.name = nil
  19598. }
  19599. // SetBotWxidList sets the "bot_wxid_list" field.
  19600. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  19601. m.bot_wxid_list = &s
  19602. m.appendbot_wxid_list = nil
  19603. }
  19604. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  19605. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  19606. v := m.bot_wxid_list
  19607. if v == nil {
  19608. return
  19609. }
  19610. return *v, true
  19611. }
  19612. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  19613. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19615. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  19616. if !m.op.Is(OpUpdateOne) {
  19617. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  19618. }
  19619. if m.id == nil || m.oldValue == nil {
  19620. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  19621. }
  19622. oldValue, err := m.oldValue(ctx)
  19623. if err != nil {
  19624. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  19625. }
  19626. return oldValue.BotWxidList, nil
  19627. }
  19628. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  19629. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  19630. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  19631. }
  19632. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  19633. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  19634. if len(m.appendbot_wxid_list) == 0 {
  19635. return nil, false
  19636. }
  19637. return m.appendbot_wxid_list, true
  19638. }
  19639. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  19640. func (m *SopTaskMutation) ClearBotWxidList() {
  19641. m.bot_wxid_list = nil
  19642. m.appendbot_wxid_list = nil
  19643. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  19644. }
  19645. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  19646. func (m *SopTaskMutation) BotWxidListCleared() bool {
  19647. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  19648. return ok
  19649. }
  19650. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  19651. func (m *SopTaskMutation) ResetBotWxidList() {
  19652. m.bot_wxid_list = nil
  19653. m.appendbot_wxid_list = nil
  19654. delete(m.clearedFields, soptask.FieldBotWxidList)
  19655. }
  19656. // SetType sets the "type" field.
  19657. func (m *SopTaskMutation) SetType(i int) {
  19658. m._type = &i
  19659. m.add_type = nil
  19660. }
  19661. // GetType returns the value of the "type" field in the mutation.
  19662. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  19663. v := m._type
  19664. if v == nil {
  19665. return
  19666. }
  19667. return *v, true
  19668. }
  19669. // OldType returns the old "type" field's value of the SopTask entity.
  19670. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19672. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  19673. if !m.op.Is(OpUpdateOne) {
  19674. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19675. }
  19676. if m.id == nil || m.oldValue == nil {
  19677. return v, errors.New("OldType requires an ID field in the mutation")
  19678. }
  19679. oldValue, err := m.oldValue(ctx)
  19680. if err != nil {
  19681. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19682. }
  19683. return oldValue.Type, nil
  19684. }
  19685. // AddType adds i to the "type" field.
  19686. func (m *SopTaskMutation) AddType(i int) {
  19687. if m.add_type != nil {
  19688. *m.add_type += i
  19689. } else {
  19690. m.add_type = &i
  19691. }
  19692. }
  19693. // AddedType returns the value that was added to the "type" field in this mutation.
  19694. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  19695. v := m.add_type
  19696. if v == nil {
  19697. return
  19698. }
  19699. return *v, true
  19700. }
  19701. // ResetType resets all changes to the "type" field.
  19702. func (m *SopTaskMutation) ResetType() {
  19703. m._type = nil
  19704. m.add_type = nil
  19705. }
  19706. // SetPlanStartTime sets the "plan_start_time" field.
  19707. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  19708. m.plan_start_time = &t
  19709. }
  19710. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  19711. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  19712. v := m.plan_start_time
  19713. if v == nil {
  19714. return
  19715. }
  19716. return *v, true
  19717. }
  19718. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  19719. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19721. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  19722. if !m.op.Is(OpUpdateOne) {
  19723. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  19724. }
  19725. if m.id == nil || m.oldValue == nil {
  19726. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  19727. }
  19728. oldValue, err := m.oldValue(ctx)
  19729. if err != nil {
  19730. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  19731. }
  19732. return oldValue.PlanStartTime, nil
  19733. }
  19734. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  19735. func (m *SopTaskMutation) ClearPlanStartTime() {
  19736. m.plan_start_time = nil
  19737. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  19738. }
  19739. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  19740. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  19741. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  19742. return ok
  19743. }
  19744. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  19745. func (m *SopTaskMutation) ResetPlanStartTime() {
  19746. m.plan_start_time = nil
  19747. delete(m.clearedFields, soptask.FieldPlanStartTime)
  19748. }
  19749. // SetPlanEndTime sets the "plan_end_time" field.
  19750. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  19751. m.plan_end_time = &t
  19752. }
  19753. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  19754. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  19755. v := m.plan_end_time
  19756. if v == nil {
  19757. return
  19758. }
  19759. return *v, true
  19760. }
  19761. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  19762. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19764. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  19765. if !m.op.Is(OpUpdateOne) {
  19766. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  19767. }
  19768. if m.id == nil || m.oldValue == nil {
  19769. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  19770. }
  19771. oldValue, err := m.oldValue(ctx)
  19772. if err != nil {
  19773. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  19774. }
  19775. return oldValue.PlanEndTime, nil
  19776. }
  19777. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  19778. func (m *SopTaskMutation) ClearPlanEndTime() {
  19779. m.plan_end_time = nil
  19780. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  19781. }
  19782. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  19783. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  19784. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  19785. return ok
  19786. }
  19787. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  19788. func (m *SopTaskMutation) ResetPlanEndTime() {
  19789. m.plan_end_time = nil
  19790. delete(m.clearedFields, soptask.FieldPlanEndTime)
  19791. }
  19792. // SetCreatorID sets the "creator_id" field.
  19793. func (m *SopTaskMutation) SetCreatorID(s string) {
  19794. m.creator_id = &s
  19795. }
  19796. // CreatorID returns the value of the "creator_id" field in the mutation.
  19797. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  19798. v := m.creator_id
  19799. if v == nil {
  19800. return
  19801. }
  19802. return *v, true
  19803. }
  19804. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  19805. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19807. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  19808. if !m.op.Is(OpUpdateOne) {
  19809. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  19810. }
  19811. if m.id == nil || m.oldValue == nil {
  19812. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  19813. }
  19814. oldValue, err := m.oldValue(ctx)
  19815. if err != nil {
  19816. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  19817. }
  19818. return oldValue.CreatorID, nil
  19819. }
  19820. // ClearCreatorID clears the value of the "creator_id" field.
  19821. func (m *SopTaskMutation) ClearCreatorID() {
  19822. m.creator_id = nil
  19823. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  19824. }
  19825. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  19826. func (m *SopTaskMutation) CreatorIDCleared() bool {
  19827. _, ok := m.clearedFields[soptask.FieldCreatorID]
  19828. return ok
  19829. }
  19830. // ResetCreatorID resets all changes to the "creator_id" field.
  19831. func (m *SopTaskMutation) ResetCreatorID() {
  19832. m.creator_id = nil
  19833. delete(m.clearedFields, soptask.FieldCreatorID)
  19834. }
  19835. // SetOrganizationID sets the "organization_id" field.
  19836. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  19837. m.organization_id = &u
  19838. m.addorganization_id = nil
  19839. }
  19840. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19841. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  19842. v := m.organization_id
  19843. if v == nil {
  19844. return
  19845. }
  19846. return *v, true
  19847. }
  19848. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  19849. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19851. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19852. if !m.op.Is(OpUpdateOne) {
  19853. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19854. }
  19855. if m.id == nil || m.oldValue == nil {
  19856. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19857. }
  19858. oldValue, err := m.oldValue(ctx)
  19859. if err != nil {
  19860. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19861. }
  19862. return oldValue.OrganizationID, nil
  19863. }
  19864. // AddOrganizationID adds u to the "organization_id" field.
  19865. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  19866. if m.addorganization_id != nil {
  19867. *m.addorganization_id += u
  19868. } else {
  19869. m.addorganization_id = &u
  19870. }
  19871. }
  19872. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19873. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  19874. v := m.addorganization_id
  19875. if v == nil {
  19876. return
  19877. }
  19878. return *v, true
  19879. }
  19880. // ClearOrganizationID clears the value of the "organization_id" field.
  19881. func (m *SopTaskMutation) ClearOrganizationID() {
  19882. m.organization_id = nil
  19883. m.addorganization_id = nil
  19884. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  19885. }
  19886. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19887. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  19888. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  19889. return ok
  19890. }
  19891. // ResetOrganizationID resets all changes to the "organization_id" field.
  19892. func (m *SopTaskMutation) ResetOrganizationID() {
  19893. m.organization_id = nil
  19894. m.addorganization_id = nil
  19895. delete(m.clearedFields, soptask.FieldOrganizationID)
  19896. }
  19897. // SetToken sets the "token" field.
  19898. func (m *SopTaskMutation) SetToken(s []string) {
  19899. m.token = &s
  19900. m.appendtoken = nil
  19901. }
  19902. // Token returns the value of the "token" field in the mutation.
  19903. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  19904. v := m.token
  19905. if v == nil {
  19906. return
  19907. }
  19908. return *v, true
  19909. }
  19910. // OldToken returns the old "token" field's value of the SopTask entity.
  19911. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19913. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  19914. if !m.op.Is(OpUpdateOne) {
  19915. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  19916. }
  19917. if m.id == nil || m.oldValue == nil {
  19918. return v, errors.New("OldToken requires an ID field in the mutation")
  19919. }
  19920. oldValue, err := m.oldValue(ctx)
  19921. if err != nil {
  19922. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  19923. }
  19924. return oldValue.Token, nil
  19925. }
  19926. // AppendToken adds s to the "token" field.
  19927. func (m *SopTaskMutation) AppendToken(s []string) {
  19928. m.appendtoken = append(m.appendtoken, s...)
  19929. }
  19930. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  19931. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  19932. if len(m.appendtoken) == 0 {
  19933. return nil, false
  19934. }
  19935. return m.appendtoken, true
  19936. }
  19937. // ClearToken clears the value of the "token" field.
  19938. func (m *SopTaskMutation) ClearToken() {
  19939. m.token = nil
  19940. m.appendtoken = nil
  19941. m.clearedFields[soptask.FieldToken] = struct{}{}
  19942. }
  19943. // TokenCleared returns if the "token" field was cleared in this mutation.
  19944. func (m *SopTaskMutation) TokenCleared() bool {
  19945. _, ok := m.clearedFields[soptask.FieldToken]
  19946. return ok
  19947. }
  19948. // ResetToken resets all changes to the "token" field.
  19949. func (m *SopTaskMutation) ResetToken() {
  19950. m.token = nil
  19951. m.appendtoken = nil
  19952. delete(m.clearedFields, soptask.FieldToken)
  19953. }
  19954. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  19955. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  19956. if m.task_stages == nil {
  19957. m.task_stages = make(map[uint64]struct{})
  19958. }
  19959. for i := range ids {
  19960. m.task_stages[ids[i]] = struct{}{}
  19961. }
  19962. }
  19963. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  19964. func (m *SopTaskMutation) ClearTaskStages() {
  19965. m.clearedtask_stages = true
  19966. }
  19967. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  19968. func (m *SopTaskMutation) TaskStagesCleared() bool {
  19969. return m.clearedtask_stages
  19970. }
  19971. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  19972. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  19973. if m.removedtask_stages == nil {
  19974. m.removedtask_stages = make(map[uint64]struct{})
  19975. }
  19976. for i := range ids {
  19977. delete(m.task_stages, ids[i])
  19978. m.removedtask_stages[ids[i]] = struct{}{}
  19979. }
  19980. }
  19981. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  19982. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  19983. for id := range m.removedtask_stages {
  19984. ids = append(ids, id)
  19985. }
  19986. return
  19987. }
  19988. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  19989. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  19990. for id := range m.task_stages {
  19991. ids = append(ids, id)
  19992. }
  19993. return
  19994. }
  19995. // ResetTaskStages resets all changes to the "task_stages" edge.
  19996. func (m *SopTaskMutation) ResetTaskStages() {
  19997. m.task_stages = nil
  19998. m.clearedtask_stages = false
  19999. m.removedtask_stages = nil
  20000. }
  20001. // Where appends a list predicates to the SopTaskMutation builder.
  20002. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  20003. m.predicates = append(m.predicates, ps...)
  20004. }
  20005. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  20006. // users can use type-assertion to append predicates that do not depend on any generated package.
  20007. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  20008. p := make([]predicate.SopTask, len(ps))
  20009. for i := range ps {
  20010. p[i] = ps[i]
  20011. }
  20012. m.Where(p...)
  20013. }
  20014. // Op returns the operation name.
  20015. func (m *SopTaskMutation) Op() Op {
  20016. return m.op
  20017. }
  20018. // SetOp allows setting the mutation operation.
  20019. func (m *SopTaskMutation) SetOp(op Op) {
  20020. m.op = op
  20021. }
  20022. // Type returns the node type of this mutation (SopTask).
  20023. func (m *SopTaskMutation) Type() string {
  20024. return m.typ
  20025. }
  20026. // Fields returns all fields that were changed during this mutation. Note that in
  20027. // order to get all numeric fields that were incremented/decremented, call
  20028. // AddedFields().
  20029. func (m *SopTaskMutation) Fields() []string {
  20030. fields := make([]string, 0, 12)
  20031. if m.created_at != nil {
  20032. fields = append(fields, soptask.FieldCreatedAt)
  20033. }
  20034. if m.updated_at != nil {
  20035. fields = append(fields, soptask.FieldUpdatedAt)
  20036. }
  20037. if m.status != nil {
  20038. fields = append(fields, soptask.FieldStatus)
  20039. }
  20040. if m.deleted_at != nil {
  20041. fields = append(fields, soptask.FieldDeletedAt)
  20042. }
  20043. if m.name != nil {
  20044. fields = append(fields, soptask.FieldName)
  20045. }
  20046. if m.bot_wxid_list != nil {
  20047. fields = append(fields, soptask.FieldBotWxidList)
  20048. }
  20049. if m._type != nil {
  20050. fields = append(fields, soptask.FieldType)
  20051. }
  20052. if m.plan_start_time != nil {
  20053. fields = append(fields, soptask.FieldPlanStartTime)
  20054. }
  20055. if m.plan_end_time != nil {
  20056. fields = append(fields, soptask.FieldPlanEndTime)
  20057. }
  20058. if m.creator_id != nil {
  20059. fields = append(fields, soptask.FieldCreatorID)
  20060. }
  20061. if m.organization_id != nil {
  20062. fields = append(fields, soptask.FieldOrganizationID)
  20063. }
  20064. if m.token != nil {
  20065. fields = append(fields, soptask.FieldToken)
  20066. }
  20067. return fields
  20068. }
  20069. // Field returns the value of a field with the given name. The second boolean
  20070. // return value indicates that this field was not set, or was not defined in the
  20071. // schema.
  20072. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  20073. switch name {
  20074. case soptask.FieldCreatedAt:
  20075. return m.CreatedAt()
  20076. case soptask.FieldUpdatedAt:
  20077. return m.UpdatedAt()
  20078. case soptask.FieldStatus:
  20079. return m.Status()
  20080. case soptask.FieldDeletedAt:
  20081. return m.DeletedAt()
  20082. case soptask.FieldName:
  20083. return m.Name()
  20084. case soptask.FieldBotWxidList:
  20085. return m.BotWxidList()
  20086. case soptask.FieldType:
  20087. return m.GetType()
  20088. case soptask.FieldPlanStartTime:
  20089. return m.PlanStartTime()
  20090. case soptask.FieldPlanEndTime:
  20091. return m.PlanEndTime()
  20092. case soptask.FieldCreatorID:
  20093. return m.CreatorID()
  20094. case soptask.FieldOrganizationID:
  20095. return m.OrganizationID()
  20096. case soptask.FieldToken:
  20097. return m.Token()
  20098. }
  20099. return nil, false
  20100. }
  20101. // OldField returns the old value of the field from the database. An error is
  20102. // returned if the mutation operation is not UpdateOne, or the query to the
  20103. // database failed.
  20104. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20105. switch name {
  20106. case soptask.FieldCreatedAt:
  20107. return m.OldCreatedAt(ctx)
  20108. case soptask.FieldUpdatedAt:
  20109. return m.OldUpdatedAt(ctx)
  20110. case soptask.FieldStatus:
  20111. return m.OldStatus(ctx)
  20112. case soptask.FieldDeletedAt:
  20113. return m.OldDeletedAt(ctx)
  20114. case soptask.FieldName:
  20115. return m.OldName(ctx)
  20116. case soptask.FieldBotWxidList:
  20117. return m.OldBotWxidList(ctx)
  20118. case soptask.FieldType:
  20119. return m.OldType(ctx)
  20120. case soptask.FieldPlanStartTime:
  20121. return m.OldPlanStartTime(ctx)
  20122. case soptask.FieldPlanEndTime:
  20123. return m.OldPlanEndTime(ctx)
  20124. case soptask.FieldCreatorID:
  20125. return m.OldCreatorID(ctx)
  20126. case soptask.FieldOrganizationID:
  20127. return m.OldOrganizationID(ctx)
  20128. case soptask.FieldToken:
  20129. return m.OldToken(ctx)
  20130. }
  20131. return nil, fmt.Errorf("unknown SopTask field %s", name)
  20132. }
  20133. // SetField sets the value of a field with the given name. It returns an error if
  20134. // the field is not defined in the schema, or if the type mismatched the field
  20135. // type.
  20136. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  20137. switch name {
  20138. case soptask.FieldCreatedAt:
  20139. v, ok := value.(time.Time)
  20140. if !ok {
  20141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20142. }
  20143. m.SetCreatedAt(v)
  20144. return nil
  20145. case soptask.FieldUpdatedAt:
  20146. v, ok := value.(time.Time)
  20147. if !ok {
  20148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20149. }
  20150. m.SetUpdatedAt(v)
  20151. return nil
  20152. case soptask.FieldStatus:
  20153. v, ok := value.(uint8)
  20154. if !ok {
  20155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20156. }
  20157. m.SetStatus(v)
  20158. return nil
  20159. case soptask.FieldDeletedAt:
  20160. v, ok := value.(time.Time)
  20161. if !ok {
  20162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20163. }
  20164. m.SetDeletedAt(v)
  20165. return nil
  20166. case soptask.FieldName:
  20167. v, ok := value.(string)
  20168. if !ok {
  20169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20170. }
  20171. m.SetName(v)
  20172. return nil
  20173. case soptask.FieldBotWxidList:
  20174. v, ok := value.([]string)
  20175. if !ok {
  20176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20177. }
  20178. m.SetBotWxidList(v)
  20179. return nil
  20180. case soptask.FieldType:
  20181. v, ok := value.(int)
  20182. if !ok {
  20183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20184. }
  20185. m.SetType(v)
  20186. return nil
  20187. case soptask.FieldPlanStartTime:
  20188. v, ok := value.(time.Time)
  20189. if !ok {
  20190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20191. }
  20192. m.SetPlanStartTime(v)
  20193. return nil
  20194. case soptask.FieldPlanEndTime:
  20195. v, ok := value.(time.Time)
  20196. if !ok {
  20197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20198. }
  20199. m.SetPlanEndTime(v)
  20200. return nil
  20201. case soptask.FieldCreatorID:
  20202. v, ok := value.(string)
  20203. if !ok {
  20204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20205. }
  20206. m.SetCreatorID(v)
  20207. return nil
  20208. case soptask.FieldOrganizationID:
  20209. v, ok := value.(uint64)
  20210. if !ok {
  20211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20212. }
  20213. m.SetOrganizationID(v)
  20214. return nil
  20215. case soptask.FieldToken:
  20216. v, ok := value.([]string)
  20217. if !ok {
  20218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20219. }
  20220. m.SetToken(v)
  20221. return nil
  20222. }
  20223. return fmt.Errorf("unknown SopTask field %s", name)
  20224. }
  20225. // AddedFields returns all numeric fields that were incremented/decremented during
  20226. // this mutation.
  20227. func (m *SopTaskMutation) AddedFields() []string {
  20228. var fields []string
  20229. if m.addstatus != nil {
  20230. fields = append(fields, soptask.FieldStatus)
  20231. }
  20232. if m.add_type != nil {
  20233. fields = append(fields, soptask.FieldType)
  20234. }
  20235. if m.addorganization_id != nil {
  20236. fields = append(fields, soptask.FieldOrganizationID)
  20237. }
  20238. return fields
  20239. }
  20240. // AddedField returns the numeric value that was incremented/decremented on a field
  20241. // with the given name. The second boolean return value indicates that this field
  20242. // was not set, or was not defined in the schema.
  20243. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  20244. switch name {
  20245. case soptask.FieldStatus:
  20246. return m.AddedStatus()
  20247. case soptask.FieldType:
  20248. return m.AddedType()
  20249. case soptask.FieldOrganizationID:
  20250. return m.AddedOrganizationID()
  20251. }
  20252. return nil, false
  20253. }
  20254. // AddField adds the value to the field with the given name. It returns an error if
  20255. // the field is not defined in the schema, or if the type mismatched the field
  20256. // type.
  20257. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  20258. switch name {
  20259. case soptask.FieldStatus:
  20260. v, ok := value.(int8)
  20261. if !ok {
  20262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20263. }
  20264. m.AddStatus(v)
  20265. return nil
  20266. case soptask.FieldType:
  20267. v, ok := value.(int)
  20268. if !ok {
  20269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20270. }
  20271. m.AddType(v)
  20272. return nil
  20273. case soptask.FieldOrganizationID:
  20274. v, ok := value.(int64)
  20275. if !ok {
  20276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20277. }
  20278. m.AddOrganizationID(v)
  20279. return nil
  20280. }
  20281. return fmt.Errorf("unknown SopTask numeric field %s", name)
  20282. }
  20283. // ClearedFields returns all nullable fields that were cleared during this
  20284. // mutation.
  20285. func (m *SopTaskMutation) ClearedFields() []string {
  20286. var fields []string
  20287. if m.FieldCleared(soptask.FieldStatus) {
  20288. fields = append(fields, soptask.FieldStatus)
  20289. }
  20290. if m.FieldCleared(soptask.FieldDeletedAt) {
  20291. fields = append(fields, soptask.FieldDeletedAt)
  20292. }
  20293. if m.FieldCleared(soptask.FieldBotWxidList) {
  20294. fields = append(fields, soptask.FieldBotWxidList)
  20295. }
  20296. if m.FieldCleared(soptask.FieldPlanStartTime) {
  20297. fields = append(fields, soptask.FieldPlanStartTime)
  20298. }
  20299. if m.FieldCleared(soptask.FieldPlanEndTime) {
  20300. fields = append(fields, soptask.FieldPlanEndTime)
  20301. }
  20302. if m.FieldCleared(soptask.FieldCreatorID) {
  20303. fields = append(fields, soptask.FieldCreatorID)
  20304. }
  20305. if m.FieldCleared(soptask.FieldOrganizationID) {
  20306. fields = append(fields, soptask.FieldOrganizationID)
  20307. }
  20308. if m.FieldCleared(soptask.FieldToken) {
  20309. fields = append(fields, soptask.FieldToken)
  20310. }
  20311. return fields
  20312. }
  20313. // FieldCleared returns a boolean indicating if a field with the given name was
  20314. // cleared in this mutation.
  20315. func (m *SopTaskMutation) FieldCleared(name string) bool {
  20316. _, ok := m.clearedFields[name]
  20317. return ok
  20318. }
  20319. // ClearField clears the value of the field with the given name. It returns an
  20320. // error if the field is not defined in the schema.
  20321. func (m *SopTaskMutation) ClearField(name string) error {
  20322. switch name {
  20323. case soptask.FieldStatus:
  20324. m.ClearStatus()
  20325. return nil
  20326. case soptask.FieldDeletedAt:
  20327. m.ClearDeletedAt()
  20328. return nil
  20329. case soptask.FieldBotWxidList:
  20330. m.ClearBotWxidList()
  20331. return nil
  20332. case soptask.FieldPlanStartTime:
  20333. m.ClearPlanStartTime()
  20334. return nil
  20335. case soptask.FieldPlanEndTime:
  20336. m.ClearPlanEndTime()
  20337. return nil
  20338. case soptask.FieldCreatorID:
  20339. m.ClearCreatorID()
  20340. return nil
  20341. case soptask.FieldOrganizationID:
  20342. m.ClearOrganizationID()
  20343. return nil
  20344. case soptask.FieldToken:
  20345. m.ClearToken()
  20346. return nil
  20347. }
  20348. return fmt.Errorf("unknown SopTask nullable field %s", name)
  20349. }
  20350. // ResetField resets all changes in the mutation for the field with the given name.
  20351. // It returns an error if the field is not defined in the schema.
  20352. func (m *SopTaskMutation) ResetField(name string) error {
  20353. switch name {
  20354. case soptask.FieldCreatedAt:
  20355. m.ResetCreatedAt()
  20356. return nil
  20357. case soptask.FieldUpdatedAt:
  20358. m.ResetUpdatedAt()
  20359. return nil
  20360. case soptask.FieldStatus:
  20361. m.ResetStatus()
  20362. return nil
  20363. case soptask.FieldDeletedAt:
  20364. m.ResetDeletedAt()
  20365. return nil
  20366. case soptask.FieldName:
  20367. m.ResetName()
  20368. return nil
  20369. case soptask.FieldBotWxidList:
  20370. m.ResetBotWxidList()
  20371. return nil
  20372. case soptask.FieldType:
  20373. m.ResetType()
  20374. return nil
  20375. case soptask.FieldPlanStartTime:
  20376. m.ResetPlanStartTime()
  20377. return nil
  20378. case soptask.FieldPlanEndTime:
  20379. m.ResetPlanEndTime()
  20380. return nil
  20381. case soptask.FieldCreatorID:
  20382. m.ResetCreatorID()
  20383. return nil
  20384. case soptask.FieldOrganizationID:
  20385. m.ResetOrganizationID()
  20386. return nil
  20387. case soptask.FieldToken:
  20388. m.ResetToken()
  20389. return nil
  20390. }
  20391. return fmt.Errorf("unknown SopTask field %s", name)
  20392. }
  20393. // AddedEdges returns all edge names that were set/added in this mutation.
  20394. func (m *SopTaskMutation) AddedEdges() []string {
  20395. edges := make([]string, 0, 1)
  20396. if m.task_stages != nil {
  20397. edges = append(edges, soptask.EdgeTaskStages)
  20398. }
  20399. return edges
  20400. }
  20401. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20402. // name in this mutation.
  20403. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  20404. switch name {
  20405. case soptask.EdgeTaskStages:
  20406. ids := make([]ent.Value, 0, len(m.task_stages))
  20407. for id := range m.task_stages {
  20408. ids = append(ids, id)
  20409. }
  20410. return ids
  20411. }
  20412. return nil
  20413. }
  20414. // RemovedEdges returns all edge names that were removed in this mutation.
  20415. func (m *SopTaskMutation) RemovedEdges() []string {
  20416. edges := make([]string, 0, 1)
  20417. if m.removedtask_stages != nil {
  20418. edges = append(edges, soptask.EdgeTaskStages)
  20419. }
  20420. return edges
  20421. }
  20422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20423. // the given name in this mutation.
  20424. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  20425. switch name {
  20426. case soptask.EdgeTaskStages:
  20427. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  20428. for id := range m.removedtask_stages {
  20429. ids = append(ids, id)
  20430. }
  20431. return ids
  20432. }
  20433. return nil
  20434. }
  20435. // ClearedEdges returns all edge names that were cleared in this mutation.
  20436. func (m *SopTaskMutation) ClearedEdges() []string {
  20437. edges := make([]string, 0, 1)
  20438. if m.clearedtask_stages {
  20439. edges = append(edges, soptask.EdgeTaskStages)
  20440. }
  20441. return edges
  20442. }
  20443. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20444. // was cleared in this mutation.
  20445. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  20446. switch name {
  20447. case soptask.EdgeTaskStages:
  20448. return m.clearedtask_stages
  20449. }
  20450. return false
  20451. }
  20452. // ClearEdge clears the value of the edge with the given name. It returns an error
  20453. // if that edge is not defined in the schema.
  20454. func (m *SopTaskMutation) ClearEdge(name string) error {
  20455. switch name {
  20456. }
  20457. return fmt.Errorf("unknown SopTask unique edge %s", name)
  20458. }
  20459. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20460. // It returns an error if the edge is not defined in the schema.
  20461. func (m *SopTaskMutation) ResetEdge(name string) error {
  20462. switch name {
  20463. case soptask.EdgeTaskStages:
  20464. m.ResetTaskStages()
  20465. return nil
  20466. }
  20467. return fmt.Errorf("unknown SopTask edge %s", name)
  20468. }
  20469. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  20470. type TokenMutation struct {
  20471. config
  20472. op Op
  20473. typ string
  20474. id *uint64
  20475. created_at *time.Time
  20476. updated_at *time.Time
  20477. deleted_at *time.Time
  20478. expire_at *time.Time
  20479. token *string
  20480. mac *string
  20481. organization_id *uint64
  20482. addorganization_id *int64
  20483. custom_agent_base *string
  20484. custom_agent_key *string
  20485. openai_base *string
  20486. openai_key *string
  20487. clearedFields map[string]struct{}
  20488. agent *uint64
  20489. clearedagent bool
  20490. done bool
  20491. oldValue func(context.Context) (*Token, error)
  20492. predicates []predicate.Token
  20493. }
  20494. var _ ent.Mutation = (*TokenMutation)(nil)
  20495. // tokenOption allows management of the mutation configuration using functional options.
  20496. type tokenOption func(*TokenMutation)
  20497. // newTokenMutation creates new mutation for the Token entity.
  20498. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  20499. m := &TokenMutation{
  20500. config: c,
  20501. op: op,
  20502. typ: TypeToken,
  20503. clearedFields: make(map[string]struct{}),
  20504. }
  20505. for _, opt := range opts {
  20506. opt(m)
  20507. }
  20508. return m
  20509. }
  20510. // withTokenID sets the ID field of the mutation.
  20511. func withTokenID(id uint64) tokenOption {
  20512. return func(m *TokenMutation) {
  20513. var (
  20514. err error
  20515. once sync.Once
  20516. value *Token
  20517. )
  20518. m.oldValue = func(ctx context.Context) (*Token, error) {
  20519. once.Do(func() {
  20520. if m.done {
  20521. err = errors.New("querying old values post mutation is not allowed")
  20522. } else {
  20523. value, err = m.Client().Token.Get(ctx, id)
  20524. }
  20525. })
  20526. return value, err
  20527. }
  20528. m.id = &id
  20529. }
  20530. }
  20531. // withToken sets the old Token of the mutation.
  20532. func withToken(node *Token) tokenOption {
  20533. return func(m *TokenMutation) {
  20534. m.oldValue = func(context.Context) (*Token, error) {
  20535. return node, nil
  20536. }
  20537. m.id = &node.ID
  20538. }
  20539. }
  20540. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20541. // executed in a transaction (ent.Tx), a transactional client is returned.
  20542. func (m TokenMutation) Client() *Client {
  20543. client := &Client{config: m.config}
  20544. client.init()
  20545. return client
  20546. }
  20547. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20548. // it returns an error otherwise.
  20549. func (m TokenMutation) Tx() (*Tx, error) {
  20550. if _, ok := m.driver.(*txDriver); !ok {
  20551. return nil, errors.New("ent: mutation is not running in a transaction")
  20552. }
  20553. tx := &Tx{config: m.config}
  20554. tx.init()
  20555. return tx, nil
  20556. }
  20557. // SetID sets the value of the id field. Note that this
  20558. // operation is only accepted on creation of Token entities.
  20559. func (m *TokenMutation) SetID(id uint64) {
  20560. m.id = &id
  20561. }
  20562. // ID returns the ID value in the mutation. Note that the ID is only available
  20563. // if it was provided to the builder or after it was returned from the database.
  20564. func (m *TokenMutation) ID() (id uint64, exists bool) {
  20565. if m.id == nil {
  20566. return
  20567. }
  20568. return *m.id, true
  20569. }
  20570. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20571. // That means, if the mutation is applied within a transaction with an isolation level such
  20572. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20573. // or updated by the mutation.
  20574. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  20575. switch {
  20576. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20577. id, exists := m.ID()
  20578. if exists {
  20579. return []uint64{id}, nil
  20580. }
  20581. fallthrough
  20582. case m.op.Is(OpUpdate | OpDelete):
  20583. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  20584. default:
  20585. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20586. }
  20587. }
  20588. // SetCreatedAt sets the "created_at" field.
  20589. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  20590. m.created_at = &t
  20591. }
  20592. // CreatedAt returns the value of the "created_at" field in the mutation.
  20593. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  20594. v := m.created_at
  20595. if v == nil {
  20596. return
  20597. }
  20598. return *v, true
  20599. }
  20600. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  20601. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20603. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20604. if !m.op.Is(OpUpdateOne) {
  20605. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20606. }
  20607. if m.id == nil || m.oldValue == nil {
  20608. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20609. }
  20610. oldValue, err := m.oldValue(ctx)
  20611. if err != nil {
  20612. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20613. }
  20614. return oldValue.CreatedAt, nil
  20615. }
  20616. // ResetCreatedAt resets all changes to the "created_at" field.
  20617. func (m *TokenMutation) ResetCreatedAt() {
  20618. m.created_at = nil
  20619. }
  20620. // SetUpdatedAt sets the "updated_at" field.
  20621. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  20622. m.updated_at = &t
  20623. }
  20624. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20625. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  20626. v := m.updated_at
  20627. if v == nil {
  20628. return
  20629. }
  20630. return *v, true
  20631. }
  20632. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  20633. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20635. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20636. if !m.op.Is(OpUpdateOne) {
  20637. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20638. }
  20639. if m.id == nil || m.oldValue == nil {
  20640. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20641. }
  20642. oldValue, err := m.oldValue(ctx)
  20643. if err != nil {
  20644. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20645. }
  20646. return oldValue.UpdatedAt, nil
  20647. }
  20648. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20649. func (m *TokenMutation) ResetUpdatedAt() {
  20650. m.updated_at = nil
  20651. }
  20652. // SetDeletedAt sets the "deleted_at" field.
  20653. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  20654. m.deleted_at = &t
  20655. }
  20656. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20657. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  20658. v := m.deleted_at
  20659. if v == nil {
  20660. return
  20661. }
  20662. return *v, true
  20663. }
  20664. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  20665. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20667. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20668. if !m.op.Is(OpUpdateOne) {
  20669. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20670. }
  20671. if m.id == nil || m.oldValue == nil {
  20672. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20673. }
  20674. oldValue, err := m.oldValue(ctx)
  20675. if err != nil {
  20676. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20677. }
  20678. return oldValue.DeletedAt, nil
  20679. }
  20680. // ClearDeletedAt clears the value of the "deleted_at" field.
  20681. func (m *TokenMutation) ClearDeletedAt() {
  20682. m.deleted_at = nil
  20683. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  20684. }
  20685. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20686. func (m *TokenMutation) DeletedAtCleared() bool {
  20687. _, ok := m.clearedFields[token.FieldDeletedAt]
  20688. return ok
  20689. }
  20690. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20691. func (m *TokenMutation) ResetDeletedAt() {
  20692. m.deleted_at = nil
  20693. delete(m.clearedFields, token.FieldDeletedAt)
  20694. }
  20695. // SetExpireAt sets the "expire_at" field.
  20696. func (m *TokenMutation) SetExpireAt(t time.Time) {
  20697. m.expire_at = &t
  20698. }
  20699. // ExpireAt returns the value of the "expire_at" field in the mutation.
  20700. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  20701. v := m.expire_at
  20702. if v == nil {
  20703. return
  20704. }
  20705. return *v, true
  20706. }
  20707. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  20708. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20710. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  20711. if !m.op.Is(OpUpdateOne) {
  20712. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  20713. }
  20714. if m.id == nil || m.oldValue == nil {
  20715. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  20716. }
  20717. oldValue, err := m.oldValue(ctx)
  20718. if err != nil {
  20719. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  20720. }
  20721. return oldValue.ExpireAt, nil
  20722. }
  20723. // ClearExpireAt clears the value of the "expire_at" field.
  20724. func (m *TokenMutation) ClearExpireAt() {
  20725. m.expire_at = nil
  20726. m.clearedFields[token.FieldExpireAt] = struct{}{}
  20727. }
  20728. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  20729. func (m *TokenMutation) ExpireAtCleared() bool {
  20730. _, ok := m.clearedFields[token.FieldExpireAt]
  20731. return ok
  20732. }
  20733. // ResetExpireAt resets all changes to the "expire_at" field.
  20734. func (m *TokenMutation) ResetExpireAt() {
  20735. m.expire_at = nil
  20736. delete(m.clearedFields, token.FieldExpireAt)
  20737. }
  20738. // SetToken sets the "token" field.
  20739. func (m *TokenMutation) SetToken(s string) {
  20740. m.token = &s
  20741. }
  20742. // Token returns the value of the "token" field in the mutation.
  20743. func (m *TokenMutation) Token() (r string, exists bool) {
  20744. v := m.token
  20745. if v == nil {
  20746. return
  20747. }
  20748. return *v, true
  20749. }
  20750. // OldToken returns the old "token" field's value of the Token entity.
  20751. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20753. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  20754. if !m.op.Is(OpUpdateOne) {
  20755. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20756. }
  20757. if m.id == nil || m.oldValue == nil {
  20758. return v, errors.New("OldToken requires an ID field in the mutation")
  20759. }
  20760. oldValue, err := m.oldValue(ctx)
  20761. if err != nil {
  20762. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20763. }
  20764. return oldValue.Token, nil
  20765. }
  20766. // ClearToken clears the value of the "token" field.
  20767. func (m *TokenMutation) ClearToken() {
  20768. m.token = nil
  20769. m.clearedFields[token.FieldToken] = struct{}{}
  20770. }
  20771. // TokenCleared returns if the "token" field was cleared in this mutation.
  20772. func (m *TokenMutation) TokenCleared() bool {
  20773. _, ok := m.clearedFields[token.FieldToken]
  20774. return ok
  20775. }
  20776. // ResetToken resets all changes to the "token" field.
  20777. func (m *TokenMutation) ResetToken() {
  20778. m.token = nil
  20779. delete(m.clearedFields, token.FieldToken)
  20780. }
  20781. // SetMAC sets the "mac" field.
  20782. func (m *TokenMutation) SetMAC(s string) {
  20783. m.mac = &s
  20784. }
  20785. // MAC returns the value of the "mac" field in the mutation.
  20786. func (m *TokenMutation) MAC() (r string, exists bool) {
  20787. v := m.mac
  20788. if v == nil {
  20789. return
  20790. }
  20791. return *v, true
  20792. }
  20793. // OldMAC returns the old "mac" field's value of the Token entity.
  20794. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20796. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  20797. if !m.op.Is(OpUpdateOne) {
  20798. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  20799. }
  20800. if m.id == nil || m.oldValue == nil {
  20801. return v, errors.New("OldMAC requires an ID field in the mutation")
  20802. }
  20803. oldValue, err := m.oldValue(ctx)
  20804. if err != nil {
  20805. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  20806. }
  20807. return oldValue.MAC, nil
  20808. }
  20809. // ClearMAC clears the value of the "mac" field.
  20810. func (m *TokenMutation) ClearMAC() {
  20811. m.mac = nil
  20812. m.clearedFields[token.FieldMAC] = struct{}{}
  20813. }
  20814. // MACCleared returns if the "mac" field was cleared in this mutation.
  20815. func (m *TokenMutation) MACCleared() bool {
  20816. _, ok := m.clearedFields[token.FieldMAC]
  20817. return ok
  20818. }
  20819. // ResetMAC resets all changes to the "mac" field.
  20820. func (m *TokenMutation) ResetMAC() {
  20821. m.mac = nil
  20822. delete(m.clearedFields, token.FieldMAC)
  20823. }
  20824. // SetOrganizationID sets the "organization_id" field.
  20825. func (m *TokenMutation) SetOrganizationID(u uint64) {
  20826. m.organization_id = &u
  20827. m.addorganization_id = nil
  20828. }
  20829. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20830. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  20831. v := m.organization_id
  20832. if v == nil {
  20833. return
  20834. }
  20835. return *v, true
  20836. }
  20837. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  20838. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20840. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20841. if !m.op.Is(OpUpdateOne) {
  20842. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20843. }
  20844. if m.id == nil || m.oldValue == nil {
  20845. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20846. }
  20847. oldValue, err := m.oldValue(ctx)
  20848. if err != nil {
  20849. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20850. }
  20851. return oldValue.OrganizationID, nil
  20852. }
  20853. // AddOrganizationID adds u to the "organization_id" field.
  20854. func (m *TokenMutation) AddOrganizationID(u int64) {
  20855. if m.addorganization_id != nil {
  20856. *m.addorganization_id += u
  20857. } else {
  20858. m.addorganization_id = &u
  20859. }
  20860. }
  20861. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20862. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  20863. v := m.addorganization_id
  20864. if v == nil {
  20865. return
  20866. }
  20867. return *v, true
  20868. }
  20869. // ResetOrganizationID resets all changes to the "organization_id" field.
  20870. func (m *TokenMutation) ResetOrganizationID() {
  20871. m.organization_id = nil
  20872. m.addorganization_id = nil
  20873. }
  20874. // SetAgentID sets the "agent_id" field.
  20875. func (m *TokenMutation) SetAgentID(u uint64) {
  20876. m.agent = &u
  20877. }
  20878. // AgentID returns the value of the "agent_id" field in the mutation.
  20879. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  20880. v := m.agent
  20881. if v == nil {
  20882. return
  20883. }
  20884. return *v, true
  20885. }
  20886. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  20887. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20889. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  20890. if !m.op.Is(OpUpdateOne) {
  20891. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  20892. }
  20893. if m.id == nil || m.oldValue == nil {
  20894. return v, errors.New("OldAgentID requires an ID field in the mutation")
  20895. }
  20896. oldValue, err := m.oldValue(ctx)
  20897. if err != nil {
  20898. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  20899. }
  20900. return oldValue.AgentID, nil
  20901. }
  20902. // ResetAgentID resets all changes to the "agent_id" field.
  20903. func (m *TokenMutation) ResetAgentID() {
  20904. m.agent = nil
  20905. }
  20906. // SetCustomAgentBase sets the "custom_agent_base" field.
  20907. func (m *TokenMutation) SetCustomAgentBase(s string) {
  20908. m.custom_agent_base = &s
  20909. }
  20910. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  20911. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  20912. v := m.custom_agent_base
  20913. if v == nil {
  20914. return
  20915. }
  20916. return *v, true
  20917. }
  20918. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  20919. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20921. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  20922. if !m.op.Is(OpUpdateOne) {
  20923. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  20924. }
  20925. if m.id == nil || m.oldValue == nil {
  20926. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  20927. }
  20928. oldValue, err := m.oldValue(ctx)
  20929. if err != nil {
  20930. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  20931. }
  20932. return oldValue.CustomAgentBase, nil
  20933. }
  20934. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  20935. func (m *TokenMutation) ClearCustomAgentBase() {
  20936. m.custom_agent_base = nil
  20937. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  20938. }
  20939. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  20940. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  20941. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  20942. return ok
  20943. }
  20944. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  20945. func (m *TokenMutation) ResetCustomAgentBase() {
  20946. m.custom_agent_base = nil
  20947. delete(m.clearedFields, token.FieldCustomAgentBase)
  20948. }
  20949. // SetCustomAgentKey sets the "custom_agent_key" field.
  20950. func (m *TokenMutation) SetCustomAgentKey(s string) {
  20951. m.custom_agent_key = &s
  20952. }
  20953. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  20954. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  20955. v := m.custom_agent_key
  20956. if v == nil {
  20957. return
  20958. }
  20959. return *v, true
  20960. }
  20961. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  20962. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20964. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  20965. if !m.op.Is(OpUpdateOne) {
  20966. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  20967. }
  20968. if m.id == nil || m.oldValue == nil {
  20969. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  20970. }
  20971. oldValue, err := m.oldValue(ctx)
  20972. if err != nil {
  20973. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  20974. }
  20975. return oldValue.CustomAgentKey, nil
  20976. }
  20977. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  20978. func (m *TokenMutation) ClearCustomAgentKey() {
  20979. m.custom_agent_key = nil
  20980. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  20981. }
  20982. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  20983. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  20984. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  20985. return ok
  20986. }
  20987. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  20988. func (m *TokenMutation) ResetCustomAgentKey() {
  20989. m.custom_agent_key = nil
  20990. delete(m.clearedFields, token.FieldCustomAgentKey)
  20991. }
  20992. // SetOpenaiBase sets the "openai_base" field.
  20993. func (m *TokenMutation) SetOpenaiBase(s string) {
  20994. m.openai_base = &s
  20995. }
  20996. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  20997. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  20998. v := m.openai_base
  20999. if v == nil {
  21000. return
  21001. }
  21002. return *v, true
  21003. }
  21004. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  21005. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21007. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  21008. if !m.op.Is(OpUpdateOne) {
  21009. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  21010. }
  21011. if m.id == nil || m.oldValue == nil {
  21012. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  21013. }
  21014. oldValue, err := m.oldValue(ctx)
  21015. if err != nil {
  21016. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  21017. }
  21018. return oldValue.OpenaiBase, nil
  21019. }
  21020. // ClearOpenaiBase clears the value of the "openai_base" field.
  21021. func (m *TokenMutation) ClearOpenaiBase() {
  21022. m.openai_base = nil
  21023. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  21024. }
  21025. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  21026. func (m *TokenMutation) OpenaiBaseCleared() bool {
  21027. _, ok := m.clearedFields[token.FieldOpenaiBase]
  21028. return ok
  21029. }
  21030. // ResetOpenaiBase resets all changes to the "openai_base" field.
  21031. func (m *TokenMutation) ResetOpenaiBase() {
  21032. m.openai_base = nil
  21033. delete(m.clearedFields, token.FieldOpenaiBase)
  21034. }
  21035. // SetOpenaiKey sets the "openai_key" field.
  21036. func (m *TokenMutation) SetOpenaiKey(s string) {
  21037. m.openai_key = &s
  21038. }
  21039. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  21040. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  21041. v := m.openai_key
  21042. if v == nil {
  21043. return
  21044. }
  21045. return *v, true
  21046. }
  21047. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  21048. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21050. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  21051. if !m.op.Is(OpUpdateOne) {
  21052. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  21053. }
  21054. if m.id == nil || m.oldValue == nil {
  21055. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  21056. }
  21057. oldValue, err := m.oldValue(ctx)
  21058. if err != nil {
  21059. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  21060. }
  21061. return oldValue.OpenaiKey, nil
  21062. }
  21063. // ClearOpenaiKey clears the value of the "openai_key" field.
  21064. func (m *TokenMutation) ClearOpenaiKey() {
  21065. m.openai_key = nil
  21066. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  21067. }
  21068. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  21069. func (m *TokenMutation) OpenaiKeyCleared() bool {
  21070. _, ok := m.clearedFields[token.FieldOpenaiKey]
  21071. return ok
  21072. }
  21073. // ResetOpenaiKey resets all changes to the "openai_key" field.
  21074. func (m *TokenMutation) ResetOpenaiKey() {
  21075. m.openai_key = nil
  21076. delete(m.clearedFields, token.FieldOpenaiKey)
  21077. }
  21078. // ClearAgent clears the "agent" edge to the Agent entity.
  21079. func (m *TokenMutation) ClearAgent() {
  21080. m.clearedagent = true
  21081. m.clearedFields[token.FieldAgentID] = struct{}{}
  21082. }
  21083. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  21084. func (m *TokenMutation) AgentCleared() bool {
  21085. return m.clearedagent
  21086. }
  21087. // AgentIDs returns the "agent" edge IDs in the mutation.
  21088. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21089. // AgentID instead. It exists only for internal usage by the builders.
  21090. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  21091. if id := m.agent; id != nil {
  21092. ids = append(ids, *id)
  21093. }
  21094. return
  21095. }
  21096. // ResetAgent resets all changes to the "agent" edge.
  21097. func (m *TokenMutation) ResetAgent() {
  21098. m.agent = nil
  21099. m.clearedagent = false
  21100. }
  21101. // Where appends a list predicates to the TokenMutation builder.
  21102. func (m *TokenMutation) Where(ps ...predicate.Token) {
  21103. m.predicates = append(m.predicates, ps...)
  21104. }
  21105. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  21106. // users can use type-assertion to append predicates that do not depend on any generated package.
  21107. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  21108. p := make([]predicate.Token, len(ps))
  21109. for i := range ps {
  21110. p[i] = ps[i]
  21111. }
  21112. m.Where(p...)
  21113. }
  21114. // Op returns the operation name.
  21115. func (m *TokenMutation) Op() Op {
  21116. return m.op
  21117. }
  21118. // SetOp allows setting the mutation operation.
  21119. func (m *TokenMutation) SetOp(op Op) {
  21120. m.op = op
  21121. }
  21122. // Type returns the node type of this mutation (Token).
  21123. func (m *TokenMutation) Type() string {
  21124. return m.typ
  21125. }
  21126. // Fields returns all fields that were changed during this mutation. Note that in
  21127. // order to get all numeric fields that were incremented/decremented, call
  21128. // AddedFields().
  21129. func (m *TokenMutation) Fields() []string {
  21130. fields := make([]string, 0, 12)
  21131. if m.created_at != nil {
  21132. fields = append(fields, token.FieldCreatedAt)
  21133. }
  21134. if m.updated_at != nil {
  21135. fields = append(fields, token.FieldUpdatedAt)
  21136. }
  21137. if m.deleted_at != nil {
  21138. fields = append(fields, token.FieldDeletedAt)
  21139. }
  21140. if m.expire_at != nil {
  21141. fields = append(fields, token.FieldExpireAt)
  21142. }
  21143. if m.token != nil {
  21144. fields = append(fields, token.FieldToken)
  21145. }
  21146. if m.mac != nil {
  21147. fields = append(fields, token.FieldMAC)
  21148. }
  21149. if m.organization_id != nil {
  21150. fields = append(fields, token.FieldOrganizationID)
  21151. }
  21152. if m.agent != nil {
  21153. fields = append(fields, token.FieldAgentID)
  21154. }
  21155. if m.custom_agent_base != nil {
  21156. fields = append(fields, token.FieldCustomAgentBase)
  21157. }
  21158. if m.custom_agent_key != nil {
  21159. fields = append(fields, token.FieldCustomAgentKey)
  21160. }
  21161. if m.openai_base != nil {
  21162. fields = append(fields, token.FieldOpenaiBase)
  21163. }
  21164. if m.openai_key != nil {
  21165. fields = append(fields, token.FieldOpenaiKey)
  21166. }
  21167. return fields
  21168. }
  21169. // Field returns the value of a field with the given name. The second boolean
  21170. // return value indicates that this field was not set, or was not defined in the
  21171. // schema.
  21172. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  21173. switch name {
  21174. case token.FieldCreatedAt:
  21175. return m.CreatedAt()
  21176. case token.FieldUpdatedAt:
  21177. return m.UpdatedAt()
  21178. case token.FieldDeletedAt:
  21179. return m.DeletedAt()
  21180. case token.FieldExpireAt:
  21181. return m.ExpireAt()
  21182. case token.FieldToken:
  21183. return m.Token()
  21184. case token.FieldMAC:
  21185. return m.MAC()
  21186. case token.FieldOrganizationID:
  21187. return m.OrganizationID()
  21188. case token.FieldAgentID:
  21189. return m.AgentID()
  21190. case token.FieldCustomAgentBase:
  21191. return m.CustomAgentBase()
  21192. case token.FieldCustomAgentKey:
  21193. return m.CustomAgentKey()
  21194. case token.FieldOpenaiBase:
  21195. return m.OpenaiBase()
  21196. case token.FieldOpenaiKey:
  21197. return m.OpenaiKey()
  21198. }
  21199. return nil, false
  21200. }
  21201. // OldField returns the old value of the field from the database. An error is
  21202. // returned if the mutation operation is not UpdateOne, or the query to the
  21203. // database failed.
  21204. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21205. switch name {
  21206. case token.FieldCreatedAt:
  21207. return m.OldCreatedAt(ctx)
  21208. case token.FieldUpdatedAt:
  21209. return m.OldUpdatedAt(ctx)
  21210. case token.FieldDeletedAt:
  21211. return m.OldDeletedAt(ctx)
  21212. case token.FieldExpireAt:
  21213. return m.OldExpireAt(ctx)
  21214. case token.FieldToken:
  21215. return m.OldToken(ctx)
  21216. case token.FieldMAC:
  21217. return m.OldMAC(ctx)
  21218. case token.FieldOrganizationID:
  21219. return m.OldOrganizationID(ctx)
  21220. case token.FieldAgentID:
  21221. return m.OldAgentID(ctx)
  21222. case token.FieldCustomAgentBase:
  21223. return m.OldCustomAgentBase(ctx)
  21224. case token.FieldCustomAgentKey:
  21225. return m.OldCustomAgentKey(ctx)
  21226. case token.FieldOpenaiBase:
  21227. return m.OldOpenaiBase(ctx)
  21228. case token.FieldOpenaiKey:
  21229. return m.OldOpenaiKey(ctx)
  21230. }
  21231. return nil, fmt.Errorf("unknown Token field %s", name)
  21232. }
  21233. // SetField sets the value of a field with the given name. It returns an error if
  21234. // the field is not defined in the schema, or if the type mismatched the field
  21235. // type.
  21236. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  21237. switch name {
  21238. case token.FieldCreatedAt:
  21239. v, ok := value.(time.Time)
  21240. if !ok {
  21241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21242. }
  21243. m.SetCreatedAt(v)
  21244. return nil
  21245. case token.FieldUpdatedAt:
  21246. v, ok := value.(time.Time)
  21247. if !ok {
  21248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21249. }
  21250. m.SetUpdatedAt(v)
  21251. return nil
  21252. case token.FieldDeletedAt:
  21253. v, ok := value.(time.Time)
  21254. if !ok {
  21255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21256. }
  21257. m.SetDeletedAt(v)
  21258. return nil
  21259. case token.FieldExpireAt:
  21260. v, ok := value.(time.Time)
  21261. if !ok {
  21262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21263. }
  21264. m.SetExpireAt(v)
  21265. return nil
  21266. case token.FieldToken:
  21267. v, ok := value.(string)
  21268. if !ok {
  21269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21270. }
  21271. m.SetToken(v)
  21272. return nil
  21273. case token.FieldMAC:
  21274. v, ok := value.(string)
  21275. if !ok {
  21276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21277. }
  21278. m.SetMAC(v)
  21279. return nil
  21280. case token.FieldOrganizationID:
  21281. v, ok := value.(uint64)
  21282. if !ok {
  21283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21284. }
  21285. m.SetOrganizationID(v)
  21286. return nil
  21287. case token.FieldAgentID:
  21288. v, ok := value.(uint64)
  21289. if !ok {
  21290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21291. }
  21292. m.SetAgentID(v)
  21293. return nil
  21294. case token.FieldCustomAgentBase:
  21295. v, ok := value.(string)
  21296. if !ok {
  21297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21298. }
  21299. m.SetCustomAgentBase(v)
  21300. return nil
  21301. case token.FieldCustomAgentKey:
  21302. v, ok := value.(string)
  21303. if !ok {
  21304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21305. }
  21306. m.SetCustomAgentKey(v)
  21307. return nil
  21308. case token.FieldOpenaiBase:
  21309. v, ok := value.(string)
  21310. if !ok {
  21311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21312. }
  21313. m.SetOpenaiBase(v)
  21314. return nil
  21315. case token.FieldOpenaiKey:
  21316. v, ok := value.(string)
  21317. if !ok {
  21318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21319. }
  21320. m.SetOpenaiKey(v)
  21321. return nil
  21322. }
  21323. return fmt.Errorf("unknown Token field %s", name)
  21324. }
  21325. // AddedFields returns all numeric fields that were incremented/decremented during
  21326. // this mutation.
  21327. func (m *TokenMutation) AddedFields() []string {
  21328. var fields []string
  21329. if m.addorganization_id != nil {
  21330. fields = append(fields, token.FieldOrganizationID)
  21331. }
  21332. return fields
  21333. }
  21334. // AddedField returns the numeric value that was incremented/decremented on a field
  21335. // with the given name. The second boolean return value indicates that this field
  21336. // was not set, or was not defined in the schema.
  21337. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  21338. switch name {
  21339. case token.FieldOrganizationID:
  21340. return m.AddedOrganizationID()
  21341. }
  21342. return nil, false
  21343. }
  21344. // AddField adds the value to the field with the given name. It returns an error if
  21345. // the field is not defined in the schema, or if the type mismatched the field
  21346. // type.
  21347. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  21348. switch name {
  21349. case token.FieldOrganizationID:
  21350. v, ok := value.(int64)
  21351. if !ok {
  21352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21353. }
  21354. m.AddOrganizationID(v)
  21355. return nil
  21356. }
  21357. return fmt.Errorf("unknown Token numeric field %s", name)
  21358. }
  21359. // ClearedFields returns all nullable fields that were cleared during this
  21360. // mutation.
  21361. func (m *TokenMutation) ClearedFields() []string {
  21362. var fields []string
  21363. if m.FieldCleared(token.FieldDeletedAt) {
  21364. fields = append(fields, token.FieldDeletedAt)
  21365. }
  21366. if m.FieldCleared(token.FieldExpireAt) {
  21367. fields = append(fields, token.FieldExpireAt)
  21368. }
  21369. if m.FieldCleared(token.FieldToken) {
  21370. fields = append(fields, token.FieldToken)
  21371. }
  21372. if m.FieldCleared(token.FieldMAC) {
  21373. fields = append(fields, token.FieldMAC)
  21374. }
  21375. if m.FieldCleared(token.FieldCustomAgentBase) {
  21376. fields = append(fields, token.FieldCustomAgentBase)
  21377. }
  21378. if m.FieldCleared(token.FieldCustomAgentKey) {
  21379. fields = append(fields, token.FieldCustomAgentKey)
  21380. }
  21381. if m.FieldCleared(token.FieldOpenaiBase) {
  21382. fields = append(fields, token.FieldOpenaiBase)
  21383. }
  21384. if m.FieldCleared(token.FieldOpenaiKey) {
  21385. fields = append(fields, token.FieldOpenaiKey)
  21386. }
  21387. return fields
  21388. }
  21389. // FieldCleared returns a boolean indicating if a field with the given name was
  21390. // cleared in this mutation.
  21391. func (m *TokenMutation) FieldCleared(name string) bool {
  21392. _, ok := m.clearedFields[name]
  21393. return ok
  21394. }
  21395. // ClearField clears the value of the field with the given name. It returns an
  21396. // error if the field is not defined in the schema.
  21397. func (m *TokenMutation) ClearField(name string) error {
  21398. switch name {
  21399. case token.FieldDeletedAt:
  21400. m.ClearDeletedAt()
  21401. return nil
  21402. case token.FieldExpireAt:
  21403. m.ClearExpireAt()
  21404. return nil
  21405. case token.FieldToken:
  21406. m.ClearToken()
  21407. return nil
  21408. case token.FieldMAC:
  21409. m.ClearMAC()
  21410. return nil
  21411. case token.FieldCustomAgentBase:
  21412. m.ClearCustomAgentBase()
  21413. return nil
  21414. case token.FieldCustomAgentKey:
  21415. m.ClearCustomAgentKey()
  21416. return nil
  21417. case token.FieldOpenaiBase:
  21418. m.ClearOpenaiBase()
  21419. return nil
  21420. case token.FieldOpenaiKey:
  21421. m.ClearOpenaiKey()
  21422. return nil
  21423. }
  21424. return fmt.Errorf("unknown Token nullable field %s", name)
  21425. }
  21426. // ResetField resets all changes in the mutation for the field with the given name.
  21427. // It returns an error if the field is not defined in the schema.
  21428. func (m *TokenMutation) ResetField(name string) error {
  21429. switch name {
  21430. case token.FieldCreatedAt:
  21431. m.ResetCreatedAt()
  21432. return nil
  21433. case token.FieldUpdatedAt:
  21434. m.ResetUpdatedAt()
  21435. return nil
  21436. case token.FieldDeletedAt:
  21437. m.ResetDeletedAt()
  21438. return nil
  21439. case token.FieldExpireAt:
  21440. m.ResetExpireAt()
  21441. return nil
  21442. case token.FieldToken:
  21443. m.ResetToken()
  21444. return nil
  21445. case token.FieldMAC:
  21446. m.ResetMAC()
  21447. return nil
  21448. case token.FieldOrganizationID:
  21449. m.ResetOrganizationID()
  21450. return nil
  21451. case token.FieldAgentID:
  21452. m.ResetAgentID()
  21453. return nil
  21454. case token.FieldCustomAgentBase:
  21455. m.ResetCustomAgentBase()
  21456. return nil
  21457. case token.FieldCustomAgentKey:
  21458. m.ResetCustomAgentKey()
  21459. return nil
  21460. case token.FieldOpenaiBase:
  21461. m.ResetOpenaiBase()
  21462. return nil
  21463. case token.FieldOpenaiKey:
  21464. m.ResetOpenaiKey()
  21465. return nil
  21466. }
  21467. return fmt.Errorf("unknown Token field %s", name)
  21468. }
  21469. // AddedEdges returns all edge names that were set/added in this mutation.
  21470. func (m *TokenMutation) AddedEdges() []string {
  21471. edges := make([]string, 0, 1)
  21472. if m.agent != nil {
  21473. edges = append(edges, token.EdgeAgent)
  21474. }
  21475. return edges
  21476. }
  21477. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21478. // name in this mutation.
  21479. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  21480. switch name {
  21481. case token.EdgeAgent:
  21482. if id := m.agent; id != nil {
  21483. return []ent.Value{*id}
  21484. }
  21485. }
  21486. return nil
  21487. }
  21488. // RemovedEdges returns all edge names that were removed in this mutation.
  21489. func (m *TokenMutation) RemovedEdges() []string {
  21490. edges := make([]string, 0, 1)
  21491. return edges
  21492. }
  21493. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21494. // the given name in this mutation.
  21495. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  21496. return nil
  21497. }
  21498. // ClearedEdges returns all edge names that were cleared in this mutation.
  21499. func (m *TokenMutation) ClearedEdges() []string {
  21500. edges := make([]string, 0, 1)
  21501. if m.clearedagent {
  21502. edges = append(edges, token.EdgeAgent)
  21503. }
  21504. return edges
  21505. }
  21506. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21507. // was cleared in this mutation.
  21508. func (m *TokenMutation) EdgeCleared(name string) bool {
  21509. switch name {
  21510. case token.EdgeAgent:
  21511. return m.clearedagent
  21512. }
  21513. return false
  21514. }
  21515. // ClearEdge clears the value of the edge with the given name. It returns an error
  21516. // if that edge is not defined in the schema.
  21517. func (m *TokenMutation) ClearEdge(name string) error {
  21518. switch name {
  21519. case token.EdgeAgent:
  21520. m.ClearAgent()
  21521. return nil
  21522. }
  21523. return fmt.Errorf("unknown Token unique edge %s", name)
  21524. }
  21525. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21526. // It returns an error if the edge is not defined in the schema.
  21527. func (m *TokenMutation) ResetEdge(name string) error {
  21528. switch name {
  21529. case token.EdgeAgent:
  21530. m.ResetAgent()
  21531. return nil
  21532. }
  21533. return fmt.Errorf("unknown Token edge %s", name)
  21534. }
  21535. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  21536. type TutorialMutation struct {
  21537. config
  21538. op Op
  21539. typ string
  21540. id *uint64
  21541. created_at *time.Time
  21542. updated_at *time.Time
  21543. deleted_at *time.Time
  21544. index *int
  21545. addindex *int
  21546. title *string
  21547. content *string
  21548. organization_id *uint64
  21549. addorganization_id *int64
  21550. clearedFields map[string]struct{}
  21551. employee *uint64
  21552. clearedemployee bool
  21553. done bool
  21554. oldValue func(context.Context) (*Tutorial, error)
  21555. predicates []predicate.Tutorial
  21556. }
  21557. var _ ent.Mutation = (*TutorialMutation)(nil)
  21558. // tutorialOption allows management of the mutation configuration using functional options.
  21559. type tutorialOption func(*TutorialMutation)
  21560. // newTutorialMutation creates new mutation for the Tutorial entity.
  21561. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  21562. m := &TutorialMutation{
  21563. config: c,
  21564. op: op,
  21565. typ: TypeTutorial,
  21566. clearedFields: make(map[string]struct{}),
  21567. }
  21568. for _, opt := range opts {
  21569. opt(m)
  21570. }
  21571. return m
  21572. }
  21573. // withTutorialID sets the ID field of the mutation.
  21574. func withTutorialID(id uint64) tutorialOption {
  21575. return func(m *TutorialMutation) {
  21576. var (
  21577. err error
  21578. once sync.Once
  21579. value *Tutorial
  21580. )
  21581. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  21582. once.Do(func() {
  21583. if m.done {
  21584. err = errors.New("querying old values post mutation is not allowed")
  21585. } else {
  21586. value, err = m.Client().Tutorial.Get(ctx, id)
  21587. }
  21588. })
  21589. return value, err
  21590. }
  21591. m.id = &id
  21592. }
  21593. }
  21594. // withTutorial sets the old Tutorial of the mutation.
  21595. func withTutorial(node *Tutorial) tutorialOption {
  21596. return func(m *TutorialMutation) {
  21597. m.oldValue = func(context.Context) (*Tutorial, error) {
  21598. return node, nil
  21599. }
  21600. m.id = &node.ID
  21601. }
  21602. }
  21603. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21604. // executed in a transaction (ent.Tx), a transactional client is returned.
  21605. func (m TutorialMutation) Client() *Client {
  21606. client := &Client{config: m.config}
  21607. client.init()
  21608. return client
  21609. }
  21610. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21611. // it returns an error otherwise.
  21612. func (m TutorialMutation) Tx() (*Tx, error) {
  21613. if _, ok := m.driver.(*txDriver); !ok {
  21614. return nil, errors.New("ent: mutation is not running in a transaction")
  21615. }
  21616. tx := &Tx{config: m.config}
  21617. tx.init()
  21618. return tx, nil
  21619. }
  21620. // SetID sets the value of the id field. Note that this
  21621. // operation is only accepted on creation of Tutorial entities.
  21622. func (m *TutorialMutation) SetID(id uint64) {
  21623. m.id = &id
  21624. }
  21625. // ID returns the ID value in the mutation. Note that the ID is only available
  21626. // if it was provided to the builder or after it was returned from the database.
  21627. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  21628. if m.id == nil {
  21629. return
  21630. }
  21631. return *m.id, true
  21632. }
  21633. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21634. // That means, if the mutation is applied within a transaction with an isolation level such
  21635. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21636. // or updated by the mutation.
  21637. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  21638. switch {
  21639. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21640. id, exists := m.ID()
  21641. if exists {
  21642. return []uint64{id}, nil
  21643. }
  21644. fallthrough
  21645. case m.op.Is(OpUpdate | OpDelete):
  21646. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  21647. default:
  21648. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21649. }
  21650. }
  21651. // SetCreatedAt sets the "created_at" field.
  21652. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  21653. m.created_at = &t
  21654. }
  21655. // CreatedAt returns the value of the "created_at" field in the mutation.
  21656. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  21657. v := m.created_at
  21658. if v == nil {
  21659. return
  21660. }
  21661. return *v, true
  21662. }
  21663. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  21664. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21666. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21667. if !m.op.Is(OpUpdateOne) {
  21668. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21669. }
  21670. if m.id == nil || m.oldValue == nil {
  21671. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21672. }
  21673. oldValue, err := m.oldValue(ctx)
  21674. if err != nil {
  21675. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21676. }
  21677. return oldValue.CreatedAt, nil
  21678. }
  21679. // ResetCreatedAt resets all changes to the "created_at" field.
  21680. func (m *TutorialMutation) ResetCreatedAt() {
  21681. m.created_at = nil
  21682. }
  21683. // SetUpdatedAt sets the "updated_at" field.
  21684. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  21685. m.updated_at = &t
  21686. }
  21687. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21688. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  21689. v := m.updated_at
  21690. if v == nil {
  21691. return
  21692. }
  21693. return *v, true
  21694. }
  21695. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  21696. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21698. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21699. if !m.op.Is(OpUpdateOne) {
  21700. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21701. }
  21702. if m.id == nil || m.oldValue == nil {
  21703. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21704. }
  21705. oldValue, err := m.oldValue(ctx)
  21706. if err != nil {
  21707. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21708. }
  21709. return oldValue.UpdatedAt, nil
  21710. }
  21711. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21712. func (m *TutorialMutation) ResetUpdatedAt() {
  21713. m.updated_at = nil
  21714. }
  21715. // SetDeletedAt sets the "deleted_at" field.
  21716. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  21717. m.deleted_at = &t
  21718. }
  21719. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21720. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  21721. v := m.deleted_at
  21722. if v == nil {
  21723. return
  21724. }
  21725. return *v, true
  21726. }
  21727. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  21728. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21730. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21731. if !m.op.Is(OpUpdateOne) {
  21732. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21733. }
  21734. if m.id == nil || m.oldValue == nil {
  21735. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21736. }
  21737. oldValue, err := m.oldValue(ctx)
  21738. if err != nil {
  21739. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21740. }
  21741. return oldValue.DeletedAt, nil
  21742. }
  21743. // ClearDeletedAt clears the value of the "deleted_at" field.
  21744. func (m *TutorialMutation) ClearDeletedAt() {
  21745. m.deleted_at = nil
  21746. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  21747. }
  21748. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21749. func (m *TutorialMutation) DeletedAtCleared() bool {
  21750. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  21751. return ok
  21752. }
  21753. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21754. func (m *TutorialMutation) ResetDeletedAt() {
  21755. m.deleted_at = nil
  21756. delete(m.clearedFields, tutorial.FieldDeletedAt)
  21757. }
  21758. // SetEmployeeID sets the "employee_id" field.
  21759. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  21760. m.employee = &u
  21761. }
  21762. // EmployeeID returns the value of the "employee_id" field in the mutation.
  21763. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  21764. v := m.employee
  21765. if v == nil {
  21766. return
  21767. }
  21768. return *v, true
  21769. }
  21770. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  21771. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21773. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  21774. if !m.op.Is(OpUpdateOne) {
  21775. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  21776. }
  21777. if m.id == nil || m.oldValue == nil {
  21778. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  21779. }
  21780. oldValue, err := m.oldValue(ctx)
  21781. if err != nil {
  21782. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  21783. }
  21784. return oldValue.EmployeeID, nil
  21785. }
  21786. // ResetEmployeeID resets all changes to the "employee_id" field.
  21787. func (m *TutorialMutation) ResetEmployeeID() {
  21788. m.employee = nil
  21789. }
  21790. // SetIndex sets the "index" field.
  21791. func (m *TutorialMutation) SetIndex(i int) {
  21792. m.index = &i
  21793. m.addindex = nil
  21794. }
  21795. // Index returns the value of the "index" field in the mutation.
  21796. func (m *TutorialMutation) Index() (r int, exists bool) {
  21797. v := m.index
  21798. if v == nil {
  21799. return
  21800. }
  21801. return *v, true
  21802. }
  21803. // OldIndex returns the old "index" field's value of the Tutorial entity.
  21804. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21806. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  21807. if !m.op.Is(OpUpdateOne) {
  21808. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  21809. }
  21810. if m.id == nil || m.oldValue == nil {
  21811. return v, errors.New("OldIndex requires an ID field in the mutation")
  21812. }
  21813. oldValue, err := m.oldValue(ctx)
  21814. if err != nil {
  21815. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  21816. }
  21817. return oldValue.Index, nil
  21818. }
  21819. // AddIndex adds i to the "index" field.
  21820. func (m *TutorialMutation) AddIndex(i int) {
  21821. if m.addindex != nil {
  21822. *m.addindex += i
  21823. } else {
  21824. m.addindex = &i
  21825. }
  21826. }
  21827. // AddedIndex returns the value that was added to the "index" field in this mutation.
  21828. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  21829. v := m.addindex
  21830. if v == nil {
  21831. return
  21832. }
  21833. return *v, true
  21834. }
  21835. // ResetIndex resets all changes to the "index" field.
  21836. func (m *TutorialMutation) ResetIndex() {
  21837. m.index = nil
  21838. m.addindex = nil
  21839. }
  21840. // SetTitle sets the "title" field.
  21841. func (m *TutorialMutation) SetTitle(s string) {
  21842. m.title = &s
  21843. }
  21844. // Title returns the value of the "title" field in the mutation.
  21845. func (m *TutorialMutation) Title() (r string, exists bool) {
  21846. v := m.title
  21847. if v == nil {
  21848. return
  21849. }
  21850. return *v, true
  21851. }
  21852. // OldTitle returns the old "title" field's value of the Tutorial entity.
  21853. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21855. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  21856. if !m.op.Is(OpUpdateOne) {
  21857. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  21858. }
  21859. if m.id == nil || m.oldValue == nil {
  21860. return v, errors.New("OldTitle requires an ID field in the mutation")
  21861. }
  21862. oldValue, err := m.oldValue(ctx)
  21863. if err != nil {
  21864. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  21865. }
  21866. return oldValue.Title, nil
  21867. }
  21868. // ResetTitle resets all changes to the "title" field.
  21869. func (m *TutorialMutation) ResetTitle() {
  21870. m.title = nil
  21871. }
  21872. // SetContent sets the "content" field.
  21873. func (m *TutorialMutation) SetContent(s string) {
  21874. m.content = &s
  21875. }
  21876. // Content returns the value of the "content" field in the mutation.
  21877. func (m *TutorialMutation) Content() (r string, exists bool) {
  21878. v := m.content
  21879. if v == nil {
  21880. return
  21881. }
  21882. return *v, true
  21883. }
  21884. // OldContent returns the old "content" field's value of the Tutorial entity.
  21885. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21887. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  21888. if !m.op.Is(OpUpdateOne) {
  21889. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21890. }
  21891. if m.id == nil || m.oldValue == nil {
  21892. return v, errors.New("OldContent requires an ID field in the mutation")
  21893. }
  21894. oldValue, err := m.oldValue(ctx)
  21895. if err != nil {
  21896. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21897. }
  21898. return oldValue.Content, nil
  21899. }
  21900. // ResetContent resets all changes to the "content" field.
  21901. func (m *TutorialMutation) ResetContent() {
  21902. m.content = nil
  21903. }
  21904. // SetOrganizationID sets the "organization_id" field.
  21905. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  21906. m.organization_id = &u
  21907. m.addorganization_id = nil
  21908. }
  21909. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21910. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  21911. v := m.organization_id
  21912. if v == nil {
  21913. return
  21914. }
  21915. return *v, true
  21916. }
  21917. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  21918. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21920. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21921. if !m.op.Is(OpUpdateOne) {
  21922. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21923. }
  21924. if m.id == nil || m.oldValue == nil {
  21925. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21926. }
  21927. oldValue, err := m.oldValue(ctx)
  21928. if err != nil {
  21929. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21930. }
  21931. return oldValue.OrganizationID, nil
  21932. }
  21933. // AddOrganizationID adds u to the "organization_id" field.
  21934. func (m *TutorialMutation) AddOrganizationID(u int64) {
  21935. if m.addorganization_id != nil {
  21936. *m.addorganization_id += u
  21937. } else {
  21938. m.addorganization_id = &u
  21939. }
  21940. }
  21941. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21942. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  21943. v := m.addorganization_id
  21944. if v == nil {
  21945. return
  21946. }
  21947. return *v, true
  21948. }
  21949. // ResetOrganizationID resets all changes to the "organization_id" field.
  21950. func (m *TutorialMutation) ResetOrganizationID() {
  21951. m.organization_id = nil
  21952. m.addorganization_id = nil
  21953. }
  21954. // ClearEmployee clears the "employee" edge to the Employee entity.
  21955. func (m *TutorialMutation) ClearEmployee() {
  21956. m.clearedemployee = true
  21957. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  21958. }
  21959. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  21960. func (m *TutorialMutation) EmployeeCleared() bool {
  21961. return m.clearedemployee
  21962. }
  21963. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  21964. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21965. // EmployeeID instead. It exists only for internal usage by the builders.
  21966. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  21967. if id := m.employee; id != nil {
  21968. ids = append(ids, *id)
  21969. }
  21970. return
  21971. }
  21972. // ResetEmployee resets all changes to the "employee" edge.
  21973. func (m *TutorialMutation) ResetEmployee() {
  21974. m.employee = nil
  21975. m.clearedemployee = false
  21976. }
  21977. // Where appends a list predicates to the TutorialMutation builder.
  21978. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  21979. m.predicates = append(m.predicates, ps...)
  21980. }
  21981. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  21982. // users can use type-assertion to append predicates that do not depend on any generated package.
  21983. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  21984. p := make([]predicate.Tutorial, len(ps))
  21985. for i := range ps {
  21986. p[i] = ps[i]
  21987. }
  21988. m.Where(p...)
  21989. }
  21990. // Op returns the operation name.
  21991. func (m *TutorialMutation) Op() Op {
  21992. return m.op
  21993. }
  21994. // SetOp allows setting the mutation operation.
  21995. func (m *TutorialMutation) SetOp(op Op) {
  21996. m.op = op
  21997. }
  21998. // Type returns the node type of this mutation (Tutorial).
  21999. func (m *TutorialMutation) Type() string {
  22000. return m.typ
  22001. }
  22002. // Fields returns all fields that were changed during this mutation. Note that in
  22003. // order to get all numeric fields that were incremented/decremented, call
  22004. // AddedFields().
  22005. func (m *TutorialMutation) Fields() []string {
  22006. fields := make([]string, 0, 8)
  22007. if m.created_at != nil {
  22008. fields = append(fields, tutorial.FieldCreatedAt)
  22009. }
  22010. if m.updated_at != nil {
  22011. fields = append(fields, tutorial.FieldUpdatedAt)
  22012. }
  22013. if m.deleted_at != nil {
  22014. fields = append(fields, tutorial.FieldDeletedAt)
  22015. }
  22016. if m.employee != nil {
  22017. fields = append(fields, tutorial.FieldEmployeeID)
  22018. }
  22019. if m.index != nil {
  22020. fields = append(fields, tutorial.FieldIndex)
  22021. }
  22022. if m.title != nil {
  22023. fields = append(fields, tutorial.FieldTitle)
  22024. }
  22025. if m.content != nil {
  22026. fields = append(fields, tutorial.FieldContent)
  22027. }
  22028. if m.organization_id != nil {
  22029. fields = append(fields, tutorial.FieldOrganizationID)
  22030. }
  22031. return fields
  22032. }
  22033. // Field returns the value of a field with the given name. The second boolean
  22034. // return value indicates that this field was not set, or was not defined in the
  22035. // schema.
  22036. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  22037. switch name {
  22038. case tutorial.FieldCreatedAt:
  22039. return m.CreatedAt()
  22040. case tutorial.FieldUpdatedAt:
  22041. return m.UpdatedAt()
  22042. case tutorial.FieldDeletedAt:
  22043. return m.DeletedAt()
  22044. case tutorial.FieldEmployeeID:
  22045. return m.EmployeeID()
  22046. case tutorial.FieldIndex:
  22047. return m.Index()
  22048. case tutorial.FieldTitle:
  22049. return m.Title()
  22050. case tutorial.FieldContent:
  22051. return m.Content()
  22052. case tutorial.FieldOrganizationID:
  22053. return m.OrganizationID()
  22054. }
  22055. return nil, false
  22056. }
  22057. // OldField returns the old value of the field from the database. An error is
  22058. // returned if the mutation operation is not UpdateOne, or the query to the
  22059. // database failed.
  22060. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22061. switch name {
  22062. case tutorial.FieldCreatedAt:
  22063. return m.OldCreatedAt(ctx)
  22064. case tutorial.FieldUpdatedAt:
  22065. return m.OldUpdatedAt(ctx)
  22066. case tutorial.FieldDeletedAt:
  22067. return m.OldDeletedAt(ctx)
  22068. case tutorial.FieldEmployeeID:
  22069. return m.OldEmployeeID(ctx)
  22070. case tutorial.FieldIndex:
  22071. return m.OldIndex(ctx)
  22072. case tutorial.FieldTitle:
  22073. return m.OldTitle(ctx)
  22074. case tutorial.FieldContent:
  22075. return m.OldContent(ctx)
  22076. case tutorial.FieldOrganizationID:
  22077. return m.OldOrganizationID(ctx)
  22078. }
  22079. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  22080. }
  22081. // SetField sets the value of a field with the given name. It returns an error if
  22082. // the field is not defined in the schema, or if the type mismatched the field
  22083. // type.
  22084. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  22085. switch name {
  22086. case tutorial.FieldCreatedAt:
  22087. v, ok := value.(time.Time)
  22088. if !ok {
  22089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22090. }
  22091. m.SetCreatedAt(v)
  22092. return nil
  22093. case tutorial.FieldUpdatedAt:
  22094. v, ok := value.(time.Time)
  22095. if !ok {
  22096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22097. }
  22098. m.SetUpdatedAt(v)
  22099. return nil
  22100. case tutorial.FieldDeletedAt:
  22101. v, ok := value.(time.Time)
  22102. if !ok {
  22103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22104. }
  22105. m.SetDeletedAt(v)
  22106. return nil
  22107. case tutorial.FieldEmployeeID:
  22108. v, ok := value.(uint64)
  22109. if !ok {
  22110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22111. }
  22112. m.SetEmployeeID(v)
  22113. return nil
  22114. case tutorial.FieldIndex:
  22115. v, ok := value.(int)
  22116. if !ok {
  22117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22118. }
  22119. m.SetIndex(v)
  22120. return nil
  22121. case tutorial.FieldTitle:
  22122. v, ok := value.(string)
  22123. if !ok {
  22124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22125. }
  22126. m.SetTitle(v)
  22127. return nil
  22128. case tutorial.FieldContent:
  22129. v, ok := value.(string)
  22130. if !ok {
  22131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22132. }
  22133. m.SetContent(v)
  22134. return nil
  22135. case tutorial.FieldOrganizationID:
  22136. v, ok := value.(uint64)
  22137. if !ok {
  22138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22139. }
  22140. m.SetOrganizationID(v)
  22141. return nil
  22142. }
  22143. return fmt.Errorf("unknown Tutorial field %s", name)
  22144. }
  22145. // AddedFields returns all numeric fields that were incremented/decremented during
  22146. // this mutation.
  22147. func (m *TutorialMutation) AddedFields() []string {
  22148. var fields []string
  22149. if m.addindex != nil {
  22150. fields = append(fields, tutorial.FieldIndex)
  22151. }
  22152. if m.addorganization_id != nil {
  22153. fields = append(fields, tutorial.FieldOrganizationID)
  22154. }
  22155. return fields
  22156. }
  22157. // AddedField returns the numeric value that was incremented/decremented on a field
  22158. // with the given name. The second boolean return value indicates that this field
  22159. // was not set, or was not defined in the schema.
  22160. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  22161. switch name {
  22162. case tutorial.FieldIndex:
  22163. return m.AddedIndex()
  22164. case tutorial.FieldOrganizationID:
  22165. return m.AddedOrganizationID()
  22166. }
  22167. return nil, false
  22168. }
  22169. // AddField adds the value to the field with the given name. It returns an error if
  22170. // the field is not defined in the schema, or if the type mismatched the field
  22171. // type.
  22172. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  22173. switch name {
  22174. case tutorial.FieldIndex:
  22175. v, ok := value.(int)
  22176. if !ok {
  22177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22178. }
  22179. m.AddIndex(v)
  22180. return nil
  22181. case tutorial.FieldOrganizationID:
  22182. v, ok := value.(int64)
  22183. if !ok {
  22184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22185. }
  22186. m.AddOrganizationID(v)
  22187. return nil
  22188. }
  22189. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  22190. }
  22191. // ClearedFields returns all nullable fields that were cleared during this
  22192. // mutation.
  22193. func (m *TutorialMutation) ClearedFields() []string {
  22194. var fields []string
  22195. if m.FieldCleared(tutorial.FieldDeletedAt) {
  22196. fields = append(fields, tutorial.FieldDeletedAt)
  22197. }
  22198. return fields
  22199. }
  22200. // FieldCleared returns a boolean indicating if a field with the given name was
  22201. // cleared in this mutation.
  22202. func (m *TutorialMutation) FieldCleared(name string) bool {
  22203. _, ok := m.clearedFields[name]
  22204. return ok
  22205. }
  22206. // ClearField clears the value of the field with the given name. It returns an
  22207. // error if the field is not defined in the schema.
  22208. func (m *TutorialMutation) ClearField(name string) error {
  22209. switch name {
  22210. case tutorial.FieldDeletedAt:
  22211. m.ClearDeletedAt()
  22212. return nil
  22213. }
  22214. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  22215. }
  22216. // ResetField resets all changes in the mutation for the field with the given name.
  22217. // It returns an error if the field is not defined in the schema.
  22218. func (m *TutorialMutation) ResetField(name string) error {
  22219. switch name {
  22220. case tutorial.FieldCreatedAt:
  22221. m.ResetCreatedAt()
  22222. return nil
  22223. case tutorial.FieldUpdatedAt:
  22224. m.ResetUpdatedAt()
  22225. return nil
  22226. case tutorial.FieldDeletedAt:
  22227. m.ResetDeletedAt()
  22228. return nil
  22229. case tutorial.FieldEmployeeID:
  22230. m.ResetEmployeeID()
  22231. return nil
  22232. case tutorial.FieldIndex:
  22233. m.ResetIndex()
  22234. return nil
  22235. case tutorial.FieldTitle:
  22236. m.ResetTitle()
  22237. return nil
  22238. case tutorial.FieldContent:
  22239. m.ResetContent()
  22240. return nil
  22241. case tutorial.FieldOrganizationID:
  22242. m.ResetOrganizationID()
  22243. return nil
  22244. }
  22245. return fmt.Errorf("unknown Tutorial field %s", name)
  22246. }
  22247. // AddedEdges returns all edge names that were set/added in this mutation.
  22248. func (m *TutorialMutation) AddedEdges() []string {
  22249. edges := make([]string, 0, 1)
  22250. if m.employee != nil {
  22251. edges = append(edges, tutorial.EdgeEmployee)
  22252. }
  22253. return edges
  22254. }
  22255. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22256. // name in this mutation.
  22257. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  22258. switch name {
  22259. case tutorial.EdgeEmployee:
  22260. if id := m.employee; id != nil {
  22261. return []ent.Value{*id}
  22262. }
  22263. }
  22264. return nil
  22265. }
  22266. // RemovedEdges returns all edge names that were removed in this mutation.
  22267. func (m *TutorialMutation) RemovedEdges() []string {
  22268. edges := make([]string, 0, 1)
  22269. return edges
  22270. }
  22271. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22272. // the given name in this mutation.
  22273. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  22274. return nil
  22275. }
  22276. // ClearedEdges returns all edge names that were cleared in this mutation.
  22277. func (m *TutorialMutation) ClearedEdges() []string {
  22278. edges := make([]string, 0, 1)
  22279. if m.clearedemployee {
  22280. edges = append(edges, tutorial.EdgeEmployee)
  22281. }
  22282. return edges
  22283. }
  22284. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22285. // was cleared in this mutation.
  22286. func (m *TutorialMutation) EdgeCleared(name string) bool {
  22287. switch name {
  22288. case tutorial.EdgeEmployee:
  22289. return m.clearedemployee
  22290. }
  22291. return false
  22292. }
  22293. // ClearEdge clears the value of the edge with the given name. It returns an error
  22294. // if that edge is not defined in the schema.
  22295. func (m *TutorialMutation) ClearEdge(name string) error {
  22296. switch name {
  22297. case tutorial.EdgeEmployee:
  22298. m.ClearEmployee()
  22299. return nil
  22300. }
  22301. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  22302. }
  22303. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22304. // It returns an error if the edge is not defined in the schema.
  22305. func (m *TutorialMutation) ResetEdge(name string) error {
  22306. switch name {
  22307. case tutorial.EdgeEmployee:
  22308. m.ResetEmployee()
  22309. return nil
  22310. }
  22311. return fmt.Errorf("unknown Tutorial edge %s", name)
  22312. }
  22313. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  22314. type UsageDetailMutation struct {
  22315. config
  22316. op Op
  22317. typ string
  22318. id *uint64
  22319. created_at *time.Time
  22320. updated_at *time.Time
  22321. status *uint8
  22322. addstatus *int8
  22323. _type *int
  22324. add_type *int
  22325. bot_id *string
  22326. receiver_id *string
  22327. app *int
  22328. addapp *int
  22329. session_id *uint64
  22330. addsession_id *int64
  22331. request *string
  22332. response *string
  22333. total_tokens *uint64
  22334. addtotal_tokens *int64
  22335. prompt_tokens *uint64
  22336. addprompt_tokens *int64
  22337. completion_tokens *uint64
  22338. addcompletion_tokens *int64
  22339. organization_id *uint64
  22340. addorganization_id *int64
  22341. clearedFields map[string]struct{}
  22342. done bool
  22343. oldValue func(context.Context) (*UsageDetail, error)
  22344. predicates []predicate.UsageDetail
  22345. }
  22346. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  22347. // usagedetailOption allows management of the mutation configuration using functional options.
  22348. type usagedetailOption func(*UsageDetailMutation)
  22349. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  22350. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  22351. m := &UsageDetailMutation{
  22352. config: c,
  22353. op: op,
  22354. typ: TypeUsageDetail,
  22355. clearedFields: make(map[string]struct{}),
  22356. }
  22357. for _, opt := range opts {
  22358. opt(m)
  22359. }
  22360. return m
  22361. }
  22362. // withUsageDetailID sets the ID field of the mutation.
  22363. func withUsageDetailID(id uint64) usagedetailOption {
  22364. return func(m *UsageDetailMutation) {
  22365. var (
  22366. err error
  22367. once sync.Once
  22368. value *UsageDetail
  22369. )
  22370. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  22371. once.Do(func() {
  22372. if m.done {
  22373. err = errors.New("querying old values post mutation is not allowed")
  22374. } else {
  22375. value, err = m.Client().UsageDetail.Get(ctx, id)
  22376. }
  22377. })
  22378. return value, err
  22379. }
  22380. m.id = &id
  22381. }
  22382. }
  22383. // withUsageDetail sets the old UsageDetail of the mutation.
  22384. func withUsageDetail(node *UsageDetail) usagedetailOption {
  22385. return func(m *UsageDetailMutation) {
  22386. m.oldValue = func(context.Context) (*UsageDetail, error) {
  22387. return node, nil
  22388. }
  22389. m.id = &node.ID
  22390. }
  22391. }
  22392. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22393. // executed in a transaction (ent.Tx), a transactional client is returned.
  22394. func (m UsageDetailMutation) Client() *Client {
  22395. client := &Client{config: m.config}
  22396. client.init()
  22397. return client
  22398. }
  22399. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22400. // it returns an error otherwise.
  22401. func (m UsageDetailMutation) Tx() (*Tx, error) {
  22402. if _, ok := m.driver.(*txDriver); !ok {
  22403. return nil, errors.New("ent: mutation is not running in a transaction")
  22404. }
  22405. tx := &Tx{config: m.config}
  22406. tx.init()
  22407. return tx, nil
  22408. }
  22409. // SetID sets the value of the id field. Note that this
  22410. // operation is only accepted on creation of UsageDetail entities.
  22411. func (m *UsageDetailMutation) SetID(id uint64) {
  22412. m.id = &id
  22413. }
  22414. // ID returns the ID value in the mutation. Note that the ID is only available
  22415. // if it was provided to the builder or after it was returned from the database.
  22416. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  22417. if m.id == nil {
  22418. return
  22419. }
  22420. return *m.id, true
  22421. }
  22422. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22423. // That means, if the mutation is applied within a transaction with an isolation level such
  22424. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22425. // or updated by the mutation.
  22426. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  22427. switch {
  22428. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22429. id, exists := m.ID()
  22430. if exists {
  22431. return []uint64{id}, nil
  22432. }
  22433. fallthrough
  22434. case m.op.Is(OpUpdate | OpDelete):
  22435. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  22436. default:
  22437. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22438. }
  22439. }
  22440. // SetCreatedAt sets the "created_at" field.
  22441. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  22442. m.created_at = &t
  22443. }
  22444. // CreatedAt returns the value of the "created_at" field in the mutation.
  22445. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  22446. v := m.created_at
  22447. if v == nil {
  22448. return
  22449. }
  22450. return *v, true
  22451. }
  22452. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  22453. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22455. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22456. if !m.op.Is(OpUpdateOne) {
  22457. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22458. }
  22459. if m.id == nil || m.oldValue == nil {
  22460. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22461. }
  22462. oldValue, err := m.oldValue(ctx)
  22463. if err != nil {
  22464. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22465. }
  22466. return oldValue.CreatedAt, nil
  22467. }
  22468. // ResetCreatedAt resets all changes to the "created_at" field.
  22469. func (m *UsageDetailMutation) ResetCreatedAt() {
  22470. m.created_at = nil
  22471. }
  22472. // SetUpdatedAt sets the "updated_at" field.
  22473. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  22474. m.updated_at = &t
  22475. }
  22476. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22477. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  22478. v := m.updated_at
  22479. if v == nil {
  22480. return
  22481. }
  22482. return *v, true
  22483. }
  22484. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  22485. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22487. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22488. if !m.op.Is(OpUpdateOne) {
  22489. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22490. }
  22491. if m.id == nil || m.oldValue == nil {
  22492. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22493. }
  22494. oldValue, err := m.oldValue(ctx)
  22495. if err != nil {
  22496. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22497. }
  22498. return oldValue.UpdatedAt, nil
  22499. }
  22500. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22501. func (m *UsageDetailMutation) ResetUpdatedAt() {
  22502. m.updated_at = nil
  22503. }
  22504. // SetStatus sets the "status" field.
  22505. func (m *UsageDetailMutation) SetStatus(u uint8) {
  22506. m.status = &u
  22507. m.addstatus = nil
  22508. }
  22509. // Status returns the value of the "status" field in the mutation.
  22510. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  22511. v := m.status
  22512. if v == nil {
  22513. return
  22514. }
  22515. return *v, true
  22516. }
  22517. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  22518. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22520. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22521. if !m.op.Is(OpUpdateOne) {
  22522. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22523. }
  22524. if m.id == nil || m.oldValue == nil {
  22525. return v, errors.New("OldStatus requires an ID field in the mutation")
  22526. }
  22527. oldValue, err := m.oldValue(ctx)
  22528. if err != nil {
  22529. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22530. }
  22531. return oldValue.Status, nil
  22532. }
  22533. // AddStatus adds u to the "status" field.
  22534. func (m *UsageDetailMutation) AddStatus(u int8) {
  22535. if m.addstatus != nil {
  22536. *m.addstatus += u
  22537. } else {
  22538. m.addstatus = &u
  22539. }
  22540. }
  22541. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22542. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  22543. v := m.addstatus
  22544. if v == nil {
  22545. return
  22546. }
  22547. return *v, true
  22548. }
  22549. // ClearStatus clears the value of the "status" field.
  22550. func (m *UsageDetailMutation) ClearStatus() {
  22551. m.status = nil
  22552. m.addstatus = nil
  22553. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  22554. }
  22555. // StatusCleared returns if the "status" field was cleared in this mutation.
  22556. func (m *UsageDetailMutation) StatusCleared() bool {
  22557. _, ok := m.clearedFields[usagedetail.FieldStatus]
  22558. return ok
  22559. }
  22560. // ResetStatus resets all changes to the "status" field.
  22561. func (m *UsageDetailMutation) ResetStatus() {
  22562. m.status = nil
  22563. m.addstatus = nil
  22564. delete(m.clearedFields, usagedetail.FieldStatus)
  22565. }
  22566. // SetType sets the "type" field.
  22567. func (m *UsageDetailMutation) SetType(i int) {
  22568. m._type = &i
  22569. m.add_type = nil
  22570. }
  22571. // GetType returns the value of the "type" field in the mutation.
  22572. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  22573. v := m._type
  22574. if v == nil {
  22575. return
  22576. }
  22577. return *v, true
  22578. }
  22579. // OldType returns the old "type" field's value of the UsageDetail entity.
  22580. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22582. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  22583. if !m.op.Is(OpUpdateOne) {
  22584. return v, errors.New("OldType is only allowed on UpdateOne operations")
  22585. }
  22586. if m.id == nil || m.oldValue == nil {
  22587. return v, errors.New("OldType requires an ID field in the mutation")
  22588. }
  22589. oldValue, err := m.oldValue(ctx)
  22590. if err != nil {
  22591. return v, fmt.Errorf("querying old value for OldType: %w", err)
  22592. }
  22593. return oldValue.Type, nil
  22594. }
  22595. // AddType adds i to the "type" field.
  22596. func (m *UsageDetailMutation) AddType(i int) {
  22597. if m.add_type != nil {
  22598. *m.add_type += i
  22599. } else {
  22600. m.add_type = &i
  22601. }
  22602. }
  22603. // AddedType returns the value that was added to the "type" field in this mutation.
  22604. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  22605. v := m.add_type
  22606. if v == nil {
  22607. return
  22608. }
  22609. return *v, true
  22610. }
  22611. // ClearType clears the value of the "type" field.
  22612. func (m *UsageDetailMutation) ClearType() {
  22613. m._type = nil
  22614. m.add_type = nil
  22615. m.clearedFields[usagedetail.FieldType] = struct{}{}
  22616. }
  22617. // TypeCleared returns if the "type" field was cleared in this mutation.
  22618. func (m *UsageDetailMutation) TypeCleared() bool {
  22619. _, ok := m.clearedFields[usagedetail.FieldType]
  22620. return ok
  22621. }
  22622. // ResetType resets all changes to the "type" field.
  22623. func (m *UsageDetailMutation) ResetType() {
  22624. m._type = nil
  22625. m.add_type = nil
  22626. delete(m.clearedFields, usagedetail.FieldType)
  22627. }
  22628. // SetBotID sets the "bot_id" field.
  22629. func (m *UsageDetailMutation) SetBotID(s string) {
  22630. m.bot_id = &s
  22631. }
  22632. // BotID returns the value of the "bot_id" field in the mutation.
  22633. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  22634. v := m.bot_id
  22635. if v == nil {
  22636. return
  22637. }
  22638. return *v, true
  22639. }
  22640. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  22641. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22643. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  22644. if !m.op.Is(OpUpdateOne) {
  22645. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  22646. }
  22647. if m.id == nil || m.oldValue == nil {
  22648. return v, errors.New("OldBotID requires an ID field in the mutation")
  22649. }
  22650. oldValue, err := m.oldValue(ctx)
  22651. if err != nil {
  22652. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  22653. }
  22654. return oldValue.BotID, nil
  22655. }
  22656. // ResetBotID resets all changes to the "bot_id" field.
  22657. func (m *UsageDetailMutation) ResetBotID() {
  22658. m.bot_id = nil
  22659. }
  22660. // SetReceiverID sets the "receiver_id" field.
  22661. func (m *UsageDetailMutation) SetReceiverID(s string) {
  22662. m.receiver_id = &s
  22663. }
  22664. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  22665. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  22666. v := m.receiver_id
  22667. if v == nil {
  22668. return
  22669. }
  22670. return *v, true
  22671. }
  22672. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  22673. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22675. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  22676. if !m.op.Is(OpUpdateOne) {
  22677. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  22678. }
  22679. if m.id == nil || m.oldValue == nil {
  22680. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  22681. }
  22682. oldValue, err := m.oldValue(ctx)
  22683. if err != nil {
  22684. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  22685. }
  22686. return oldValue.ReceiverID, nil
  22687. }
  22688. // ResetReceiverID resets all changes to the "receiver_id" field.
  22689. func (m *UsageDetailMutation) ResetReceiverID() {
  22690. m.receiver_id = nil
  22691. }
  22692. // SetApp sets the "app" field.
  22693. func (m *UsageDetailMutation) SetApp(i int) {
  22694. m.app = &i
  22695. m.addapp = nil
  22696. }
  22697. // App returns the value of the "app" field in the mutation.
  22698. func (m *UsageDetailMutation) App() (r int, exists bool) {
  22699. v := m.app
  22700. if v == nil {
  22701. return
  22702. }
  22703. return *v, true
  22704. }
  22705. // OldApp returns the old "app" field's value of the UsageDetail entity.
  22706. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22708. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  22709. if !m.op.Is(OpUpdateOne) {
  22710. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  22711. }
  22712. if m.id == nil || m.oldValue == nil {
  22713. return v, errors.New("OldApp requires an ID field in the mutation")
  22714. }
  22715. oldValue, err := m.oldValue(ctx)
  22716. if err != nil {
  22717. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  22718. }
  22719. return oldValue.App, nil
  22720. }
  22721. // AddApp adds i to the "app" field.
  22722. func (m *UsageDetailMutation) AddApp(i int) {
  22723. if m.addapp != nil {
  22724. *m.addapp += i
  22725. } else {
  22726. m.addapp = &i
  22727. }
  22728. }
  22729. // AddedApp returns the value that was added to the "app" field in this mutation.
  22730. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  22731. v := m.addapp
  22732. if v == nil {
  22733. return
  22734. }
  22735. return *v, true
  22736. }
  22737. // ClearApp clears the value of the "app" field.
  22738. func (m *UsageDetailMutation) ClearApp() {
  22739. m.app = nil
  22740. m.addapp = nil
  22741. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  22742. }
  22743. // AppCleared returns if the "app" field was cleared in this mutation.
  22744. func (m *UsageDetailMutation) AppCleared() bool {
  22745. _, ok := m.clearedFields[usagedetail.FieldApp]
  22746. return ok
  22747. }
  22748. // ResetApp resets all changes to the "app" field.
  22749. func (m *UsageDetailMutation) ResetApp() {
  22750. m.app = nil
  22751. m.addapp = nil
  22752. delete(m.clearedFields, usagedetail.FieldApp)
  22753. }
  22754. // SetSessionID sets the "session_id" field.
  22755. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  22756. m.session_id = &u
  22757. m.addsession_id = nil
  22758. }
  22759. // SessionID returns the value of the "session_id" field in the mutation.
  22760. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  22761. v := m.session_id
  22762. if v == nil {
  22763. return
  22764. }
  22765. return *v, true
  22766. }
  22767. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  22768. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22770. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  22771. if !m.op.Is(OpUpdateOne) {
  22772. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  22773. }
  22774. if m.id == nil || m.oldValue == nil {
  22775. return v, errors.New("OldSessionID requires an ID field in the mutation")
  22776. }
  22777. oldValue, err := m.oldValue(ctx)
  22778. if err != nil {
  22779. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  22780. }
  22781. return oldValue.SessionID, nil
  22782. }
  22783. // AddSessionID adds u to the "session_id" field.
  22784. func (m *UsageDetailMutation) AddSessionID(u int64) {
  22785. if m.addsession_id != nil {
  22786. *m.addsession_id += u
  22787. } else {
  22788. m.addsession_id = &u
  22789. }
  22790. }
  22791. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  22792. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  22793. v := m.addsession_id
  22794. if v == nil {
  22795. return
  22796. }
  22797. return *v, true
  22798. }
  22799. // ClearSessionID clears the value of the "session_id" field.
  22800. func (m *UsageDetailMutation) ClearSessionID() {
  22801. m.session_id = nil
  22802. m.addsession_id = nil
  22803. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  22804. }
  22805. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  22806. func (m *UsageDetailMutation) SessionIDCleared() bool {
  22807. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  22808. return ok
  22809. }
  22810. // ResetSessionID resets all changes to the "session_id" field.
  22811. func (m *UsageDetailMutation) ResetSessionID() {
  22812. m.session_id = nil
  22813. m.addsession_id = nil
  22814. delete(m.clearedFields, usagedetail.FieldSessionID)
  22815. }
  22816. // SetRequest sets the "request" field.
  22817. func (m *UsageDetailMutation) SetRequest(s string) {
  22818. m.request = &s
  22819. }
  22820. // Request returns the value of the "request" field in the mutation.
  22821. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  22822. v := m.request
  22823. if v == nil {
  22824. return
  22825. }
  22826. return *v, true
  22827. }
  22828. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  22829. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22831. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  22832. if !m.op.Is(OpUpdateOne) {
  22833. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  22834. }
  22835. if m.id == nil || m.oldValue == nil {
  22836. return v, errors.New("OldRequest requires an ID field in the mutation")
  22837. }
  22838. oldValue, err := m.oldValue(ctx)
  22839. if err != nil {
  22840. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  22841. }
  22842. return oldValue.Request, nil
  22843. }
  22844. // ResetRequest resets all changes to the "request" field.
  22845. func (m *UsageDetailMutation) ResetRequest() {
  22846. m.request = nil
  22847. }
  22848. // SetResponse sets the "response" field.
  22849. func (m *UsageDetailMutation) SetResponse(s string) {
  22850. m.response = &s
  22851. }
  22852. // Response returns the value of the "response" field in the mutation.
  22853. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  22854. v := m.response
  22855. if v == nil {
  22856. return
  22857. }
  22858. return *v, true
  22859. }
  22860. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  22861. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22863. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  22864. if !m.op.Is(OpUpdateOne) {
  22865. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  22866. }
  22867. if m.id == nil || m.oldValue == nil {
  22868. return v, errors.New("OldResponse requires an ID field in the mutation")
  22869. }
  22870. oldValue, err := m.oldValue(ctx)
  22871. if err != nil {
  22872. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  22873. }
  22874. return oldValue.Response, nil
  22875. }
  22876. // ResetResponse resets all changes to the "response" field.
  22877. func (m *UsageDetailMutation) ResetResponse() {
  22878. m.response = nil
  22879. }
  22880. // SetTotalTokens sets the "total_tokens" field.
  22881. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  22882. m.total_tokens = &u
  22883. m.addtotal_tokens = nil
  22884. }
  22885. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  22886. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  22887. v := m.total_tokens
  22888. if v == nil {
  22889. return
  22890. }
  22891. return *v, true
  22892. }
  22893. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  22894. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22896. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  22897. if !m.op.Is(OpUpdateOne) {
  22898. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  22899. }
  22900. if m.id == nil || m.oldValue == nil {
  22901. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  22902. }
  22903. oldValue, err := m.oldValue(ctx)
  22904. if err != nil {
  22905. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  22906. }
  22907. return oldValue.TotalTokens, nil
  22908. }
  22909. // AddTotalTokens adds u to the "total_tokens" field.
  22910. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  22911. if m.addtotal_tokens != nil {
  22912. *m.addtotal_tokens += u
  22913. } else {
  22914. m.addtotal_tokens = &u
  22915. }
  22916. }
  22917. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  22918. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  22919. v := m.addtotal_tokens
  22920. if v == nil {
  22921. return
  22922. }
  22923. return *v, true
  22924. }
  22925. // ClearTotalTokens clears the value of the "total_tokens" field.
  22926. func (m *UsageDetailMutation) ClearTotalTokens() {
  22927. m.total_tokens = nil
  22928. m.addtotal_tokens = nil
  22929. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  22930. }
  22931. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  22932. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  22933. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  22934. return ok
  22935. }
  22936. // ResetTotalTokens resets all changes to the "total_tokens" field.
  22937. func (m *UsageDetailMutation) ResetTotalTokens() {
  22938. m.total_tokens = nil
  22939. m.addtotal_tokens = nil
  22940. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  22941. }
  22942. // SetPromptTokens sets the "prompt_tokens" field.
  22943. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  22944. m.prompt_tokens = &u
  22945. m.addprompt_tokens = nil
  22946. }
  22947. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  22948. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  22949. v := m.prompt_tokens
  22950. if v == nil {
  22951. return
  22952. }
  22953. return *v, true
  22954. }
  22955. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  22956. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22958. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  22959. if !m.op.Is(OpUpdateOne) {
  22960. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  22961. }
  22962. if m.id == nil || m.oldValue == nil {
  22963. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  22964. }
  22965. oldValue, err := m.oldValue(ctx)
  22966. if err != nil {
  22967. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  22968. }
  22969. return oldValue.PromptTokens, nil
  22970. }
  22971. // AddPromptTokens adds u to the "prompt_tokens" field.
  22972. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  22973. if m.addprompt_tokens != nil {
  22974. *m.addprompt_tokens += u
  22975. } else {
  22976. m.addprompt_tokens = &u
  22977. }
  22978. }
  22979. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  22980. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  22981. v := m.addprompt_tokens
  22982. if v == nil {
  22983. return
  22984. }
  22985. return *v, true
  22986. }
  22987. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  22988. func (m *UsageDetailMutation) ClearPromptTokens() {
  22989. m.prompt_tokens = nil
  22990. m.addprompt_tokens = nil
  22991. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  22992. }
  22993. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  22994. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  22995. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  22996. return ok
  22997. }
  22998. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  22999. func (m *UsageDetailMutation) ResetPromptTokens() {
  23000. m.prompt_tokens = nil
  23001. m.addprompt_tokens = nil
  23002. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  23003. }
  23004. // SetCompletionTokens sets the "completion_tokens" field.
  23005. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  23006. m.completion_tokens = &u
  23007. m.addcompletion_tokens = nil
  23008. }
  23009. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  23010. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  23011. v := m.completion_tokens
  23012. if v == nil {
  23013. return
  23014. }
  23015. return *v, true
  23016. }
  23017. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  23018. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23020. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  23021. if !m.op.Is(OpUpdateOne) {
  23022. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  23023. }
  23024. if m.id == nil || m.oldValue == nil {
  23025. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  23026. }
  23027. oldValue, err := m.oldValue(ctx)
  23028. if err != nil {
  23029. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  23030. }
  23031. return oldValue.CompletionTokens, nil
  23032. }
  23033. // AddCompletionTokens adds u to the "completion_tokens" field.
  23034. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  23035. if m.addcompletion_tokens != nil {
  23036. *m.addcompletion_tokens += u
  23037. } else {
  23038. m.addcompletion_tokens = &u
  23039. }
  23040. }
  23041. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  23042. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  23043. v := m.addcompletion_tokens
  23044. if v == nil {
  23045. return
  23046. }
  23047. return *v, true
  23048. }
  23049. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  23050. func (m *UsageDetailMutation) ClearCompletionTokens() {
  23051. m.completion_tokens = nil
  23052. m.addcompletion_tokens = nil
  23053. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  23054. }
  23055. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  23056. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  23057. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  23058. return ok
  23059. }
  23060. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  23061. func (m *UsageDetailMutation) ResetCompletionTokens() {
  23062. m.completion_tokens = nil
  23063. m.addcompletion_tokens = nil
  23064. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  23065. }
  23066. // SetOrganizationID sets the "organization_id" field.
  23067. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  23068. m.organization_id = &u
  23069. m.addorganization_id = nil
  23070. }
  23071. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23072. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  23073. v := m.organization_id
  23074. if v == nil {
  23075. return
  23076. }
  23077. return *v, true
  23078. }
  23079. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  23080. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23082. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23083. if !m.op.Is(OpUpdateOne) {
  23084. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23085. }
  23086. if m.id == nil || m.oldValue == nil {
  23087. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23088. }
  23089. oldValue, err := m.oldValue(ctx)
  23090. if err != nil {
  23091. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23092. }
  23093. return oldValue.OrganizationID, nil
  23094. }
  23095. // AddOrganizationID adds u to the "organization_id" field.
  23096. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  23097. if m.addorganization_id != nil {
  23098. *m.addorganization_id += u
  23099. } else {
  23100. m.addorganization_id = &u
  23101. }
  23102. }
  23103. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23104. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  23105. v := m.addorganization_id
  23106. if v == nil {
  23107. return
  23108. }
  23109. return *v, true
  23110. }
  23111. // ClearOrganizationID clears the value of the "organization_id" field.
  23112. func (m *UsageDetailMutation) ClearOrganizationID() {
  23113. m.organization_id = nil
  23114. m.addorganization_id = nil
  23115. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  23116. }
  23117. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23118. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  23119. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  23120. return ok
  23121. }
  23122. // ResetOrganizationID resets all changes to the "organization_id" field.
  23123. func (m *UsageDetailMutation) ResetOrganizationID() {
  23124. m.organization_id = nil
  23125. m.addorganization_id = nil
  23126. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  23127. }
  23128. // Where appends a list predicates to the UsageDetailMutation builder.
  23129. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  23130. m.predicates = append(m.predicates, ps...)
  23131. }
  23132. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  23133. // users can use type-assertion to append predicates that do not depend on any generated package.
  23134. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  23135. p := make([]predicate.UsageDetail, len(ps))
  23136. for i := range ps {
  23137. p[i] = ps[i]
  23138. }
  23139. m.Where(p...)
  23140. }
  23141. // Op returns the operation name.
  23142. func (m *UsageDetailMutation) Op() Op {
  23143. return m.op
  23144. }
  23145. // SetOp allows setting the mutation operation.
  23146. func (m *UsageDetailMutation) SetOp(op Op) {
  23147. m.op = op
  23148. }
  23149. // Type returns the node type of this mutation (UsageDetail).
  23150. func (m *UsageDetailMutation) Type() string {
  23151. return m.typ
  23152. }
  23153. // Fields returns all fields that were changed during this mutation. Note that in
  23154. // order to get all numeric fields that were incremented/decremented, call
  23155. // AddedFields().
  23156. func (m *UsageDetailMutation) Fields() []string {
  23157. fields := make([]string, 0, 14)
  23158. if m.created_at != nil {
  23159. fields = append(fields, usagedetail.FieldCreatedAt)
  23160. }
  23161. if m.updated_at != nil {
  23162. fields = append(fields, usagedetail.FieldUpdatedAt)
  23163. }
  23164. if m.status != nil {
  23165. fields = append(fields, usagedetail.FieldStatus)
  23166. }
  23167. if m._type != nil {
  23168. fields = append(fields, usagedetail.FieldType)
  23169. }
  23170. if m.bot_id != nil {
  23171. fields = append(fields, usagedetail.FieldBotID)
  23172. }
  23173. if m.receiver_id != nil {
  23174. fields = append(fields, usagedetail.FieldReceiverID)
  23175. }
  23176. if m.app != nil {
  23177. fields = append(fields, usagedetail.FieldApp)
  23178. }
  23179. if m.session_id != nil {
  23180. fields = append(fields, usagedetail.FieldSessionID)
  23181. }
  23182. if m.request != nil {
  23183. fields = append(fields, usagedetail.FieldRequest)
  23184. }
  23185. if m.response != nil {
  23186. fields = append(fields, usagedetail.FieldResponse)
  23187. }
  23188. if m.total_tokens != nil {
  23189. fields = append(fields, usagedetail.FieldTotalTokens)
  23190. }
  23191. if m.prompt_tokens != nil {
  23192. fields = append(fields, usagedetail.FieldPromptTokens)
  23193. }
  23194. if m.completion_tokens != nil {
  23195. fields = append(fields, usagedetail.FieldCompletionTokens)
  23196. }
  23197. if m.organization_id != nil {
  23198. fields = append(fields, usagedetail.FieldOrganizationID)
  23199. }
  23200. return fields
  23201. }
  23202. // Field returns the value of a field with the given name. The second boolean
  23203. // return value indicates that this field was not set, or was not defined in the
  23204. // schema.
  23205. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  23206. switch name {
  23207. case usagedetail.FieldCreatedAt:
  23208. return m.CreatedAt()
  23209. case usagedetail.FieldUpdatedAt:
  23210. return m.UpdatedAt()
  23211. case usagedetail.FieldStatus:
  23212. return m.Status()
  23213. case usagedetail.FieldType:
  23214. return m.GetType()
  23215. case usagedetail.FieldBotID:
  23216. return m.BotID()
  23217. case usagedetail.FieldReceiverID:
  23218. return m.ReceiverID()
  23219. case usagedetail.FieldApp:
  23220. return m.App()
  23221. case usagedetail.FieldSessionID:
  23222. return m.SessionID()
  23223. case usagedetail.FieldRequest:
  23224. return m.Request()
  23225. case usagedetail.FieldResponse:
  23226. return m.Response()
  23227. case usagedetail.FieldTotalTokens:
  23228. return m.TotalTokens()
  23229. case usagedetail.FieldPromptTokens:
  23230. return m.PromptTokens()
  23231. case usagedetail.FieldCompletionTokens:
  23232. return m.CompletionTokens()
  23233. case usagedetail.FieldOrganizationID:
  23234. return m.OrganizationID()
  23235. }
  23236. return nil, false
  23237. }
  23238. // OldField returns the old value of the field from the database. An error is
  23239. // returned if the mutation operation is not UpdateOne, or the query to the
  23240. // database failed.
  23241. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23242. switch name {
  23243. case usagedetail.FieldCreatedAt:
  23244. return m.OldCreatedAt(ctx)
  23245. case usagedetail.FieldUpdatedAt:
  23246. return m.OldUpdatedAt(ctx)
  23247. case usagedetail.FieldStatus:
  23248. return m.OldStatus(ctx)
  23249. case usagedetail.FieldType:
  23250. return m.OldType(ctx)
  23251. case usagedetail.FieldBotID:
  23252. return m.OldBotID(ctx)
  23253. case usagedetail.FieldReceiverID:
  23254. return m.OldReceiverID(ctx)
  23255. case usagedetail.FieldApp:
  23256. return m.OldApp(ctx)
  23257. case usagedetail.FieldSessionID:
  23258. return m.OldSessionID(ctx)
  23259. case usagedetail.FieldRequest:
  23260. return m.OldRequest(ctx)
  23261. case usagedetail.FieldResponse:
  23262. return m.OldResponse(ctx)
  23263. case usagedetail.FieldTotalTokens:
  23264. return m.OldTotalTokens(ctx)
  23265. case usagedetail.FieldPromptTokens:
  23266. return m.OldPromptTokens(ctx)
  23267. case usagedetail.FieldCompletionTokens:
  23268. return m.OldCompletionTokens(ctx)
  23269. case usagedetail.FieldOrganizationID:
  23270. return m.OldOrganizationID(ctx)
  23271. }
  23272. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  23273. }
  23274. // SetField sets the value of a field with the given name. It returns an error if
  23275. // the field is not defined in the schema, or if the type mismatched the field
  23276. // type.
  23277. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  23278. switch name {
  23279. case usagedetail.FieldCreatedAt:
  23280. v, ok := value.(time.Time)
  23281. if !ok {
  23282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23283. }
  23284. m.SetCreatedAt(v)
  23285. return nil
  23286. case usagedetail.FieldUpdatedAt:
  23287. v, ok := value.(time.Time)
  23288. if !ok {
  23289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23290. }
  23291. m.SetUpdatedAt(v)
  23292. return nil
  23293. case usagedetail.FieldStatus:
  23294. v, ok := value.(uint8)
  23295. if !ok {
  23296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23297. }
  23298. m.SetStatus(v)
  23299. return nil
  23300. case usagedetail.FieldType:
  23301. v, ok := value.(int)
  23302. if !ok {
  23303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23304. }
  23305. m.SetType(v)
  23306. return nil
  23307. case usagedetail.FieldBotID:
  23308. v, ok := value.(string)
  23309. if !ok {
  23310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23311. }
  23312. m.SetBotID(v)
  23313. return nil
  23314. case usagedetail.FieldReceiverID:
  23315. v, ok := value.(string)
  23316. if !ok {
  23317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23318. }
  23319. m.SetReceiverID(v)
  23320. return nil
  23321. case usagedetail.FieldApp:
  23322. v, ok := value.(int)
  23323. if !ok {
  23324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23325. }
  23326. m.SetApp(v)
  23327. return nil
  23328. case usagedetail.FieldSessionID:
  23329. v, ok := value.(uint64)
  23330. if !ok {
  23331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23332. }
  23333. m.SetSessionID(v)
  23334. return nil
  23335. case usagedetail.FieldRequest:
  23336. v, ok := value.(string)
  23337. if !ok {
  23338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23339. }
  23340. m.SetRequest(v)
  23341. return nil
  23342. case usagedetail.FieldResponse:
  23343. v, ok := value.(string)
  23344. if !ok {
  23345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23346. }
  23347. m.SetResponse(v)
  23348. return nil
  23349. case usagedetail.FieldTotalTokens:
  23350. v, ok := value.(uint64)
  23351. if !ok {
  23352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23353. }
  23354. m.SetTotalTokens(v)
  23355. return nil
  23356. case usagedetail.FieldPromptTokens:
  23357. v, ok := value.(uint64)
  23358. if !ok {
  23359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23360. }
  23361. m.SetPromptTokens(v)
  23362. return nil
  23363. case usagedetail.FieldCompletionTokens:
  23364. v, ok := value.(uint64)
  23365. if !ok {
  23366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23367. }
  23368. m.SetCompletionTokens(v)
  23369. return nil
  23370. case usagedetail.FieldOrganizationID:
  23371. v, ok := value.(uint64)
  23372. if !ok {
  23373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23374. }
  23375. m.SetOrganizationID(v)
  23376. return nil
  23377. }
  23378. return fmt.Errorf("unknown UsageDetail field %s", name)
  23379. }
  23380. // AddedFields returns all numeric fields that were incremented/decremented during
  23381. // this mutation.
  23382. func (m *UsageDetailMutation) AddedFields() []string {
  23383. var fields []string
  23384. if m.addstatus != nil {
  23385. fields = append(fields, usagedetail.FieldStatus)
  23386. }
  23387. if m.add_type != nil {
  23388. fields = append(fields, usagedetail.FieldType)
  23389. }
  23390. if m.addapp != nil {
  23391. fields = append(fields, usagedetail.FieldApp)
  23392. }
  23393. if m.addsession_id != nil {
  23394. fields = append(fields, usagedetail.FieldSessionID)
  23395. }
  23396. if m.addtotal_tokens != nil {
  23397. fields = append(fields, usagedetail.FieldTotalTokens)
  23398. }
  23399. if m.addprompt_tokens != nil {
  23400. fields = append(fields, usagedetail.FieldPromptTokens)
  23401. }
  23402. if m.addcompletion_tokens != nil {
  23403. fields = append(fields, usagedetail.FieldCompletionTokens)
  23404. }
  23405. if m.addorganization_id != nil {
  23406. fields = append(fields, usagedetail.FieldOrganizationID)
  23407. }
  23408. return fields
  23409. }
  23410. // AddedField returns the numeric value that was incremented/decremented on a field
  23411. // with the given name. The second boolean return value indicates that this field
  23412. // was not set, or was not defined in the schema.
  23413. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  23414. switch name {
  23415. case usagedetail.FieldStatus:
  23416. return m.AddedStatus()
  23417. case usagedetail.FieldType:
  23418. return m.AddedType()
  23419. case usagedetail.FieldApp:
  23420. return m.AddedApp()
  23421. case usagedetail.FieldSessionID:
  23422. return m.AddedSessionID()
  23423. case usagedetail.FieldTotalTokens:
  23424. return m.AddedTotalTokens()
  23425. case usagedetail.FieldPromptTokens:
  23426. return m.AddedPromptTokens()
  23427. case usagedetail.FieldCompletionTokens:
  23428. return m.AddedCompletionTokens()
  23429. case usagedetail.FieldOrganizationID:
  23430. return m.AddedOrganizationID()
  23431. }
  23432. return nil, false
  23433. }
  23434. // AddField adds the value to the field with the given name. It returns an error if
  23435. // the field is not defined in the schema, or if the type mismatched the field
  23436. // type.
  23437. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  23438. switch name {
  23439. case usagedetail.FieldStatus:
  23440. v, ok := value.(int8)
  23441. if !ok {
  23442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23443. }
  23444. m.AddStatus(v)
  23445. return nil
  23446. case usagedetail.FieldType:
  23447. v, ok := value.(int)
  23448. if !ok {
  23449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23450. }
  23451. m.AddType(v)
  23452. return nil
  23453. case usagedetail.FieldApp:
  23454. v, ok := value.(int)
  23455. if !ok {
  23456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23457. }
  23458. m.AddApp(v)
  23459. return nil
  23460. case usagedetail.FieldSessionID:
  23461. v, ok := value.(int64)
  23462. if !ok {
  23463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23464. }
  23465. m.AddSessionID(v)
  23466. return nil
  23467. case usagedetail.FieldTotalTokens:
  23468. v, ok := value.(int64)
  23469. if !ok {
  23470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23471. }
  23472. m.AddTotalTokens(v)
  23473. return nil
  23474. case usagedetail.FieldPromptTokens:
  23475. v, ok := value.(int64)
  23476. if !ok {
  23477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23478. }
  23479. m.AddPromptTokens(v)
  23480. return nil
  23481. case usagedetail.FieldCompletionTokens:
  23482. v, ok := value.(int64)
  23483. if !ok {
  23484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23485. }
  23486. m.AddCompletionTokens(v)
  23487. return nil
  23488. case usagedetail.FieldOrganizationID:
  23489. v, ok := value.(int64)
  23490. if !ok {
  23491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23492. }
  23493. m.AddOrganizationID(v)
  23494. return nil
  23495. }
  23496. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  23497. }
  23498. // ClearedFields returns all nullable fields that were cleared during this
  23499. // mutation.
  23500. func (m *UsageDetailMutation) ClearedFields() []string {
  23501. var fields []string
  23502. if m.FieldCleared(usagedetail.FieldStatus) {
  23503. fields = append(fields, usagedetail.FieldStatus)
  23504. }
  23505. if m.FieldCleared(usagedetail.FieldType) {
  23506. fields = append(fields, usagedetail.FieldType)
  23507. }
  23508. if m.FieldCleared(usagedetail.FieldApp) {
  23509. fields = append(fields, usagedetail.FieldApp)
  23510. }
  23511. if m.FieldCleared(usagedetail.FieldSessionID) {
  23512. fields = append(fields, usagedetail.FieldSessionID)
  23513. }
  23514. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  23515. fields = append(fields, usagedetail.FieldTotalTokens)
  23516. }
  23517. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  23518. fields = append(fields, usagedetail.FieldPromptTokens)
  23519. }
  23520. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  23521. fields = append(fields, usagedetail.FieldCompletionTokens)
  23522. }
  23523. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  23524. fields = append(fields, usagedetail.FieldOrganizationID)
  23525. }
  23526. return fields
  23527. }
  23528. // FieldCleared returns a boolean indicating if a field with the given name was
  23529. // cleared in this mutation.
  23530. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  23531. _, ok := m.clearedFields[name]
  23532. return ok
  23533. }
  23534. // ClearField clears the value of the field with the given name. It returns an
  23535. // error if the field is not defined in the schema.
  23536. func (m *UsageDetailMutation) ClearField(name string) error {
  23537. switch name {
  23538. case usagedetail.FieldStatus:
  23539. m.ClearStatus()
  23540. return nil
  23541. case usagedetail.FieldType:
  23542. m.ClearType()
  23543. return nil
  23544. case usagedetail.FieldApp:
  23545. m.ClearApp()
  23546. return nil
  23547. case usagedetail.FieldSessionID:
  23548. m.ClearSessionID()
  23549. return nil
  23550. case usagedetail.FieldTotalTokens:
  23551. m.ClearTotalTokens()
  23552. return nil
  23553. case usagedetail.FieldPromptTokens:
  23554. m.ClearPromptTokens()
  23555. return nil
  23556. case usagedetail.FieldCompletionTokens:
  23557. m.ClearCompletionTokens()
  23558. return nil
  23559. case usagedetail.FieldOrganizationID:
  23560. m.ClearOrganizationID()
  23561. return nil
  23562. }
  23563. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  23564. }
  23565. // ResetField resets all changes in the mutation for the field with the given name.
  23566. // It returns an error if the field is not defined in the schema.
  23567. func (m *UsageDetailMutation) ResetField(name string) error {
  23568. switch name {
  23569. case usagedetail.FieldCreatedAt:
  23570. m.ResetCreatedAt()
  23571. return nil
  23572. case usagedetail.FieldUpdatedAt:
  23573. m.ResetUpdatedAt()
  23574. return nil
  23575. case usagedetail.FieldStatus:
  23576. m.ResetStatus()
  23577. return nil
  23578. case usagedetail.FieldType:
  23579. m.ResetType()
  23580. return nil
  23581. case usagedetail.FieldBotID:
  23582. m.ResetBotID()
  23583. return nil
  23584. case usagedetail.FieldReceiverID:
  23585. m.ResetReceiverID()
  23586. return nil
  23587. case usagedetail.FieldApp:
  23588. m.ResetApp()
  23589. return nil
  23590. case usagedetail.FieldSessionID:
  23591. m.ResetSessionID()
  23592. return nil
  23593. case usagedetail.FieldRequest:
  23594. m.ResetRequest()
  23595. return nil
  23596. case usagedetail.FieldResponse:
  23597. m.ResetResponse()
  23598. return nil
  23599. case usagedetail.FieldTotalTokens:
  23600. m.ResetTotalTokens()
  23601. return nil
  23602. case usagedetail.FieldPromptTokens:
  23603. m.ResetPromptTokens()
  23604. return nil
  23605. case usagedetail.FieldCompletionTokens:
  23606. m.ResetCompletionTokens()
  23607. return nil
  23608. case usagedetail.FieldOrganizationID:
  23609. m.ResetOrganizationID()
  23610. return nil
  23611. }
  23612. return fmt.Errorf("unknown UsageDetail field %s", name)
  23613. }
  23614. // AddedEdges returns all edge names that were set/added in this mutation.
  23615. func (m *UsageDetailMutation) AddedEdges() []string {
  23616. edges := make([]string, 0, 0)
  23617. return edges
  23618. }
  23619. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23620. // name in this mutation.
  23621. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  23622. return nil
  23623. }
  23624. // RemovedEdges returns all edge names that were removed in this mutation.
  23625. func (m *UsageDetailMutation) RemovedEdges() []string {
  23626. edges := make([]string, 0, 0)
  23627. return edges
  23628. }
  23629. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23630. // the given name in this mutation.
  23631. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  23632. return nil
  23633. }
  23634. // ClearedEdges returns all edge names that were cleared in this mutation.
  23635. func (m *UsageDetailMutation) ClearedEdges() []string {
  23636. edges := make([]string, 0, 0)
  23637. return edges
  23638. }
  23639. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23640. // was cleared in this mutation.
  23641. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  23642. return false
  23643. }
  23644. // ClearEdge clears the value of the edge with the given name. It returns an error
  23645. // if that edge is not defined in the schema.
  23646. func (m *UsageDetailMutation) ClearEdge(name string) error {
  23647. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  23648. }
  23649. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23650. // It returns an error if the edge is not defined in the schema.
  23651. func (m *UsageDetailMutation) ResetEdge(name string) error {
  23652. return fmt.Errorf("unknown UsageDetail edge %s", name)
  23653. }
  23654. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  23655. type UsageStatisticDayMutation struct {
  23656. config
  23657. op Op
  23658. typ string
  23659. id *uint64
  23660. created_at *time.Time
  23661. updated_at *time.Time
  23662. status *uint8
  23663. addstatus *int8
  23664. deleted_at *time.Time
  23665. addtime *uint64
  23666. addaddtime *int64
  23667. _type *int
  23668. add_type *int
  23669. bot_id *string
  23670. organization_id *uint64
  23671. addorganization_id *int64
  23672. ai_response *uint64
  23673. addai_response *int64
  23674. sop_run *uint64
  23675. addsop_run *int64
  23676. total_friend *uint64
  23677. addtotal_friend *int64
  23678. total_group *uint64
  23679. addtotal_group *int64
  23680. account_balance *uint64
  23681. addaccount_balance *int64
  23682. consume_token *uint64
  23683. addconsume_token *int64
  23684. active_user *uint64
  23685. addactive_user *int64
  23686. new_user *int64
  23687. addnew_user *int64
  23688. label_dist *[]custom_types.LabelDist
  23689. appendlabel_dist []custom_types.LabelDist
  23690. clearedFields map[string]struct{}
  23691. done bool
  23692. oldValue func(context.Context) (*UsageStatisticDay, error)
  23693. predicates []predicate.UsageStatisticDay
  23694. }
  23695. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  23696. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  23697. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  23698. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  23699. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  23700. m := &UsageStatisticDayMutation{
  23701. config: c,
  23702. op: op,
  23703. typ: TypeUsageStatisticDay,
  23704. clearedFields: make(map[string]struct{}),
  23705. }
  23706. for _, opt := range opts {
  23707. opt(m)
  23708. }
  23709. return m
  23710. }
  23711. // withUsageStatisticDayID sets the ID field of the mutation.
  23712. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  23713. return func(m *UsageStatisticDayMutation) {
  23714. var (
  23715. err error
  23716. once sync.Once
  23717. value *UsageStatisticDay
  23718. )
  23719. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  23720. once.Do(func() {
  23721. if m.done {
  23722. err = errors.New("querying old values post mutation is not allowed")
  23723. } else {
  23724. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  23725. }
  23726. })
  23727. return value, err
  23728. }
  23729. m.id = &id
  23730. }
  23731. }
  23732. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  23733. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  23734. return func(m *UsageStatisticDayMutation) {
  23735. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  23736. return node, nil
  23737. }
  23738. m.id = &node.ID
  23739. }
  23740. }
  23741. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23742. // executed in a transaction (ent.Tx), a transactional client is returned.
  23743. func (m UsageStatisticDayMutation) Client() *Client {
  23744. client := &Client{config: m.config}
  23745. client.init()
  23746. return client
  23747. }
  23748. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23749. // it returns an error otherwise.
  23750. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  23751. if _, ok := m.driver.(*txDriver); !ok {
  23752. return nil, errors.New("ent: mutation is not running in a transaction")
  23753. }
  23754. tx := &Tx{config: m.config}
  23755. tx.init()
  23756. return tx, nil
  23757. }
  23758. // SetID sets the value of the id field. Note that this
  23759. // operation is only accepted on creation of UsageStatisticDay entities.
  23760. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  23761. m.id = &id
  23762. }
  23763. // ID returns the ID value in the mutation. Note that the ID is only available
  23764. // if it was provided to the builder or after it was returned from the database.
  23765. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  23766. if m.id == nil {
  23767. return
  23768. }
  23769. return *m.id, true
  23770. }
  23771. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23772. // That means, if the mutation is applied within a transaction with an isolation level such
  23773. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23774. // or updated by the mutation.
  23775. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  23776. switch {
  23777. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23778. id, exists := m.ID()
  23779. if exists {
  23780. return []uint64{id}, nil
  23781. }
  23782. fallthrough
  23783. case m.op.Is(OpUpdate | OpDelete):
  23784. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  23785. default:
  23786. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23787. }
  23788. }
  23789. // SetCreatedAt sets the "created_at" field.
  23790. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  23791. m.created_at = &t
  23792. }
  23793. // CreatedAt returns the value of the "created_at" field in the mutation.
  23794. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  23795. v := m.created_at
  23796. if v == nil {
  23797. return
  23798. }
  23799. return *v, true
  23800. }
  23801. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  23802. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  23803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23804. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23805. if !m.op.Is(OpUpdateOne) {
  23806. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23807. }
  23808. if m.id == nil || m.oldValue == nil {
  23809. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23810. }
  23811. oldValue, err := m.oldValue(ctx)
  23812. if err != nil {
  23813. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23814. }
  23815. return oldValue.CreatedAt, nil
  23816. }
  23817. // ResetCreatedAt resets all changes to the "created_at" field.
  23818. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  23819. m.created_at = nil
  23820. }
  23821. // SetUpdatedAt sets the "updated_at" field.
  23822. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  23823. m.updated_at = &t
  23824. }
  23825. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23826. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  23827. v := m.updated_at
  23828. if v == nil {
  23829. return
  23830. }
  23831. return *v, true
  23832. }
  23833. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  23834. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  23835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23836. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23837. if !m.op.Is(OpUpdateOne) {
  23838. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23839. }
  23840. if m.id == nil || m.oldValue == nil {
  23841. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23842. }
  23843. oldValue, err := m.oldValue(ctx)
  23844. if err != nil {
  23845. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23846. }
  23847. return oldValue.UpdatedAt, nil
  23848. }
  23849. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23850. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  23851. m.updated_at = nil
  23852. }
  23853. // SetStatus sets the "status" field.
  23854. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  23855. m.status = &u
  23856. m.addstatus = nil
  23857. }
  23858. // Status returns the value of the "status" field in the mutation.
  23859. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  23860. v := m.status
  23861. if v == nil {
  23862. return
  23863. }
  23864. return *v, true
  23865. }
  23866. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  23867. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  23868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23869. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23870. if !m.op.Is(OpUpdateOne) {
  23871. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23872. }
  23873. if m.id == nil || m.oldValue == nil {
  23874. return v, errors.New("OldStatus requires an ID field in the mutation")
  23875. }
  23876. oldValue, err := m.oldValue(ctx)
  23877. if err != nil {
  23878. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23879. }
  23880. return oldValue.Status, nil
  23881. }
  23882. // AddStatus adds u to the "status" field.
  23883. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  23884. if m.addstatus != nil {
  23885. *m.addstatus += u
  23886. } else {
  23887. m.addstatus = &u
  23888. }
  23889. }
  23890. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23891. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  23892. v := m.addstatus
  23893. if v == nil {
  23894. return
  23895. }
  23896. return *v, true
  23897. }
  23898. // ClearStatus clears the value of the "status" field.
  23899. func (m *UsageStatisticDayMutation) ClearStatus() {
  23900. m.status = nil
  23901. m.addstatus = nil
  23902. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  23903. }
  23904. // StatusCleared returns if the "status" field was cleared in this mutation.
  23905. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  23906. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  23907. return ok
  23908. }
  23909. // ResetStatus resets all changes to the "status" field.
  23910. func (m *UsageStatisticDayMutation) ResetStatus() {
  23911. m.status = nil
  23912. m.addstatus = nil
  23913. delete(m.clearedFields, usagestatisticday.FieldStatus)
  23914. }
  23915. // SetDeletedAt sets the "deleted_at" field.
  23916. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  23917. m.deleted_at = &t
  23918. }
  23919. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23920. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  23921. v := m.deleted_at
  23922. if v == nil {
  23923. return
  23924. }
  23925. return *v, true
  23926. }
  23927. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  23928. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  23929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23930. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23931. if !m.op.Is(OpUpdateOne) {
  23932. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23933. }
  23934. if m.id == nil || m.oldValue == nil {
  23935. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23936. }
  23937. oldValue, err := m.oldValue(ctx)
  23938. if err != nil {
  23939. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23940. }
  23941. return oldValue.DeletedAt, nil
  23942. }
  23943. // ClearDeletedAt clears the value of the "deleted_at" field.
  23944. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  23945. m.deleted_at = nil
  23946. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  23947. }
  23948. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23949. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  23950. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  23951. return ok
  23952. }
  23953. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23954. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  23955. m.deleted_at = nil
  23956. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  23957. }
  23958. // SetAddtime sets the "addtime" field.
  23959. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  23960. m.addtime = &u
  23961. m.addaddtime = nil
  23962. }
  23963. // Addtime returns the value of the "addtime" field in the mutation.
  23964. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  23965. v := m.addtime
  23966. if v == nil {
  23967. return
  23968. }
  23969. return *v, true
  23970. }
  23971. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  23972. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  23973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23974. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  23975. if !m.op.Is(OpUpdateOne) {
  23976. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  23977. }
  23978. if m.id == nil || m.oldValue == nil {
  23979. return v, errors.New("OldAddtime requires an ID field in the mutation")
  23980. }
  23981. oldValue, err := m.oldValue(ctx)
  23982. if err != nil {
  23983. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  23984. }
  23985. return oldValue.Addtime, nil
  23986. }
  23987. // AddAddtime adds u to the "addtime" field.
  23988. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  23989. if m.addaddtime != nil {
  23990. *m.addaddtime += u
  23991. } else {
  23992. m.addaddtime = &u
  23993. }
  23994. }
  23995. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  23996. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  23997. v := m.addaddtime
  23998. if v == nil {
  23999. return
  24000. }
  24001. return *v, true
  24002. }
  24003. // ResetAddtime resets all changes to the "addtime" field.
  24004. func (m *UsageStatisticDayMutation) ResetAddtime() {
  24005. m.addtime = nil
  24006. m.addaddtime = nil
  24007. }
  24008. // SetType sets the "type" field.
  24009. func (m *UsageStatisticDayMutation) SetType(i int) {
  24010. m._type = &i
  24011. m.add_type = nil
  24012. }
  24013. // GetType returns the value of the "type" field in the mutation.
  24014. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  24015. v := m._type
  24016. if v == nil {
  24017. return
  24018. }
  24019. return *v, true
  24020. }
  24021. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  24022. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24024. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  24025. if !m.op.Is(OpUpdateOne) {
  24026. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24027. }
  24028. if m.id == nil || m.oldValue == nil {
  24029. return v, errors.New("OldType requires an ID field in the mutation")
  24030. }
  24031. oldValue, err := m.oldValue(ctx)
  24032. if err != nil {
  24033. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24034. }
  24035. return oldValue.Type, nil
  24036. }
  24037. // AddType adds i to the "type" field.
  24038. func (m *UsageStatisticDayMutation) AddType(i int) {
  24039. if m.add_type != nil {
  24040. *m.add_type += i
  24041. } else {
  24042. m.add_type = &i
  24043. }
  24044. }
  24045. // AddedType returns the value that was added to the "type" field in this mutation.
  24046. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  24047. v := m.add_type
  24048. if v == nil {
  24049. return
  24050. }
  24051. return *v, true
  24052. }
  24053. // ResetType resets all changes to the "type" field.
  24054. func (m *UsageStatisticDayMutation) ResetType() {
  24055. m._type = nil
  24056. m.add_type = nil
  24057. }
  24058. // SetBotID sets the "bot_id" field.
  24059. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  24060. m.bot_id = &s
  24061. }
  24062. // BotID returns the value of the "bot_id" field in the mutation.
  24063. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  24064. v := m.bot_id
  24065. if v == nil {
  24066. return
  24067. }
  24068. return *v, true
  24069. }
  24070. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  24071. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24073. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  24074. if !m.op.Is(OpUpdateOne) {
  24075. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  24076. }
  24077. if m.id == nil || m.oldValue == nil {
  24078. return v, errors.New("OldBotID requires an ID field in the mutation")
  24079. }
  24080. oldValue, err := m.oldValue(ctx)
  24081. if err != nil {
  24082. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  24083. }
  24084. return oldValue.BotID, nil
  24085. }
  24086. // ClearBotID clears the value of the "bot_id" field.
  24087. func (m *UsageStatisticDayMutation) ClearBotID() {
  24088. m.bot_id = nil
  24089. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  24090. }
  24091. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  24092. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  24093. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  24094. return ok
  24095. }
  24096. // ResetBotID resets all changes to the "bot_id" field.
  24097. func (m *UsageStatisticDayMutation) ResetBotID() {
  24098. m.bot_id = nil
  24099. delete(m.clearedFields, usagestatisticday.FieldBotID)
  24100. }
  24101. // SetOrganizationID sets the "organization_id" field.
  24102. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  24103. m.organization_id = &u
  24104. m.addorganization_id = nil
  24105. }
  24106. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24107. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  24108. v := m.organization_id
  24109. if v == nil {
  24110. return
  24111. }
  24112. return *v, true
  24113. }
  24114. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  24115. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24117. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24118. if !m.op.Is(OpUpdateOne) {
  24119. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24120. }
  24121. if m.id == nil || m.oldValue == nil {
  24122. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24123. }
  24124. oldValue, err := m.oldValue(ctx)
  24125. if err != nil {
  24126. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24127. }
  24128. return oldValue.OrganizationID, nil
  24129. }
  24130. // AddOrganizationID adds u to the "organization_id" field.
  24131. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  24132. if m.addorganization_id != nil {
  24133. *m.addorganization_id += u
  24134. } else {
  24135. m.addorganization_id = &u
  24136. }
  24137. }
  24138. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24139. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  24140. v := m.addorganization_id
  24141. if v == nil {
  24142. return
  24143. }
  24144. return *v, true
  24145. }
  24146. // ClearOrganizationID clears the value of the "organization_id" field.
  24147. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  24148. m.organization_id = nil
  24149. m.addorganization_id = nil
  24150. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  24151. }
  24152. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24153. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  24154. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  24155. return ok
  24156. }
  24157. // ResetOrganizationID resets all changes to the "organization_id" field.
  24158. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  24159. m.organization_id = nil
  24160. m.addorganization_id = nil
  24161. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  24162. }
  24163. // SetAiResponse sets the "ai_response" field.
  24164. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  24165. m.ai_response = &u
  24166. m.addai_response = nil
  24167. }
  24168. // AiResponse returns the value of the "ai_response" field in the mutation.
  24169. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  24170. v := m.ai_response
  24171. if v == nil {
  24172. return
  24173. }
  24174. return *v, true
  24175. }
  24176. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  24177. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24179. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  24180. if !m.op.Is(OpUpdateOne) {
  24181. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  24182. }
  24183. if m.id == nil || m.oldValue == nil {
  24184. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  24185. }
  24186. oldValue, err := m.oldValue(ctx)
  24187. if err != nil {
  24188. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  24189. }
  24190. return oldValue.AiResponse, nil
  24191. }
  24192. // AddAiResponse adds u to the "ai_response" field.
  24193. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  24194. if m.addai_response != nil {
  24195. *m.addai_response += u
  24196. } else {
  24197. m.addai_response = &u
  24198. }
  24199. }
  24200. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  24201. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  24202. v := m.addai_response
  24203. if v == nil {
  24204. return
  24205. }
  24206. return *v, true
  24207. }
  24208. // ResetAiResponse resets all changes to the "ai_response" field.
  24209. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  24210. m.ai_response = nil
  24211. m.addai_response = nil
  24212. }
  24213. // SetSopRun sets the "sop_run" field.
  24214. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  24215. m.sop_run = &u
  24216. m.addsop_run = nil
  24217. }
  24218. // SopRun returns the value of the "sop_run" field in the mutation.
  24219. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  24220. v := m.sop_run
  24221. if v == nil {
  24222. return
  24223. }
  24224. return *v, true
  24225. }
  24226. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  24227. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24229. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  24230. if !m.op.Is(OpUpdateOne) {
  24231. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  24232. }
  24233. if m.id == nil || m.oldValue == nil {
  24234. return v, errors.New("OldSopRun requires an ID field in the mutation")
  24235. }
  24236. oldValue, err := m.oldValue(ctx)
  24237. if err != nil {
  24238. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  24239. }
  24240. return oldValue.SopRun, nil
  24241. }
  24242. // AddSopRun adds u to the "sop_run" field.
  24243. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  24244. if m.addsop_run != nil {
  24245. *m.addsop_run += u
  24246. } else {
  24247. m.addsop_run = &u
  24248. }
  24249. }
  24250. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  24251. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  24252. v := m.addsop_run
  24253. if v == nil {
  24254. return
  24255. }
  24256. return *v, true
  24257. }
  24258. // ResetSopRun resets all changes to the "sop_run" field.
  24259. func (m *UsageStatisticDayMutation) ResetSopRun() {
  24260. m.sop_run = nil
  24261. m.addsop_run = nil
  24262. }
  24263. // SetTotalFriend sets the "total_friend" field.
  24264. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  24265. m.total_friend = &u
  24266. m.addtotal_friend = nil
  24267. }
  24268. // TotalFriend returns the value of the "total_friend" field in the mutation.
  24269. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  24270. v := m.total_friend
  24271. if v == nil {
  24272. return
  24273. }
  24274. return *v, true
  24275. }
  24276. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  24277. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24279. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  24280. if !m.op.Is(OpUpdateOne) {
  24281. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  24282. }
  24283. if m.id == nil || m.oldValue == nil {
  24284. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  24285. }
  24286. oldValue, err := m.oldValue(ctx)
  24287. if err != nil {
  24288. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  24289. }
  24290. return oldValue.TotalFriend, nil
  24291. }
  24292. // AddTotalFriend adds u to the "total_friend" field.
  24293. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  24294. if m.addtotal_friend != nil {
  24295. *m.addtotal_friend += u
  24296. } else {
  24297. m.addtotal_friend = &u
  24298. }
  24299. }
  24300. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  24301. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  24302. v := m.addtotal_friend
  24303. if v == nil {
  24304. return
  24305. }
  24306. return *v, true
  24307. }
  24308. // ResetTotalFriend resets all changes to the "total_friend" field.
  24309. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  24310. m.total_friend = nil
  24311. m.addtotal_friend = nil
  24312. }
  24313. // SetTotalGroup sets the "total_group" field.
  24314. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  24315. m.total_group = &u
  24316. m.addtotal_group = nil
  24317. }
  24318. // TotalGroup returns the value of the "total_group" field in the mutation.
  24319. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  24320. v := m.total_group
  24321. if v == nil {
  24322. return
  24323. }
  24324. return *v, true
  24325. }
  24326. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  24327. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24329. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  24330. if !m.op.Is(OpUpdateOne) {
  24331. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  24332. }
  24333. if m.id == nil || m.oldValue == nil {
  24334. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  24335. }
  24336. oldValue, err := m.oldValue(ctx)
  24337. if err != nil {
  24338. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  24339. }
  24340. return oldValue.TotalGroup, nil
  24341. }
  24342. // AddTotalGroup adds u to the "total_group" field.
  24343. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  24344. if m.addtotal_group != nil {
  24345. *m.addtotal_group += u
  24346. } else {
  24347. m.addtotal_group = &u
  24348. }
  24349. }
  24350. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  24351. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  24352. v := m.addtotal_group
  24353. if v == nil {
  24354. return
  24355. }
  24356. return *v, true
  24357. }
  24358. // ResetTotalGroup resets all changes to the "total_group" field.
  24359. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  24360. m.total_group = nil
  24361. m.addtotal_group = nil
  24362. }
  24363. // SetAccountBalance sets the "account_balance" field.
  24364. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  24365. m.account_balance = &u
  24366. m.addaccount_balance = nil
  24367. }
  24368. // AccountBalance returns the value of the "account_balance" field in the mutation.
  24369. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  24370. v := m.account_balance
  24371. if v == nil {
  24372. return
  24373. }
  24374. return *v, true
  24375. }
  24376. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  24377. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24379. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  24380. if !m.op.Is(OpUpdateOne) {
  24381. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  24382. }
  24383. if m.id == nil || m.oldValue == nil {
  24384. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  24385. }
  24386. oldValue, err := m.oldValue(ctx)
  24387. if err != nil {
  24388. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  24389. }
  24390. return oldValue.AccountBalance, nil
  24391. }
  24392. // AddAccountBalance adds u to the "account_balance" field.
  24393. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  24394. if m.addaccount_balance != nil {
  24395. *m.addaccount_balance += u
  24396. } else {
  24397. m.addaccount_balance = &u
  24398. }
  24399. }
  24400. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  24401. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  24402. v := m.addaccount_balance
  24403. if v == nil {
  24404. return
  24405. }
  24406. return *v, true
  24407. }
  24408. // ResetAccountBalance resets all changes to the "account_balance" field.
  24409. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  24410. m.account_balance = nil
  24411. m.addaccount_balance = nil
  24412. }
  24413. // SetConsumeToken sets the "consume_token" field.
  24414. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  24415. m.consume_token = &u
  24416. m.addconsume_token = nil
  24417. }
  24418. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  24419. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  24420. v := m.consume_token
  24421. if v == nil {
  24422. return
  24423. }
  24424. return *v, true
  24425. }
  24426. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  24427. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24429. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  24430. if !m.op.Is(OpUpdateOne) {
  24431. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  24432. }
  24433. if m.id == nil || m.oldValue == nil {
  24434. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  24435. }
  24436. oldValue, err := m.oldValue(ctx)
  24437. if err != nil {
  24438. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  24439. }
  24440. return oldValue.ConsumeToken, nil
  24441. }
  24442. // AddConsumeToken adds u to the "consume_token" field.
  24443. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  24444. if m.addconsume_token != nil {
  24445. *m.addconsume_token += u
  24446. } else {
  24447. m.addconsume_token = &u
  24448. }
  24449. }
  24450. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  24451. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  24452. v := m.addconsume_token
  24453. if v == nil {
  24454. return
  24455. }
  24456. return *v, true
  24457. }
  24458. // ResetConsumeToken resets all changes to the "consume_token" field.
  24459. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  24460. m.consume_token = nil
  24461. m.addconsume_token = nil
  24462. }
  24463. // SetActiveUser sets the "active_user" field.
  24464. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  24465. m.active_user = &u
  24466. m.addactive_user = nil
  24467. }
  24468. // ActiveUser returns the value of the "active_user" field in the mutation.
  24469. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  24470. v := m.active_user
  24471. if v == nil {
  24472. return
  24473. }
  24474. return *v, true
  24475. }
  24476. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  24477. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24479. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  24480. if !m.op.Is(OpUpdateOne) {
  24481. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  24482. }
  24483. if m.id == nil || m.oldValue == nil {
  24484. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  24485. }
  24486. oldValue, err := m.oldValue(ctx)
  24487. if err != nil {
  24488. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  24489. }
  24490. return oldValue.ActiveUser, nil
  24491. }
  24492. // AddActiveUser adds u to the "active_user" field.
  24493. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  24494. if m.addactive_user != nil {
  24495. *m.addactive_user += u
  24496. } else {
  24497. m.addactive_user = &u
  24498. }
  24499. }
  24500. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  24501. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  24502. v := m.addactive_user
  24503. if v == nil {
  24504. return
  24505. }
  24506. return *v, true
  24507. }
  24508. // ResetActiveUser resets all changes to the "active_user" field.
  24509. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  24510. m.active_user = nil
  24511. m.addactive_user = nil
  24512. }
  24513. // SetNewUser sets the "new_user" field.
  24514. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  24515. m.new_user = &i
  24516. m.addnew_user = nil
  24517. }
  24518. // NewUser returns the value of the "new_user" field in the mutation.
  24519. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  24520. v := m.new_user
  24521. if v == nil {
  24522. return
  24523. }
  24524. return *v, true
  24525. }
  24526. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  24527. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24529. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  24530. if !m.op.Is(OpUpdateOne) {
  24531. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  24532. }
  24533. if m.id == nil || m.oldValue == nil {
  24534. return v, errors.New("OldNewUser requires an ID field in the mutation")
  24535. }
  24536. oldValue, err := m.oldValue(ctx)
  24537. if err != nil {
  24538. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  24539. }
  24540. return oldValue.NewUser, nil
  24541. }
  24542. // AddNewUser adds i to the "new_user" field.
  24543. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  24544. if m.addnew_user != nil {
  24545. *m.addnew_user += i
  24546. } else {
  24547. m.addnew_user = &i
  24548. }
  24549. }
  24550. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  24551. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  24552. v := m.addnew_user
  24553. if v == nil {
  24554. return
  24555. }
  24556. return *v, true
  24557. }
  24558. // ResetNewUser resets all changes to the "new_user" field.
  24559. func (m *UsageStatisticDayMutation) ResetNewUser() {
  24560. m.new_user = nil
  24561. m.addnew_user = nil
  24562. }
  24563. // SetLabelDist sets the "label_dist" field.
  24564. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  24565. m.label_dist = &ctd
  24566. m.appendlabel_dist = nil
  24567. }
  24568. // LabelDist returns the value of the "label_dist" field in the mutation.
  24569. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  24570. v := m.label_dist
  24571. if v == nil {
  24572. return
  24573. }
  24574. return *v, true
  24575. }
  24576. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  24577. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24579. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  24580. if !m.op.Is(OpUpdateOne) {
  24581. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  24582. }
  24583. if m.id == nil || m.oldValue == nil {
  24584. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  24585. }
  24586. oldValue, err := m.oldValue(ctx)
  24587. if err != nil {
  24588. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  24589. }
  24590. return oldValue.LabelDist, nil
  24591. }
  24592. // AppendLabelDist adds ctd to the "label_dist" field.
  24593. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  24594. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  24595. }
  24596. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  24597. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  24598. if len(m.appendlabel_dist) == 0 {
  24599. return nil, false
  24600. }
  24601. return m.appendlabel_dist, true
  24602. }
  24603. // ResetLabelDist resets all changes to the "label_dist" field.
  24604. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  24605. m.label_dist = nil
  24606. m.appendlabel_dist = nil
  24607. }
  24608. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  24609. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  24610. m.predicates = append(m.predicates, ps...)
  24611. }
  24612. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  24613. // users can use type-assertion to append predicates that do not depend on any generated package.
  24614. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  24615. p := make([]predicate.UsageStatisticDay, len(ps))
  24616. for i := range ps {
  24617. p[i] = ps[i]
  24618. }
  24619. m.Where(p...)
  24620. }
  24621. // Op returns the operation name.
  24622. func (m *UsageStatisticDayMutation) Op() Op {
  24623. return m.op
  24624. }
  24625. // SetOp allows setting the mutation operation.
  24626. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  24627. m.op = op
  24628. }
  24629. // Type returns the node type of this mutation (UsageStatisticDay).
  24630. func (m *UsageStatisticDayMutation) Type() string {
  24631. return m.typ
  24632. }
  24633. // Fields returns all fields that were changed during this mutation. Note that in
  24634. // order to get all numeric fields that were incremented/decremented, call
  24635. // AddedFields().
  24636. func (m *UsageStatisticDayMutation) Fields() []string {
  24637. fields := make([]string, 0, 17)
  24638. if m.created_at != nil {
  24639. fields = append(fields, usagestatisticday.FieldCreatedAt)
  24640. }
  24641. if m.updated_at != nil {
  24642. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  24643. }
  24644. if m.status != nil {
  24645. fields = append(fields, usagestatisticday.FieldStatus)
  24646. }
  24647. if m.deleted_at != nil {
  24648. fields = append(fields, usagestatisticday.FieldDeletedAt)
  24649. }
  24650. if m.addtime != nil {
  24651. fields = append(fields, usagestatisticday.FieldAddtime)
  24652. }
  24653. if m._type != nil {
  24654. fields = append(fields, usagestatisticday.FieldType)
  24655. }
  24656. if m.bot_id != nil {
  24657. fields = append(fields, usagestatisticday.FieldBotID)
  24658. }
  24659. if m.organization_id != nil {
  24660. fields = append(fields, usagestatisticday.FieldOrganizationID)
  24661. }
  24662. if m.ai_response != nil {
  24663. fields = append(fields, usagestatisticday.FieldAiResponse)
  24664. }
  24665. if m.sop_run != nil {
  24666. fields = append(fields, usagestatisticday.FieldSopRun)
  24667. }
  24668. if m.total_friend != nil {
  24669. fields = append(fields, usagestatisticday.FieldTotalFriend)
  24670. }
  24671. if m.total_group != nil {
  24672. fields = append(fields, usagestatisticday.FieldTotalGroup)
  24673. }
  24674. if m.account_balance != nil {
  24675. fields = append(fields, usagestatisticday.FieldAccountBalance)
  24676. }
  24677. if m.consume_token != nil {
  24678. fields = append(fields, usagestatisticday.FieldConsumeToken)
  24679. }
  24680. if m.active_user != nil {
  24681. fields = append(fields, usagestatisticday.FieldActiveUser)
  24682. }
  24683. if m.new_user != nil {
  24684. fields = append(fields, usagestatisticday.FieldNewUser)
  24685. }
  24686. if m.label_dist != nil {
  24687. fields = append(fields, usagestatisticday.FieldLabelDist)
  24688. }
  24689. return fields
  24690. }
  24691. // Field returns the value of a field with the given name. The second boolean
  24692. // return value indicates that this field was not set, or was not defined in the
  24693. // schema.
  24694. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  24695. switch name {
  24696. case usagestatisticday.FieldCreatedAt:
  24697. return m.CreatedAt()
  24698. case usagestatisticday.FieldUpdatedAt:
  24699. return m.UpdatedAt()
  24700. case usagestatisticday.FieldStatus:
  24701. return m.Status()
  24702. case usagestatisticday.FieldDeletedAt:
  24703. return m.DeletedAt()
  24704. case usagestatisticday.FieldAddtime:
  24705. return m.Addtime()
  24706. case usagestatisticday.FieldType:
  24707. return m.GetType()
  24708. case usagestatisticday.FieldBotID:
  24709. return m.BotID()
  24710. case usagestatisticday.FieldOrganizationID:
  24711. return m.OrganizationID()
  24712. case usagestatisticday.FieldAiResponse:
  24713. return m.AiResponse()
  24714. case usagestatisticday.FieldSopRun:
  24715. return m.SopRun()
  24716. case usagestatisticday.FieldTotalFriend:
  24717. return m.TotalFriend()
  24718. case usagestatisticday.FieldTotalGroup:
  24719. return m.TotalGroup()
  24720. case usagestatisticday.FieldAccountBalance:
  24721. return m.AccountBalance()
  24722. case usagestatisticday.FieldConsumeToken:
  24723. return m.ConsumeToken()
  24724. case usagestatisticday.FieldActiveUser:
  24725. return m.ActiveUser()
  24726. case usagestatisticday.FieldNewUser:
  24727. return m.NewUser()
  24728. case usagestatisticday.FieldLabelDist:
  24729. return m.LabelDist()
  24730. }
  24731. return nil, false
  24732. }
  24733. // OldField returns the old value of the field from the database. An error is
  24734. // returned if the mutation operation is not UpdateOne, or the query to the
  24735. // database failed.
  24736. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24737. switch name {
  24738. case usagestatisticday.FieldCreatedAt:
  24739. return m.OldCreatedAt(ctx)
  24740. case usagestatisticday.FieldUpdatedAt:
  24741. return m.OldUpdatedAt(ctx)
  24742. case usagestatisticday.FieldStatus:
  24743. return m.OldStatus(ctx)
  24744. case usagestatisticday.FieldDeletedAt:
  24745. return m.OldDeletedAt(ctx)
  24746. case usagestatisticday.FieldAddtime:
  24747. return m.OldAddtime(ctx)
  24748. case usagestatisticday.FieldType:
  24749. return m.OldType(ctx)
  24750. case usagestatisticday.FieldBotID:
  24751. return m.OldBotID(ctx)
  24752. case usagestatisticday.FieldOrganizationID:
  24753. return m.OldOrganizationID(ctx)
  24754. case usagestatisticday.FieldAiResponse:
  24755. return m.OldAiResponse(ctx)
  24756. case usagestatisticday.FieldSopRun:
  24757. return m.OldSopRun(ctx)
  24758. case usagestatisticday.FieldTotalFriend:
  24759. return m.OldTotalFriend(ctx)
  24760. case usagestatisticday.FieldTotalGroup:
  24761. return m.OldTotalGroup(ctx)
  24762. case usagestatisticday.FieldAccountBalance:
  24763. return m.OldAccountBalance(ctx)
  24764. case usagestatisticday.FieldConsumeToken:
  24765. return m.OldConsumeToken(ctx)
  24766. case usagestatisticday.FieldActiveUser:
  24767. return m.OldActiveUser(ctx)
  24768. case usagestatisticday.FieldNewUser:
  24769. return m.OldNewUser(ctx)
  24770. case usagestatisticday.FieldLabelDist:
  24771. return m.OldLabelDist(ctx)
  24772. }
  24773. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  24774. }
  24775. // SetField sets the value of a field with the given name. It returns an error if
  24776. // the field is not defined in the schema, or if the type mismatched the field
  24777. // type.
  24778. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  24779. switch name {
  24780. case usagestatisticday.FieldCreatedAt:
  24781. v, ok := value.(time.Time)
  24782. if !ok {
  24783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24784. }
  24785. m.SetCreatedAt(v)
  24786. return nil
  24787. case usagestatisticday.FieldUpdatedAt:
  24788. v, ok := value.(time.Time)
  24789. if !ok {
  24790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24791. }
  24792. m.SetUpdatedAt(v)
  24793. return nil
  24794. case usagestatisticday.FieldStatus:
  24795. v, ok := value.(uint8)
  24796. if !ok {
  24797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24798. }
  24799. m.SetStatus(v)
  24800. return nil
  24801. case usagestatisticday.FieldDeletedAt:
  24802. v, ok := value.(time.Time)
  24803. if !ok {
  24804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24805. }
  24806. m.SetDeletedAt(v)
  24807. return nil
  24808. case usagestatisticday.FieldAddtime:
  24809. v, ok := value.(uint64)
  24810. if !ok {
  24811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24812. }
  24813. m.SetAddtime(v)
  24814. return nil
  24815. case usagestatisticday.FieldType:
  24816. v, ok := value.(int)
  24817. if !ok {
  24818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24819. }
  24820. m.SetType(v)
  24821. return nil
  24822. case usagestatisticday.FieldBotID:
  24823. v, ok := value.(string)
  24824. if !ok {
  24825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24826. }
  24827. m.SetBotID(v)
  24828. return nil
  24829. case usagestatisticday.FieldOrganizationID:
  24830. v, ok := value.(uint64)
  24831. if !ok {
  24832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24833. }
  24834. m.SetOrganizationID(v)
  24835. return nil
  24836. case usagestatisticday.FieldAiResponse:
  24837. v, ok := value.(uint64)
  24838. if !ok {
  24839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24840. }
  24841. m.SetAiResponse(v)
  24842. return nil
  24843. case usagestatisticday.FieldSopRun:
  24844. v, ok := value.(uint64)
  24845. if !ok {
  24846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24847. }
  24848. m.SetSopRun(v)
  24849. return nil
  24850. case usagestatisticday.FieldTotalFriend:
  24851. v, ok := value.(uint64)
  24852. if !ok {
  24853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24854. }
  24855. m.SetTotalFriend(v)
  24856. return nil
  24857. case usagestatisticday.FieldTotalGroup:
  24858. v, ok := value.(uint64)
  24859. if !ok {
  24860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24861. }
  24862. m.SetTotalGroup(v)
  24863. return nil
  24864. case usagestatisticday.FieldAccountBalance:
  24865. v, ok := value.(uint64)
  24866. if !ok {
  24867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24868. }
  24869. m.SetAccountBalance(v)
  24870. return nil
  24871. case usagestatisticday.FieldConsumeToken:
  24872. v, ok := value.(uint64)
  24873. if !ok {
  24874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24875. }
  24876. m.SetConsumeToken(v)
  24877. return nil
  24878. case usagestatisticday.FieldActiveUser:
  24879. v, ok := value.(uint64)
  24880. if !ok {
  24881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24882. }
  24883. m.SetActiveUser(v)
  24884. return nil
  24885. case usagestatisticday.FieldNewUser:
  24886. v, ok := value.(int64)
  24887. if !ok {
  24888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24889. }
  24890. m.SetNewUser(v)
  24891. return nil
  24892. case usagestatisticday.FieldLabelDist:
  24893. v, ok := value.([]custom_types.LabelDist)
  24894. if !ok {
  24895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24896. }
  24897. m.SetLabelDist(v)
  24898. return nil
  24899. }
  24900. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  24901. }
  24902. // AddedFields returns all numeric fields that were incremented/decremented during
  24903. // this mutation.
  24904. func (m *UsageStatisticDayMutation) AddedFields() []string {
  24905. var fields []string
  24906. if m.addstatus != nil {
  24907. fields = append(fields, usagestatisticday.FieldStatus)
  24908. }
  24909. if m.addaddtime != nil {
  24910. fields = append(fields, usagestatisticday.FieldAddtime)
  24911. }
  24912. if m.add_type != nil {
  24913. fields = append(fields, usagestatisticday.FieldType)
  24914. }
  24915. if m.addorganization_id != nil {
  24916. fields = append(fields, usagestatisticday.FieldOrganizationID)
  24917. }
  24918. if m.addai_response != nil {
  24919. fields = append(fields, usagestatisticday.FieldAiResponse)
  24920. }
  24921. if m.addsop_run != nil {
  24922. fields = append(fields, usagestatisticday.FieldSopRun)
  24923. }
  24924. if m.addtotal_friend != nil {
  24925. fields = append(fields, usagestatisticday.FieldTotalFriend)
  24926. }
  24927. if m.addtotal_group != nil {
  24928. fields = append(fields, usagestatisticday.FieldTotalGroup)
  24929. }
  24930. if m.addaccount_balance != nil {
  24931. fields = append(fields, usagestatisticday.FieldAccountBalance)
  24932. }
  24933. if m.addconsume_token != nil {
  24934. fields = append(fields, usagestatisticday.FieldConsumeToken)
  24935. }
  24936. if m.addactive_user != nil {
  24937. fields = append(fields, usagestatisticday.FieldActiveUser)
  24938. }
  24939. if m.addnew_user != nil {
  24940. fields = append(fields, usagestatisticday.FieldNewUser)
  24941. }
  24942. return fields
  24943. }
  24944. // AddedField returns the numeric value that was incremented/decremented on a field
  24945. // with the given name. The second boolean return value indicates that this field
  24946. // was not set, or was not defined in the schema.
  24947. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  24948. switch name {
  24949. case usagestatisticday.FieldStatus:
  24950. return m.AddedStatus()
  24951. case usagestatisticday.FieldAddtime:
  24952. return m.AddedAddtime()
  24953. case usagestatisticday.FieldType:
  24954. return m.AddedType()
  24955. case usagestatisticday.FieldOrganizationID:
  24956. return m.AddedOrganizationID()
  24957. case usagestatisticday.FieldAiResponse:
  24958. return m.AddedAiResponse()
  24959. case usagestatisticday.FieldSopRun:
  24960. return m.AddedSopRun()
  24961. case usagestatisticday.FieldTotalFriend:
  24962. return m.AddedTotalFriend()
  24963. case usagestatisticday.FieldTotalGroup:
  24964. return m.AddedTotalGroup()
  24965. case usagestatisticday.FieldAccountBalance:
  24966. return m.AddedAccountBalance()
  24967. case usagestatisticday.FieldConsumeToken:
  24968. return m.AddedConsumeToken()
  24969. case usagestatisticday.FieldActiveUser:
  24970. return m.AddedActiveUser()
  24971. case usagestatisticday.FieldNewUser:
  24972. return m.AddedNewUser()
  24973. }
  24974. return nil, false
  24975. }
  24976. // AddField adds the value to the field with the given name. It returns an error if
  24977. // the field is not defined in the schema, or if the type mismatched the field
  24978. // type.
  24979. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  24980. switch name {
  24981. case usagestatisticday.FieldStatus:
  24982. v, ok := value.(int8)
  24983. if !ok {
  24984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24985. }
  24986. m.AddStatus(v)
  24987. return nil
  24988. case usagestatisticday.FieldAddtime:
  24989. v, ok := value.(int64)
  24990. if !ok {
  24991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24992. }
  24993. m.AddAddtime(v)
  24994. return nil
  24995. case usagestatisticday.FieldType:
  24996. v, ok := value.(int)
  24997. if !ok {
  24998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24999. }
  25000. m.AddType(v)
  25001. return nil
  25002. case usagestatisticday.FieldOrganizationID:
  25003. v, ok := value.(int64)
  25004. if !ok {
  25005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25006. }
  25007. m.AddOrganizationID(v)
  25008. return nil
  25009. case usagestatisticday.FieldAiResponse:
  25010. v, ok := value.(int64)
  25011. if !ok {
  25012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25013. }
  25014. m.AddAiResponse(v)
  25015. return nil
  25016. case usagestatisticday.FieldSopRun:
  25017. v, ok := value.(int64)
  25018. if !ok {
  25019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25020. }
  25021. m.AddSopRun(v)
  25022. return nil
  25023. case usagestatisticday.FieldTotalFriend:
  25024. v, ok := value.(int64)
  25025. if !ok {
  25026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25027. }
  25028. m.AddTotalFriend(v)
  25029. return nil
  25030. case usagestatisticday.FieldTotalGroup:
  25031. v, ok := value.(int64)
  25032. if !ok {
  25033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25034. }
  25035. m.AddTotalGroup(v)
  25036. return nil
  25037. case usagestatisticday.FieldAccountBalance:
  25038. v, ok := value.(int64)
  25039. if !ok {
  25040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25041. }
  25042. m.AddAccountBalance(v)
  25043. return nil
  25044. case usagestatisticday.FieldConsumeToken:
  25045. v, ok := value.(int64)
  25046. if !ok {
  25047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25048. }
  25049. m.AddConsumeToken(v)
  25050. return nil
  25051. case usagestatisticday.FieldActiveUser:
  25052. v, ok := value.(int64)
  25053. if !ok {
  25054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25055. }
  25056. m.AddActiveUser(v)
  25057. return nil
  25058. case usagestatisticday.FieldNewUser:
  25059. v, ok := value.(int64)
  25060. if !ok {
  25061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25062. }
  25063. m.AddNewUser(v)
  25064. return nil
  25065. }
  25066. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  25067. }
  25068. // ClearedFields returns all nullable fields that were cleared during this
  25069. // mutation.
  25070. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  25071. var fields []string
  25072. if m.FieldCleared(usagestatisticday.FieldStatus) {
  25073. fields = append(fields, usagestatisticday.FieldStatus)
  25074. }
  25075. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  25076. fields = append(fields, usagestatisticday.FieldDeletedAt)
  25077. }
  25078. if m.FieldCleared(usagestatisticday.FieldBotID) {
  25079. fields = append(fields, usagestatisticday.FieldBotID)
  25080. }
  25081. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  25082. fields = append(fields, usagestatisticday.FieldOrganizationID)
  25083. }
  25084. return fields
  25085. }
  25086. // FieldCleared returns a boolean indicating if a field with the given name was
  25087. // cleared in this mutation.
  25088. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  25089. _, ok := m.clearedFields[name]
  25090. return ok
  25091. }
  25092. // ClearField clears the value of the field with the given name. It returns an
  25093. // error if the field is not defined in the schema.
  25094. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  25095. switch name {
  25096. case usagestatisticday.FieldStatus:
  25097. m.ClearStatus()
  25098. return nil
  25099. case usagestatisticday.FieldDeletedAt:
  25100. m.ClearDeletedAt()
  25101. return nil
  25102. case usagestatisticday.FieldBotID:
  25103. m.ClearBotID()
  25104. return nil
  25105. case usagestatisticday.FieldOrganizationID:
  25106. m.ClearOrganizationID()
  25107. return nil
  25108. }
  25109. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  25110. }
  25111. // ResetField resets all changes in the mutation for the field with the given name.
  25112. // It returns an error if the field is not defined in the schema.
  25113. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  25114. switch name {
  25115. case usagestatisticday.FieldCreatedAt:
  25116. m.ResetCreatedAt()
  25117. return nil
  25118. case usagestatisticday.FieldUpdatedAt:
  25119. m.ResetUpdatedAt()
  25120. return nil
  25121. case usagestatisticday.FieldStatus:
  25122. m.ResetStatus()
  25123. return nil
  25124. case usagestatisticday.FieldDeletedAt:
  25125. m.ResetDeletedAt()
  25126. return nil
  25127. case usagestatisticday.FieldAddtime:
  25128. m.ResetAddtime()
  25129. return nil
  25130. case usagestatisticday.FieldType:
  25131. m.ResetType()
  25132. return nil
  25133. case usagestatisticday.FieldBotID:
  25134. m.ResetBotID()
  25135. return nil
  25136. case usagestatisticday.FieldOrganizationID:
  25137. m.ResetOrganizationID()
  25138. return nil
  25139. case usagestatisticday.FieldAiResponse:
  25140. m.ResetAiResponse()
  25141. return nil
  25142. case usagestatisticday.FieldSopRun:
  25143. m.ResetSopRun()
  25144. return nil
  25145. case usagestatisticday.FieldTotalFriend:
  25146. m.ResetTotalFriend()
  25147. return nil
  25148. case usagestatisticday.FieldTotalGroup:
  25149. m.ResetTotalGroup()
  25150. return nil
  25151. case usagestatisticday.FieldAccountBalance:
  25152. m.ResetAccountBalance()
  25153. return nil
  25154. case usagestatisticday.FieldConsumeToken:
  25155. m.ResetConsumeToken()
  25156. return nil
  25157. case usagestatisticday.FieldActiveUser:
  25158. m.ResetActiveUser()
  25159. return nil
  25160. case usagestatisticday.FieldNewUser:
  25161. m.ResetNewUser()
  25162. return nil
  25163. case usagestatisticday.FieldLabelDist:
  25164. m.ResetLabelDist()
  25165. return nil
  25166. }
  25167. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  25168. }
  25169. // AddedEdges returns all edge names that were set/added in this mutation.
  25170. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  25171. edges := make([]string, 0, 0)
  25172. return edges
  25173. }
  25174. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25175. // name in this mutation.
  25176. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  25177. return nil
  25178. }
  25179. // RemovedEdges returns all edge names that were removed in this mutation.
  25180. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  25181. edges := make([]string, 0, 0)
  25182. return edges
  25183. }
  25184. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25185. // the given name in this mutation.
  25186. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  25187. return nil
  25188. }
  25189. // ClearedEdges returns all edge names that were cleared in this mutation.
  25190. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  25191. edges := make([]string, 0, 0)
  25192. return edges
  25193. }
  25194. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25195. // was cleared in this mutation.
  25196. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  25197. return false
  25198. }
  25199. // ClearEdge clears the value of the edge with the given name. It returns an error
  25200. // if that edge is not defined in the schema.
  25201. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  25202. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  25203. }
  25204. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25205. // It returns an error if the edge is not defined in the schema.
  25206. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  25207. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  25208. }
  25209. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  25210. type UsageStatisticHourMutation struct {
  25211. config
  25212. op Op
  25213. typ string
  25214. id *uint64
  25215. created_at *time.Time
  25216. updated_at *time.Time
  25217. status *uint8
  25218. addstatus *int8
  25219. deleted_at *time.Time
  25220. addtime *uint64
  25221. addaddtime *int64
  25222. _type *int
  25223. add_type *int
  25224. bot_id *string
  25225. organization_id *uint64
  25226. addorganization_id *int64
  25227. ai_response *uint64
  25228. addai_response *int64
  25229. sop_run *uint64
  25230. addsop_run *int64
  25231. total_friend *uint64
  25232. addtotal_friend *int64
  25233. total_group *uint64
  25234. addtotal_group *int64
  25235. account_balance *uint64
  25236. addaccount_balance *int64
  25237. consume_token *uint64
  25238. addconsume_token *int64
  25239. active_user *uint64
  25240. addactive_user *int64
  25241. new_user *int64
  25242. addnew_user *int64
  25243. label_dist *[]custom_types.LabelDist
  25244. appendlabel_dist []custom_types.LabelDist
  25245. clearedFields map[string]struct{}
  25246. done bool
  25247. oldValue func(context.Context) (*UsageStatisticHour, error)
  25248. predicates []predicate.UsageStatisticHour
  25249. }
  25250. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  25251. // usagestatistichourOption allows management of the mutation configuration using functional options.
  25252. type usagestatistichourOption func(*UsageStatisticHourMutation)
  25253. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  25254. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  25255. m := &UsageStatisticHourMutation{
  25256. config: c,
  25257. op: op,
  25258. typ: TypeUsageStatisticHour,
  25259. clearedFields: make(map[string]struct{}),
  25260. }
  25261. for _, opt := range opts {
  25262. opt(m)
  25263. }
  25264. return m
  25265. }
  25266. // withUsageStatisticHourID sets the ID field of the mutation.
  25267. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  25268. return func(m *UsageStatisticHourMutation) {
  25269. var (
  25270. err error
  25271. once sync.Once
  25272. value *UsageStatisticHour
  25273. )
  25274. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  25275. once.Do(func() {
  25276. if m.done {
  25277. err = errors.New("querying old values post mutation is not allowed")
  25278. } else {
  25279. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  25280. }
  25281. })
  25282. return value, err
  25283. }
  25284. m.id = &id
  25285. }
  25286. }
  25287. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  25288. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  25289. return func(m *UsageStatisticHourMutation) {
  25290. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  25291. return node, nil
  25292. }
  25293. m.id = &node.ID
  25294. }
  25295. }
  25296. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25297. // executed in a transaction (ent.Tx), a transactional client is returned.
  25298. func (m UsageStatisticHourMutation) Client() *Client {
  25299. client := &Client{config: m.config}
  25300. client.init()
  25301. return client
  25302. }
  25303. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25304. // it returns an error otherwise.
  25305. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  25306. if _, ok := m.driver.(*txDriver); !ok {
  25307. return nil, errors.New("ent: mutation is not running in a transaction")
  25308. }
  25309. tx := &Tx{config: m.config}
  25310. tx.init()
  25311. return tx, nil
  25312. }
  25313. // SetID sets the value of the id field. Note that this
  25314. // operation is only accepted on creation of UsageStatisticHour entities.
  25315. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  25316. m.id = &id
  25317. }
  25318. // ID returns the ID value in the mutation. Note that the ID is only available
  25319. // if it was provided to the builder or after it was returned from the database.
  25320. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  25321. if m.id == nil {
  25322. return
  25323. }
  25324. return *m.id, true
  25325. }
  25326. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25327. // That means, if the mutation is applied within a transaction with an isolation level such
  25328. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25329. // or updated by the mutation.
  25330. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  25331. switch {
  25332. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25333. id, exists := m.ID()
  25334. if exists {
  25335. return []uint64{id}, nil
  25336. }
  25337. fallthrough
  25338. case m.op.Is(OpUpdate | OpDelete):
  25339. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  25340. default:
  25341. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25342. }
  25343. }
  25344. // SetCreatedAt sets the "created_at" field.
  25345. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  25346. m.created_at = &t
  25347. }
  25348. // CreatedAt returns the value of the "created_at" field in the mutation.
  25349. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  25350. v := m.created_at
  25351. if v == nil {
  25352. return
  25353. }
  25354. return *v, true
  25355. }
  25356. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  25357. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25359. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25360. if !m.op.Is(OpUpdateOne) {
  25361. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25362. }
  25363. if m.id == nil || m.oldValue == nil {
  25364. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25365. }
  25366. oldValue, err := m.oldValue(ctx)
  25367. if err != nil {
  25368. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25369. }
  25370. return oldValue.CreatedAt, nil
  25371. }
  25372. // ResetCreatedAt resets all changes to the "created_at" field.
  25373. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  25374. m.created_at = nil
  25375. }
  25376. // SetUpdatedAt sets the "updated_at" field.
  25377. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  25378. m.updated_at = &t
  25379. }
  25380. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25381. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  25382. v := m.updated_at
  25383. if v == nil {
  25384. return
  25385. }
  25386. return *v, true
  25387. }
  25388. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  25389. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25391. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25392. if !m.op.Is(OpUpdateOne) {
  25393. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25394. }
  25395. if m.id == nil || m.oldValue == nil {
  25396. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25397. }
  25398. oldValue, err := m.oldValue(ctx)
  25399. if err != nil {
  25400. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25401. }
  25402. return oldValue.UpdatedAt, nil
  25403. }
  25404. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25405. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  25406. m.updated_at = nil
  25407. }
  25408. // SetStatus sets the "status" field.
  25409. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  25410. m.status = &u
  25411. m.addstatus = nil
  25412. }
  25413. // Status returns the value of the "status" field in the mutation.
  25414. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  25415. v := m.status
  25416. if v == nil {
  25417. return
  25418. }
  25419. return *v, true
  25420. }
  25421. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  25422. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25424. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25425. if !m.op.Is(OpUpdateOne) {
  25426. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25427. }
  25428. if m.id == nil || m.oldValue == nil {
  25429. return v, errors.New("OldStatus requires an ID field in the mutation")
  25430. }
  25431. oldValue, err := m.oldValue(ctx)
  25432. if err != nil {
  25433. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25434. }
  25435. return oldValue.Status, nil
  25436. }
  25437. // AddStatus adds u to the "status" field.
  25438. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  25439. if m.addstatus != nil {
  25440. *m.addstatus += u
  25441. } else {
  25442. m.addstatus = &u
  25443. }
  25444. }
  25445. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25446. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  25447. v := m.addstatus
  25448. if v == nil {
  25449. return
  25450. }
  25451. return *v, true
  25452. }
  25453. // ClearStatus clears the value of the "status" field.
  25454. func (m *UsageStatisticHourMutation) ClearStatus() {
  25455. m.status = nil
  25456. m.addstatus = nil
  25457. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  25458. }
  25459. // StatusCleared returns if the "status" field was cleared in this mutation.
  25460. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  25461. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  25462. return ok
  25463. }
  25464. // ResetStatus resets all changes to the "status" field.
  25465. func (m *UsageStatisticHourMutation) ResetStatus() {
  25466. m.status = nil
  25467. m.addstatus = nil
  25468. delete(m.clearedFields, usagestatistichour.FieldStatus)
  25469. }
  25470. // SetDeletedAt sets the "deleted_at" field.
  25471. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  25472. m.deleted_at = &t
  25473. }
  25474. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25475. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  25476. v := m.deleted_at
  25477. if v == nil {
  25478. return
  25479. }
  25480. return *v, true
  25481. }
  25482. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  25483. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25485. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25486. if !m.op.Is(OpUpdateOne) {
  25487. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25488. }
  25489. if m.id == nil || m.oldValue == nil {
  25490. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25491. }
  25492. oldValue, err := m.oldValue(ctx)
  25493. if err != nil {
  25494. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25495. }
  25496. return oldValue.DeletedAt, nil
  25497. }
  25498. // ClearDeletedAt clears the value of the "deleted_at" field.
  25499. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  25500. m.deleted_at = nil
  25501. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  25502. }
  25503. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25504. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  25505. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  25506. return ok
  25507. }
  25508. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25509. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  25510. m.deleted_at = nil
  25511. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  25512. }
  25513. // SetAddtime sets the "addtime" field.
  25514. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  25515. m.addtime = &u
  25516. m.addaddtime = nil
  25517. }
  25518. // Addtime returns the value of the "addtime" field in the mutation.
  25519. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  25520. v := m.addtime
  25521. if v == nil {
  25522. return
  25523. }
  25524. return *v, true
  25525. }
  25526. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  25527. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25529. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  25530. if !m.op.Is(OpUpdateOne) {
  25531. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  25532. }
  25533. if m.id == nil || m.oldValue == nil {
  25534. return v, errors.New("OldAddtime requires an ID field in the mutation")
  25535. }
  25536. oldValue, err := m.oldValue(ctx)
  25537. if err != nil {
  25538. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  25539. }
  25540. return oldValue.Addtime, nil
  25541. }
  25542. // AddAddtime adds u to the "addtime" field.
  25543. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  25544. if m.addaddtime != nil {
  25545. *m.addaddtime += u
  25546. } else {
  25547. m.addaddtime = &u
  25548. }
  25549. }
  25550. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  25551. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  25552. v := m.addaddtime
  25553. if v == nil {
  25554. return
  25555. }
  25556. return *v, true
  25557. }
  25558. // ResetAddtime resets all changes to the "addtime" field.
  25559. func (m *UsageStatisticHourMutation) ResetAddtime() {
  25560. m.addtime = nil
  25561. m.addaddtime = nil
  25562. }
  25563. // SetType sets the "type" field.
  25564. func (m *UsageStatisticHourMutation) SetType(i int) {
  25565. m._type = &i
  25566. m.add_type = nil
  25567. }
  25568. // GetType returns the value of the "type" field in the mutation.
  25569. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  25570. v := m._type
  25571. if v == nil {
  25572. return
  25573. }
  25574. return *v, true
  25575. }
  25576. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  25577. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25579. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  25580. if !m.op.Is(OpUpdateOne) {
  25581. return v, errors.New("OldType is only allowed on UpdateOne operations")
  25582. }
  25583. if m.id == nil || m.oldValue == nil {
  25584. return v, errors.New("OldType requires an ID field in the mutation")
  25585. }
  25586. oldValue, err := m.oldValue(ctx)
  25587. if err != nil {
  25588. return v, fmt.Errorf("querying old value for OldType: %w", err)
  25589. }
  25590. return oldValue.Type, nil
  25591. }
  25592. // AddType adds i to the "type" field.
  25593. func (m *UsageStatisticHourMutation) AddType(i int) {
  25594. if m.add_type != nil {
  25595. *m.add_type += i
  25596. } else {
  25597. m.add_type = &i
  25598. }
  25599. }
  25600. // AddedType returns the value that was added to the "type" field in this mutation.
  25601. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  25602. v := m.add_type
  25603. if v == nil {
  25604. return
  25605. }
  25606. return *v, true
  25607. }
  25608. // ResetType resets all changes to the "type" field.
  25609. func (m *UsageStatisticHourMutation) ResetType() {
  25610. m._type = nil
  25611. m.add_type = nil
  25612. }
  25613. // SetBotID sets the "bot_id" field.
  25614. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  25615. m.bot_id = &s
  25616. }
  25617. // BotID returns the value of the "bot_id" field in the mutation.
  25618. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  25619. v := m.bot_id
  25620. if v == nil {
  25621. return
  25622. }
  25623. return *v, true
  25624. }
  25625. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  25626. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25628. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  25629. if !m.op.Is(OpUpdateOne) {
  25630. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  25631. }
  25632. if m.id == nil || m.oldValue == nil {
  25633. return v, errors.New("OldBotID requires an ID field in the mutation")
  25634. }
  25635. oldValue, err := m.oldValue(ctx)
  25636. if err != nil {
  25637. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  25638. }
  25639. return oldValue.BotID, nil
  25640. }
  25641. // ClearBotID clears the value of the "bot_id" field.
  25642. func (m *UsageStatisticHourMutation) ClearBotID() {
  25643. m.bot_id = nil
  25644. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  25645. }
  25646. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  25647. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  25648. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  25649. return ok
  25650. }
  25651. // ResetBotID resets all changes to the "bot_id" field.
  25652. func (m *UsageStatisticHourMutation) ResetBotID() {
  25653. m.bot_id = nil
  25654. delete(m.clearedFields, usagestatistichour.FieldBotID)
  25655. }
  25656. // SetOrganizationID sets the "organization_id" field.
  25657. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  25658. m.organization_id = &u
  25659. m.addorganization_id = nil
  25660. }
  25661. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25662. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  25663. v := m.organization_id
  25664. if v == nil {
  25665. return
  25666. }
  25667. return *v, true
  25668. }
  25669. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  25670. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25672. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25673. if !m.op.Is(OpUpdateOne) {
  25674. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25675. }
  25676. if m.id == nil || m.oldValue == nil {
  25677. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25678. }
  25679. oldValue, err := m.oldValue(ctx)
  25680. if err != nil {
  25681. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25682. }
  25683. return oldValue.OrganizationID, nil
  25684. }
  25685. // AddOrganizationID adds u to the "organization_id" field.
  25686. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  25687. if m.addorganization_id != nil {
  25688. *m.addorganization_id += u
  25689. } else {
  25690. m.addorganization_id = &u
  25691. }
  25692. }
  25693. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25694. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  25695. v := m.addorganization_id
  25696. if v == nil {
  25697. return
  25698. }
  25699. return *v, true
  25700. }
  25701. // ClearOrganizationID clears the value of the "organization_id" field.
  25702. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  25703. m.organization_id = nil
  25704. m.addorganization_id = nil
  25705. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  25706. }
  25707. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25708. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  25709. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  25710. return ok
  25711. }
  25712. // ResetOrganizationID resets all changes to the "organization_id" field.
  25713. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  25714. m.organization_id = nil
  25715. m.addorganization_id = nil
  25716. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  25717. }
  25718. // SetAiResponse sets the "ai_response" field.
  25719. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  25720. m.ai_response = &u
  25721. m.addai_response = nil
  25722. }
  25723. // AiResponse returns the value of the "ai_response" field in the mutation.
  25724. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  25725. v := m.ai_response
  25726. if v == nil {
  25727. return
  25728. }
  25729. return *v, true
  25730. }
  25731. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  25732. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25734. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  25735. if !m.op.Is(OpUpdateOne) {
  25736. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  25737. }
  25738. if m.id == nil || m.oldValue == nil {
  25739. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  25740. }
  25741. oldValue, err := m.oldValue(ctx)
  25742. if err != nil {
  25743. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  25744. }
  25745. return oldValue.AiResponse, nil
  25746. }
  25747. // AddAiResponse adds u to the "ai_response" field.
  25748. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  25749. if m.addai_response != nil {
  25750. *m.addai_response += u
  25751. } else {
  25752. m.addai_response = &u
  25753. }
  25754. }
  25755. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  25756. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  25757. v := m.addai_response
  25758. if v == nil {
  25759. return
  25760. }
  25761. return *v, true
  25762. }
  25763. // ResetAiResponse resets all changes to the "ai_response" field.
  25764. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  25765. m.ai_response = nil
  25766. m.addai_response = nil
  25767. }
  25768. // SetSopRun sets the "sop_run" field.
  25769. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  25770. m.sop_run = &u
  25771. m.addsop_run = nil
  25772. }
  25773. // SopRun returns the value of the "sop_run" field in the mutation.
  25774. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  25775. v := m.sop_run
  25776. if v == nil {
  25777. return
  25778. }
  25779. return *v, true
  25780. }
  25781. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  25782. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25784. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  25785. if !m.op.Is(OpUpdateOne) {
  25786. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  25787. }
  25788. if m.id == nil || m.oldValue == nil {
  25789. return v, errors.New("OldSopRun requires an ID field in the mutation")
  25790. }
  25791. oldValue, err := m.oldValue(ctx)
  25792. if err != nil {
  25793. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  25794. }
  25795. return oldValue.SopRun, nil
  25796. }
  25797. // AddSopRun adds u to the "sop_run" field.
  25798. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  25799. if m.addsop_run != nil {
  25800. *m.addsop_run += u
  25801. } else {
  25802. m.addsop_run = &u
  25803. }
  25804. }
  25805. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  25806. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  25807. v := m.addsop_run
  25808. if v == nil {
  25809. return
  25810. }
  25811. return *v, true
  25812. }
  25813. // ResetSopRun resets all changes to the "sop_run" field.
  25814. func (m *UsageStatisticHourMutation) ResetSopRun() {
  25815. m.sop_run = nil
  25816. m.addsop_run = nil
  25817. }
  25818. // SetTotalFriend sets the "total_friend" field.
  25819. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  25820. m.total_friend = &u
  25821. m.addtotal_friend = nil
  25822. }
  25823. // TotalFriend returns the value of the "total_friend" field in the mutation.
  25824. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  25825. v := m.total_friend
  25826. if v == nil {
  25827. return
  25828. }
  25829. return *v, true
  25830. }
  25831. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  25832. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25834. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  25835. if !m.op.Is(OpUpdateOne) {
  25836. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  25837. }
  25838. if m.id == nil || m.oldValue == nil {
  25839. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  25840. }
  25841. oldValue, err := m.oldValue(ctx)
  25842. if err != nil {
  25843. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  25844. }
  25845. return oldValue.TotalFriend, nil
  25846. }
  25847. // AddTotalFriend adds u to the "total_friend" field.
  25848. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  25849. if m.addtotal_friend != nil {
  25850. *m.addtotal_friend += u
  25851. } else {
  25852. m.addtotal_friend = &u
  25853. }
  25854. }
  25855. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  25856. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  25857. v := m.addtotal_friend
  25858. if v == nil {
  25859. return
  25860. }
  25861. return *v, true
  25862. }
  25863. // ResetTotalFriend resets all changes to the "total_friend" field.
  25864. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  25865. m.total_friend = nil
  25866. m.addtotal_friend = nil
  25867. }
  25868. // SetTotalGroup sets the "total_group" field.
  25869. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  25870. m.total_group = &u
  25871. m.addtotal_group = nil
  25872. }
  25873. // TotalGroup returns the value of the "total_group" field in the mutation.
  25874. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  25875. v := m.total_group
  25876. if v == nil {
  25877. return
  25878. }
  25879. return *v, true
  25880. }
  25881. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  25882. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25884. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  25885. if !m.op.Is(OpUpdateOne) {
  25886. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  25887. }
  25888. if m.id == nil || m.oldValue == nil {
  25889. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  25890. }
  25891. oldValue, err := m.oldValue(ctx)
  25892. if err != nil {
  25893. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  25894. }
  25895. return oldValue.TotalGroup, nil
  25896. }
  25897. // AddTotalGroup adds u to the "total_group" field.
  25898. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  25899. if m.addtotal_group != nil {
  25900. *m.addtotal_group += u
  25901. } else {
  25902. m.addtotal_group = &u
  25903. }
  25904. }
  25905. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  25906. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  25907. v := m.addtotal_group
  25908. if v == nil {
  25909. return
  25910. }
  25911. return *v, true
  25912. }
  25913. // ResetTotalGroup resets all changes to the "total_group" field.
  25914. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  25915. m.total_group = nil
  25916. m.addtotal_group = nil
  25917. }
  25918. // SetAccountBalance sets the "account_balance" field.
  25919. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  25920. m.account_balance = &u
  25921. m.addaccount_balance = nil
  25922. }
  25923. // AccountBalance returns the value of the "account_balance" field in the mutation.
  25924. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  25925. v := m.account_balance
  25926. if v == nil {
  25927. return
  25928. }
  25929. return *v, true
  25930. }
  25931. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  25932. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25934. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  25935. if !m.op.Is(OpUpdateOne) {
  25936. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  25937. }
  25938. if m.id == nil || m.oldValue == nil {
  25939. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  25940. }
  25941. oldValue, err := m.oldValue(ctx)
  25942. if err != nil {
  25943. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  25944. }
  25945. return oldValue.AccountBalance, nil
  25946. }
  25947. // AddAccountBalance adds u to the "account_balance" field.
  25948. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  25949. if m.addaccount_balance != nil {
  25950. *m.addaccount_balance += u
  25951. } else {
  25952. m.addaccount_balance = &u
  25953. }
  25954. }
  25955. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  25956. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  25957. v := m.addaccount_balance
  25958. if v == nil {
  25959. return
  25960. }
  25961. return *v, true
  25962. }
  25963. // ResetAccountBalance resets all changes to the "account_balance" field.
  25964. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  25965. m.account_balance = nil
  25966. m.addaccount_balance = nil
  25967. }
  25968. // SetConsumeToken sets the "consume_token" field.
  25969. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  25970. m.consume_token = &u
  25971. m.addconsume_token = nil
  25972. }
  25973. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  25974. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  25975. v := m.consume_token
  25976. if v == nil {
  25977. return
  25978. }
  25979. return *v, true
  25980. }
  25981. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  25982. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  25983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25984. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  25985. if !m.op.Is(OpUpdateOne) {
  25986. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  25987. }
  25988. if m.id == nil || m.oldValue == nil {
  25989. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  25990. }
  25991. oldValue, err := m.oldValue(ctx)
  25992. if err != nil {
  25993. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  25994. }
  25995. return oldValue.ConsumeToken, nil
  25996. }
  25997. // AddConsumeToken adds u to the "consume_token" field.
  25998. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  25999. if m.addconsume_token != nil {
  26000. *m.addconsume_token += u
  26001. } else {
  26002. m.addconsume_token = &u
  26003. }
  26004. }
  26005. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  26006. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  26007. v := m.addconsume_token
  26008. if v == nil {
  26009. return
  26010. }
  26011. return *v, true
  26012. }
  26013. // ResetConsumeToken resets all changes to the "consume_token" field.
  26014. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  26015. m.consume_token = nil
  26016. m.addconsume_token = nil
  26017. }
  26018. // SetActiveUser sets the "active_user" field.
  26019. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  26020. m.active_user = &u
  26021. m.addactive_user = nil
  26022. }
  26023. // ActiveUser returns the value of the "active_user" field in the mutation.
  26024. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  26025. v := m.active_user
  26026. if v == nil {
  26027. return
  26028. }
  26029. return *v, true
  26030. }
  26031. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  26032. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26034. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  26035. if !m.op.Is(OpUpdateOne) {
  26036. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  26037. }
  26038. if m.id == nil || m.oldValue == nil {
  26039. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  26040. }
  26041. oldValue, err := m.oldValue(ctx)
  26042. if err != nil {
  26043. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  26044. }
  26045. return oldValue.ActiveUser, nil
  26046. }
  26047. // AddActiveUser adds u to the "active_user" field.
  26048. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  26049. if m.addactive_user != nil {
  26050. *m.addactive_user += u
  26051. } else {
  26052. m.addactive_user = &u
  26053. }
  26054. }
  26055. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  26056. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  26057. v := m.addactive_user
  26058. if v == nil {
  26059. return
  26060. }
  26061. return *v, true
  26062. }
  26063. // ResetActiveUser resets all changes to the "active_user" field.
  26064. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  26065. m.active_user = nil
  26066. m.addactive_user = nil
  26067. }
  26068. // SetNewUser sets the "new_user" field.
  26069. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  26070. m.new_user = &i
  26071. m.addnew_user = nil
  26072. }
  26073. // NewUser returns the value of the "new_user" field in the mutation.
  26074. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  26075. v := m.new_user
  26076. if v == nil {
  26077. return
  26078. }
  26079. return *v, true
  26080. }
  26081. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  26082. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26084. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  26085. if !m.op.Is(OpUpdateOne) {
  26086. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  26087. }
  26088. if m.id == nil || m.oldValue == nil {
  26089. return v, errors.New("OldNewUser requires an ID field in the mutation")
  26090. }
  26091. oldValue, err := m.oldValue(ctx)
  26092. if err != nil {
  26093. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  26094. }
  26095. return oldValue.NewUser, nil
  26096. }
  26097. // AddNewUser adds i to the "new_user" field.
  26098. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  26099. if m.addnew_user != nil {
  26100. *m.addnew_user += i
  26101. } else {
  26102. m.addnew_user = &i
  26103. }
  26104. }
  26105. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  26106. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  26107. v := m.addnew_user
  26108. if v == nil {
  26109. return
  26110. }
  26111. return *v, true
  26112. }
  26113. // ResetNewUser resets all changes to the "new_user" field.
  26114. func (m *UsageStatisticHourMutation) ResetNewUser() {
  26115. m.new_user = nil
  26116. m.addnew_user = nil
  26117. }
  26118. // SetLabelDist sets the "label_dist" field.
  26119. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  26120. m.label_dist = &ctd
  26121. m.appendlabel_dist = nil
  26122. }
  26123. // LabelDist returns the value of the "label_dist" field in the mutation.
  26124. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  26125. v := m.label_dist
  26126. if v == nil {
  26127. return
  26128. }
  26129. return *v, true
  26130. }
  26131. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  26132. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26134. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  26135. if !m.op.Is(OpUpdateOne) {
  26136. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  26137. }
  26138. if m.id == nil || m.oldValue == nil {
  26139. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  26140. }
  26141. oldValue, err := m.oldValue(ctx)
  26142. if err != nil {
  26143. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  26144. }
  26145. return oldValue.LabelDist, nil
  26146. }
  26147. // AppendLabelDist adds ctd to the "label_dist" field.
  26148. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  26149. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  26150. }
  26151. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  26152. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  26153. if len(m.appendlabel_dist) == 0 {
  26154. return nil, false
  26155. }
  26156. return m.appendlabel_dist, true
  26157. }
  26158. // ResetLabelDist resets all changes to the "label_dist" field.
  26159. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  26160. m.label_dist = nil
  26161. m.appendlabel_dist = nil
  26162. }
  26163. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  26164. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  26165. m.predicates = append(m.predicates, ps...)
  26166. }
  26167. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  26168. // users can use type-assertion to append predicates that do not depend on any generated package.
  26169. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  26170. p := make([]predicate.UsageStatisticHour, len(ps))
  26171. for i := range ps {
  26172. p[i] = ps[i]
  26173. }
  26174. m.Where(p...)
  26175. }
  26176. // Op returns the operation name.
  26177. func (m *UsageStatisticHourMutation) Op() Op {
  26178. return m.op
  26179. }
  26180. // SetOp allows setting the mutation operation.
  26181. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  26182. m.op = op
  26183. }
  26184. // Type returns the node type of this mutation (UsageStatisticHour).
  26185. func (m *UsageStatisticHourMutation) Type() string {
  26186. return m.typ
  26187. }
  26188. // Fields returns all fields that were changed during this mutation. Note that in
  26189. // order to get all numeric fields that were incremented/decremented, call
  26190. // AddedFields().
  26191. func (m *UsageStatisticHourMutation) Fields() []string {
  26192. fields := make([]string, 0, 17)
  26193. if m.created_at != nil {
  26194. fields = append(fields, usagestatistichour.FieldCreatedAt)
  26195. }
  26196. if m.updated_at != nil {
  26197. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  26198. }
  26199. if m.status != nil {
  26200. fields = append(fields, usagestatistichour.FieldStatus)
  26201. }
  26202. if m.deleted_at != nil {
  26203. fields = append(fields, usagestatistichour.FieldDeletedAt)
  26204. }
  26205. if m.addtime != nil {
  26206. fields = append(fields, usagestatistichour.FieldAddtime)
  26207. }
  26208. if m._type != nil {
  26209. fields = append(fields, usagestatistichour.FieldType)
  26210. }
  26211. if m.bot_id != nil {
  26212. fields = append(fields, usagestatistichour.FieldBotID)
  26213. }
  26214. if m.organization_id != nil {
  26215. fields = append(fields, usagestatistichour.FieldOrganizationID)
  26216. }
  26217. if m.ai_response != nil {
  26218. fields = append(fields, usagestatistichour.FieldAiResponse)
  26219. }
  26220. if m.sop_run != nil {
  26221. fields = append(fields, usagestatistichour.FieldSopRun)
  26222. }
  26223. if m.total_friend != nil {
  26224. fields = append(fields, usagestatistichour.FieldTotalFriend)
  26225. }
  26226. if m.total_group != nil {
  26227. fields = append(fields, usagestatistichour.FieldTotalGroup)
  26228. }
  26229. if m.account_balance != nil {
  26230. fields = append(fields, usagestatistichour.FieldAccountBalance)
  26231. }
  26232. if m.consume_token != nil {
  26233. fields = append(fields, usagestatistichour.FieldConsumeToken)
  26234. }
  26235. if m.active_user != nil {
  26236. fields = append(fields, usagestatistichour.FieldActiveUser)
  26237. }
  26238. if m.new_user != nil {
  26239. fields = append(fields, usagestatistichour.FieldNewUser)
  26240. }
  26241. if m.label_dist != nil {
  26242. fields = append(fields, usagestatistichour.FieldLabelDist)
  26243. }
  26244. return fields
  26245. }
  26246. // Field returns the value of a field with the given name. The second boolean
  26247. // return value indicates that this field was not set, or was not defined in the
  26248. // schema.
  26249. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  26250. switch name {
  26251. case usagestatistichour.FieldCreatedAt:
  26252. return m.CreatedAt()
  26253. case usagestatistichour.FieldUpdatedAt:
  26254. return m.UpdatedAt()
  26255. case usagestatistichour.FieldStatus:
  26256. return m.Status()
  26257. case usagestatistichour.FieldDeletedAt:
  26258. return m.DeletedAt()
  26259. case usagestatistichour.FieldAddtime:
  26260. return m.Addtime()
  26261. case usagestatistichour.FieldType:
  26262. return m.GetType()
  26263. case usagestatistichour.FieldBotID:
  26264. return m.BotID()
  26265. case usagestatistichour.FieldOrganizationID:
  26266. return m.OrganizationID()
  26267. case usagestatistichour.FieldAiResponse:
  26268. return m.AiResponse()
  26269. case usagestatistichour.FieldSopRun:
  26270. return m.SopRun()
  26271. case usagestatistichour.FieldTotalFriend:
  26272. return m.TotalFriend()
  26273. case usagestatistichour.FieldTotalGroup:
  26274. return m.TotalGroup()
  26275. case usagestatistichour.FieldAccountBalance:
  26276. return m.AccountBalance()
  26277. case usagestatistichour.FieldConsumeToken:
  26278. return m.ConsumeToken()
  26279. case usagestatistichour.FieldActiveUser:
  26280. return m.ActiveUser()
  26281. case usagestatistichour.FieldNewUser:
  26282. return m.NewUser()
  26283. case usagestatistichour.FieldLabelDist:
  26284. return m.LabelDist()
  26285. }
  26286. return nil, false
  26287. }
  26288. // OldField returns the old value of the field from the database. An error is
  26289. // returned if the mutation operation is not UpdateOne, or the query to the
  26290. // database failed.
  26291. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26292. switch name {
  26293. case usagestatistichour.FieldCreatedAt:
  26294. return m.OldCreatedAt(ctx)
  26295. case usagestatistichour.FieldUpdatedAt:
  26296. return m.OldUpdatedAt(ctx)
  26297. case usagestatistichour.FieldStatus:
  26298. return m.OldStatus(ctx)
  26299. case usagestatistichour.FieldDeletedAt:
  26300. return m.OldDeletedAt(ctx)
  26301. case usagestatistichour.FieldAddtime:
  26302. return m.OldAddtime(ctx)
  26303. case usagestatistichour.FieldType:
  26304. return m.OldType(ctx)
  26305. case usagestatistichour.FieldBotID:
  26306. return m.OldBotID(ctx)
  26307. case usagestatistichour.FieldOrganizationID:
  26308. return m.OldOrganizationID(ctx)
  26309. case usagestatistichour.FieldAiResponse:
  26310. return m.OldAiResponse(ctx)
  26311. case usagestatistichour.FieldSopRun:
  26312. return m.OldSopRun(ctx)
  26313. case usagestatistichour.FieldTotalFriend:
  26314. return m.OldTotalFriend(ctx)
  26315. case usagestatistichour.FieldTotalGroup:
  26316. return m.OldTotalGroup(ctx)
  26317. case usagestatistichour.FieldAccountBalance:
  26318. return m.OldAccountBalance(ctx)
  26319. case usagestatistichour.FieldConsumeToken:
  26320. return m.OldConsumeToken(ctx)
  26321. case usagestatistichour.FieldActiveUser:
  26322. return m.OldActiveUser(ctx)
  26323. case usagestatistichour.FieldNewUser:
  26324. return m.OldNewUser(ctx)
  26325. case usagestatistichour.FieldLabelDist:
  26326. return m.OldLabelDist(ctx)
  26327. }
  26328. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  26329. }
  26330. // SetField sets the value of a field with the given name. It returns an error if
  26331. // the field is not defined in the schema, or if the type mismatched the field
  26332. // type.
  26333. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  26334. switch name {
  26335. case usagestatistichour.FieldCreatedAt:
  26336. v, ok := value.(time.Time)
  26337. if !ok {
  26338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26339. }
  26340. m.SetCreatedAt(v)
  26341. return nil
  26342. case usagestatistichour.FieldUpdatedAt:
  26343. v, ok := value.(time.Time)
  26344. if !ok {
  26345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26346. }
  26347. m.SetUpdatedAt(v)
  26348. return nil
  26349. case usagestatistichour.FieldStatus:
  26350. v, ok := value.(uint8)
  26351. if !ok {
  26352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26353. }
  26354. m.SetStatus(v)
  26355. return nil
  26356. case usagestatistichour.FieldDeletedAt:
  26357. v, ok := value.(time.Time)
  26358. if !ok {
  26359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26360. }
  26361. m.SetDeletedAt(v)
  26362. return nil
  26363. case usagestatistichour.FieldAddtime:
  26364. v, ok := value.(uint64)
  26365. if !ok {
  26366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26367. }
  26368. m.SetAddtime(v)
  26369. return nil
  26370. case usagestatistichour.FieldType:
  26371. v, ok := value.(int)
  26372. if !ok {
  26373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26374. }
  26375. m.SetType(v)
  26376. return nil
  26377. case usagestatistichour.FieldBotID:
  26378. v, ok := value.(string)
  26379. if !ok {
  26380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26381. }
  26382. m.SetBotID(v)
  26383. return nil
  26384. case usagestatistichour.FieldOrganizationID:
  26385. v, ok := value.(uint64)
  26386. if !ok {
  26387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26388. }
  26389. m.SetOrganizationID(v)
  26390. return nil
  26391. case usagestatistichour.FieldAiResponse:
  26392. v, ok := value.(uint64)
  26393. if !ok {
  26394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26395. }
  26396. m.SetAiResponse(v)
  26397. return nil
  26398. case usagestatistichour.FieldSopRun:
  26399. v, ok := value.(uint64)
  26400. if !ok {
  26401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26402. }
  26403. m.SetSopRun(v)
  26404. return nil
  26405. case usagestatistichour.FieldTotalFriend:
  26406. v, ok := value.(uint64)
  26407. if !ok {
  26408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26409. }
  26410. m.SetTotalFriend(v)
  26411. return nil
  26412. case usagestatistichour.FieldTotalGroup:
  26413. v, ok := value.(uint64)
  26414. if !ok {
  26415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26416. }
  26417. m.SetTotalGroup(v)
  26418. return nil
  26419. case usagestatistichour.FieldAccountBalance:
  26420. v, ok := value.(uint64)
  26421. if !ok {
  26422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26423. }
  26424. m.SetAccountBalance(v)
  26425. return nil
  26426. case usagestatistichour.FieldConsumeToken:
  26427. v, ok := value.(uint64)
  26428. if !ok {
  26429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26430. }
  26431. m.SetConsumeToken(v)
  26432. return nil
  26433. case usagestatistichour.FieldActiveUser:
  26434. v, ok := value.(uint64)
  26435. if !ok {
  26436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26437. }
  26438. m.SetActiveUser(v)
  26439. return nil
  26440. case usagestatistichour.FieldNewUser:
  26441. v, ok := value.(int64)
  26442. if !ok {
  26443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26444. }
  26445. m.SetNewUser(v)
  26446. return nil
  26447. case usagestatistichour.FieldLabelDist:
  26448. v, ok := value.([]custom_types.LabelDist)
  26449. if !ok {
  26450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26451. }
  26452. m.SetLabelDist(v)
  26453. return nil
  26454. }
  26455. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  26456. }
  26457. // AddedFields returns all numeric fields that were incremented/decremented during
  26458. // this mutation.
  26459. func (m *UsageStatisticHourMutation) AddedFields() []string {
  26460. var fields []string
  26461. if m.addstatus != nil {
  26462. fields = append(fields, usagestatistichour.FieldStatus)
  26463. }
  26464. if m.addaddtime != nil {
  26465. fields = append(fields, usagestatistichour.FieldAddtime)
  26466. }
  26467. if m.add_type != nil {
  26468. fields = append(fields, usagestatistichour.FieldType)
  26469. }
  26470. if m.addorganization_id != nil {
  26471. fields = append(fields, usagestatistichour.FieldOrganizationID)
  26472. }
  26473. if m.addai_response != nil {
  26474. fields = append(fields, usagestatistichour.FieldAiResponse)
  26475. }
  26476. if m.addsop_run != nil {
  26477. fields = append(fields, usagestatistichour.FieldSopRun)
  26478. }
  26479. if m.addtotal_friend != nil {
  26480. fields = append(fields, usagestatistichour.FieldTotalFriend)
  26481. }
  26482. if m.addtotal_group != nil {
  26483. fields = append(fields, usagestatistichour.FieldTotalGroup)
  26484. }
  26485. if m.addaccount_balance != nil {
  26486. fields = append(fields, usagestatistichour.FieldAccountBalance)
  26487. }
  26488. if m.addconsume_token != nil {
  26489. fields = append(fields, usagestatistichour.FieldConsumeToken)
  26490. }
  26491. if m.addactive_user != nil {
  26492. fields = append(fields, usagestatistichour.FieldActiveUser)
  26493. }
  26494. if m.addnew_user != nil {
  26495. fields = append(fields, usagestatistichour.FieldNewUser)
  26496. }
  26497. return fields
  26498. }
  26499. // AddedField returns the numeric value that was incremented/decremented on a field
  26500. // with the given name. The second boolean return value indicates that this field
  26501. // was not set, or was not defined in the schema.
  26502. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  26503. switch name {
  26504. case usagestatistichour.FieldStatus:
  26505. return m.AddedStatus()
  26506. case usagestatistichour.FieldAddtime:
  26507. return m.AddedAddtime()
  26508. case usagestatistichour.FieldType:
  26509. return m.AddedType()
  26510. case usagestatistichour.FieldOrganizationID:
  26511. return m.AddedOrganizationID()
  26512. case usagestatistichour.FieldAiResponse:
  26513. return m.AddedAiResponse()
  26514. case usagestatistichour.FieldSopRun:
  26515. return m.AddedSopRun()
  26516. case usagestatistichour.FieldTotalFriend:
  26517. return m.AddedTotalFriend()
  26518. case usagestatistichour.FieldTotalGroup:
  26519. return m.AddedTotalGroup()
  26520. case usagestatistichour.FieldAccountBalance:
  26521. return m.AddedAccountBalance()
  26522. case usagestatistichour.FieldConsumeToken:
  26523. return m.AddedConsumeToken()
  26524. case usagestatistichour.FieldActiveUser:
  26525. return m.AddedActiveUser()
  26526. case usagestatistichour.FieldNewUser:
  26527. return m.AddedNewUser()
  26528. }
  26529. return nil, false
  26530. }
  26531. // AddField adds the value to the field with the given name. It returns an error if
  26532. // the field is not defined in the schema, or if the type mismatched the field
  26533. // type.
  26534. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  26535. switch name {
  26536. case usagestatistichour.FieldStatus:
  26537. v, ok := value.(int8)
  26538. if !ok {
  26539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26540. }
  26541. m.AddStatus(v)
  26542. return nil
  26543. case usagestatistichour.FieldAddtime:
  26544. v, ok := value.(int64)
  26545. if !ok {
  26546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26547. }
  26548. m.AddAddtime(v)
  26549. return nil
  26550. case usagestatistichour.FieldType:
  26551. v, ok := value.(int)
  26552. if !ok {
  26553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26554. }
  26555. m.AddType(v)
  26556. return nil
  26557. case usagestatistichour.FieldOrganizationID:
  26558. v, ok := value.(int64)
  26559. if !ok {
  26560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26561. }
  26562. m.AddOrganizationID(v)
  26563. return nil
  26564. case usagestatistichour.FieldAiResponse:
  26565. v, ok := value.(int64)
  26566. if !ok {
  26567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26568. }
  26569. m.AddAiResponse(v)
  26570. return nil
  26571. case usagestatistichour.FieldSopRun:
  26572. v, ok := value.(int64)
  26573. if !ok {
  26574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26575. }
  26576. m.AddSopRun(v)
  26577. return nil
  26578. case usagestatistichour.FieldTotalFriend:
  26579. v, ok := value.(int64)
  26580. if !ok {
  26581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26582. }
  26583. m.AddTotalFriend(v)
  26584. return nil
  26585. case usagestatistichour.FieldTotalGroup:
  26586. v, ok := value.(int64)
  26587. if !ok {
  26588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26589. }
  26590. m.AddTotalGroup(v)
  26591. return nil
  26592. case usagestatistichour.FieldAccountBalance:
  26593. v, ok := value.(int64)
  26594. if !ok {
  26595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26596. }
  26597. m.AddAccountBalance(v)
  26598. return nil
  26599. case usagestatistichour.FieldConsumeToken:
  26600. v, ok := value.(int64)
  26601. if !ok {
  26602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26603. }
  26604. m.AddConsumeToken(v)
  26605. return nil
  26606. case usagestatistichour.FieldActiveUser:
  26607. v, ok := value.(int64)
  26608. if !ok {
  26609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26610. }
  26611. m.AddActiveUser(v)
  26612. return nil
  26613. case usagestatistichour.FieldNewUser:
  26614. v, ok := value.(int64)
  26615. if !ok {
  26616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26617. }
  26618. m.AddNewUser(v)
  26619. return nil
  26620. }
  26621. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  26622. }
  26623. // ClearedFields returns all nullable fields that were cleared during this
  26624. // mutation.
  26625. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  26626. var fields []string
  26627. if m.FieldCleared(usagestatistichour.FieldStatus) {
  26628. fields = append(fields, usagestatistichour.FieldStatus)
  26629. }
  26630. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  26631. fields = append(fields, usagestatistichour.FieldDeletedAt)
  26632. }
  26633. if m.FieldCleared(usagestatistichour.FieldBotID) {
  26634. fields = append(fields, usagestatistichour.FieldBotID)
  26635. }
  26636. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  26637. fields = append(fields, usagestatistichour.FieldOrganizationID)
  26638. }
  26639. return fields
  26640. }
  26641. // FieldCleared returns a boolean indicating if a field with the given name was
  26642. // cleared in this mutation.
  26643. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  26644. _, ok := m.clearedFields[name]
  26645. return ok
  26646. }
  26647. // ClearField clears the value of the field with the given name. It returns an
  26648. // error if the field is not defined in the schema.
  26649. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  26650. switch name {
  26651. case usagestatistichour.FieldStatus:
  26652. m.ClearStatus()
  26653. return nil
  26654. case usagestatistichour.FieldDeletedAt:
  26655. m.ClearDeletedAt()
  26656. return nil
  26657. case usagestatistichour.FieldBotID:
  26658. m.ClearBotID()
  26659. return nil
  26660. case usagestatistichour.FieldOrganizationID:
  26661. m.ClearOrganizationID()
  26662. return nil
  26663. }
  26664. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  26665. }
  26666. // ResetField resets all changes in the mutation for the field with the given name.
  26667. // It returns an error if the field is not defined in the schema.
  26668. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  26669. switch name {
  26670. case usagestatistichour.FieldCreatedAt:
  26671. m.ResetCreatedAt()
  26672. return nil
  26673. case usagestatistichour.FieldUpdatedAt:
  26674. m.ResetUpdatedAt()
  26675. return nil
  26676. case usagestatistichour.FieldStatus:
  26677. m.ResetStatus()
  26678. return nil
  26679. case usagestatistichour.FieldDeletedAt:
  26680. m.ResetDeletedAt()
  26681. return nil
  26682. case usagestatistichour.FieldAddtime:
  26683. m.ResetAddtime()
  26684. return nil
  26685. case usagestatistichour.FieldType:
  26686. m.ResetType()
  26687. return nil
  26688. case usagestatistichour.FieldBotID:
  26689. m.ResetBotID()
  26690. return nil
  26691. case usagestatistichour.FieldOrganizationID:
  26692. m.ResetOrganizationID()
  26693. return nil
  26694. case usagestatistichour.FieldAiResponse:
  26695. m.ResetAiResponse()
  26696. return nil
  26697. case usagestatistichour.FieldSopRun:
  26698. m.ResetSopRun()
  26699. return nil
  26700. case usagestatistichour.FieldTotalFriend:
  26701. m.ResetTotalFriend()
  26702. return nil
  26703. case usagestatistichour.FieldTotalGroup:
  26704. m.ResetTotalGroup()
  26705. return nil
  26706. case usagestatistichour.FieldAccountBalance:
  26707. m.ResetAccountBalance()
  26708. return nil
  26709. case usagestatistichour.FieldConsumeToken:
  26710. m.ResetConsumeToken()
  26711. return nil
  26712. case usagestatistichour.FieldActiveUser:
  26713. m.ResetActiveUser()
  26714. return nil
  26715. case usagestatistichour.FieldNewUser:
  26716. m.ResetNewUser()
  26717. return nil
  26718. case usagestatistichour.FieldLabelDist:
  26719. m.ResetLabelDist()
  26720. return nil
  26721. }
  26722. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  26723. }
  26724. // AddedEdges returns all edge names that were set/added in this mutation.
  26725. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  26726. edges := make([]string, 0, 0)
  26727. return edges
  26728. }
  26729. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26730. // name in this mutation.
  26731. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  26732. return nil
  26733. }
  26734. // RemovedEdges returns all edge names that were removed in this mutation.
  26735. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  26736. edges := make([]string, 0, 0)
  26737. return edges
  26738. }
  26739. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26740. // the given name in this mutation.
  26741. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  26742. return nil
  26743. }
  26744. // ClearedEdges returns all edge names that were cleared in this mutation.
  26745. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  26746. edges := make([]string, 0, 0)
  26747. return edges
  26748. }
  26749. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26750. // was cleared in this mutation.
  26751. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  26752. return false
  26753. }
  26754. // ClearEdge clears the value of the edge with the given name. It returns an error
  26755. // if that edge is not defined in the schema.
  26756. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  26757. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  26758. }
  26759. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26760. // It returns an error if the edge is not defined in the schema.
  26761. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  26762. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  26763. }
  26764. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  26765. type UsageStatisticMonthMutation struct {
  26766. config
  26767. op Op
  26768. typ string
  26769. id *uint64
  26770. created_at *time.Time
  26771. updated_at *time.Time
  26772. status *uint8
  26773. addstatus *int8
  26774. deleted_at *time.Time
  26775. addtime *uint64
  26776. addaddtime *int64
  26777. _type *int
  26778. add_type *int
  26779. bot_id *string
  26780. organization_id *uint64
  26781. addorganization_id *int64
  26782. ai_response *uint64
  26783. addai_response *int64
  26784. sop_run *uint64
  26785. addsop_run *int64
  26786. total_friend *uint64
  26787. addtotal_friend *int64
  26788. total_group *uint64
  26789. addtotal_group *int64
  26790. account_balance *uint64
  26791. addaccount_balance *int64
  26792. consume_token *uint64
  26793. addconsume_token *int64
  26794. active_user *uint64
  26795. addactive_user *int64
  26796. new_user *int64
  26797. addnew_user *int64
  26798. label_dist *[]custom_types.LabelDist
  26799. appendlabel_dist []custom_types.LabelDist
  26800. clearedFields map[string]struct{}
  26801. done bool
  26802. oldValue func(context.Context) (*UsageStatisticMonth, error)
  26803. predicates []predicate.UsageStatisticMonth
  26804. }
  26805. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  26806. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  26807. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  26808. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  26809. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  26810. m := &UsageStatisticMonthMutation{
  26811. config: c,
  26812. op: op,
  26813. typ: TypeUsageStatisticMonth,
  26814. clearedFields: make(map[string]struct{}),
  26815. }
  26816. for _, opt := range opts {
  26817. opt(m)
  26818. }
  26819. return m
  26820. }
  26821. // withUsageStatisticMonthID sets the ID field of the mutation.
  26822. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  26823. return func(m *UsageStatisticMonthMutation) {
  26824. var (
  26825. err error
  26826. once sync.Once
  26827. value *UsageStatisticMonth
  26828. )
  26829. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  26830. once.Do(func() {
  26831. if m.done {
  26832. err = errors.New("querying old values post mutation is not allowed")
  26833. } else {
  26834. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  26835. }
  26836. })
  26837. return value, err
  26838. }
  26839. m.id = &id
  26840. }
  26841. }
  26842. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  26843. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  26844. return func(m *UsageStatisticMonthMutation) {
  26845. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  26846. return node, nil
  26847. }
  26848. m.id = &node.ID
  26849. }
  26850. }
  26851. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26852. // executed in a transaction (ent.Tx), a transactional client is returned.
  26853. func (m UsageStatisticMonthMutation) Client() *Client {
  26854. client := &Client{config: m.config}
  26855. client.init()
  26856. return client
  26857. }
  26858. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26859. // it returns an error otherwise.
  26860. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  26861. if _, ok := m.driver.(*txDriver); !ok {
  26862. return nil, errors.New("ent: mutation is not running in a transaction")
  26863. }
  26864. tx := &Tx{config: m.config}
  26865. tx.init()
  26866. return tx, nil
  26867. }
  26868. // SetID sets the value of the id field. Note that this
  26869. // operation is only accepted on creation of UsageStatisticMonth entities.
  26870. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  26871. m.id = &id
  26872. }
  26873. // ID returns the ID value in the mutation. Note that the ID is only available
  26874. // if it was provided to the builder or after it was returned from the database.
  26875. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  26876. if m.id == nil {
  26877. return
  26878. }
  26879. return *m.id, true
  26880. }
  26881. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26882. // That means, if the mutation is applied within a transaction with an isolation level such
  26883. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26884. // or updated by the mutation.
  26885. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  26886. switch {
  26887. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26888. id, exists := m.ID()
  26889. if exists {
  26890. return []uint64{id}, nil
  26891. }
  26892. fallthrough
  26893. case m.op.Is(OpUpdate | OpDelete):
  26894. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  26895. default:
  26896. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26897. }
  26898. }
  26899. // SetCreatedAt sets the "created_at" field.
  26900. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  26901. m.created_at = &t
  26902. }
  26903. // CreatedAt returns the value of the "created_at" field in the mutation.
  26904. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  26905. v := m.created_at
  26906. if v == nil {
  26907. return
  26908. }
  26909. return *v, true
  26910. }
  26911. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  26912. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  26913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26914. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26915. if !m.op.Is(OpUpdateOne) {
  26916. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26917. }
  26918. if m.id == nil || m.oldValue == nil {
  26919. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26920. }
  26921. oldValue, err := m.oldValue(ctx)
  26922. if err != nil {
  26923. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26924. }
  26925. return oldValue.CreatedAt, nil
  26926. }
  26927. // ResetCreatedAt resets all changes to the "created_at" field.
  26928. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  26929. m.created_at = nil
  26930. }
  26931. // SetUpdatedAt sets the "updated_at" field.
  26932. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  26933. m.updated_at = &t
  26934. }
  26935. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26936. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  26937. v := m.updated_at
  26938. if v == nil {
  26939. return
  26940. }
  26941. return *v, true
  26942. }
  26943. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  26944. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  26945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26946. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26947. if !m.op.Is(OpUpdateOne) {
  26948. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26949. }
  26950. if m.id == nil || m.oldValue == nil {
  26951. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26952. }
  26953. oldValue, err := m.oldValue(ctx)
  26954. if err != nil {
  26955. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26956. }
  26957. return oldValue.UpdatedAt, nil
  26958. }
  26959. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26960. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  26961. m.updated_at = nil
  26962. }
  26963. // SetStatus sets the "status" field.
  26964. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  26965. m.status = &u
  26966. m.addstatus = nil
  26967. }
  26968. // Status returns the value of the "status" field in the mutation.
  26969. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  26970. v := m.status
  26971. if v == nil {
  26972. return
  26973. }
  26974. return *v, true
  26975. }
  26976. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  26977. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  26978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26979. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26980. if !m.op.Is(OpUpdateOne) {
  26981. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26982. }
  26983. if m.id == nil || m.oldValue == nil {
  26984. return v, errors.New("OldStatus requires an ID field in the mutation")
  26985. }
  26986. oldValue, err := m.oldValue(ctx)
  26987. if err != nil {
  26988. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26989. }
  26990. return oldValue.Status, nil
  26991. }
  26992. // AddStatus adds u to the "status" field.
  26993. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  26994. if m.addstatus != nil {
  26995. *m.addstatus += u
  26996. } else {
  26997. m.addstatus = &u
  26998. }
  26999. }
  27000. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27001. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  27002. v := m.addstatus
  27003. if v == nil {
  27004. return
  27005. }
  27006. return *v, true
  27007. }
  27008. // ClearStatus clears the value of the "status" field.
  27009. func (m *UsageStatisticMonthMutation) ClearStatus() {
  27010. m.status = nil
  27011. m.addstatus = nil
  27012. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  27013. }
  27014. // StatusCleared returns if the "status" field was cleared in this mutation.
  27015. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  27016. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  27017. return ok
  27018. }
  27019. // ResetStatus resets all changes to the "status" field.
  27020. func (m *UsageStatisticMonthMutation) ResetStatus() {
  27021. m.status = nil
  27022. m.addstatus = nil
  27023. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  27024. }
  27025. // SetDeletedAt sets the "deleted_at" field.
  27026. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  27027. m.deleted_at = &t
  27028. }
  27029. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27030. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  27031. v := m.deleted_at
  27032. if v == nil {
  27033. return
  27034. }
  27035. return *v, true
  27036. }
  27037. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  27038. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27040. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27041. if !m.op.Is(OpUpdateOne) {
  27042. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27043. }
  27044. if m.id == nil || m.oldValue == nil {
  27045. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27046. }
  27047. oldValue, err := m.oldValue(ctx)
  27048. if err != nil {
  27049. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27050. }
  27051. return oldValue.DeletedAt, nil
  27052. }
  27053. // ClearDeletedAt clears the value of the "deleted_at" field.
  27054. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  27055. m.deleted_at = nil
  27056. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  27057. }
  27058. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27059. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  27060. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  27061. return ok
  27062. }
  27063. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27064. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  27065. m.deleted_at = nil
  27066. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  27067. }
  27068. // SetAddtime sets the "addtime" field.
  27069. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  27070. m.addtime = &u
  27071. m.addaddtime = nil
  27072. }
  27073. // Addtime returns the value of the "addtime" field in the mutation.
  27074. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  27075. v := m.addtime
  27076. if v == nil {
  27077. return
  27078. }
  27079. return *v, true
  27080. }
  27081. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  27082. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27084. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  27085. if !m.op.Is(OpUpdateOne) {
  27086. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  27087. }
  27088. if m.id == nil || m.oldValue == nil {
  27089. return v, errors.New("OldAddtime requires an ID field in the mutation")
  27090. }
  27091. oldValue, err := m.oldValue(ctx)
  27092. if err != nil {
  27093. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  27094. }
  27095. return oldValue.Addtime, nil
  27096. }
  27097. // AddAddtime adds u to the "addtime" field.
  27098. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  27099. if m.addaddtime != nil {
  27100. *m.addaddtime += u
  27101. } else {
  27102. m.addaddtime = &u
  27103. }
  27104. }
  27105. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  27106. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  27107. v := m.addaddtime
  27108. if v == nil {
  27109. return
  27110. }
  27111. return *v, true
  27112. }
  27113. // ResetAddtime resets all changes to the "addtime" field.
  27114. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  27115. m.addtime = nil
  27116. m.addaddtime = nil
  27117. }
  27118. // SetType sets the "type" field.
  27119. func (m *UsageStatisticMonthMutation) SetType(i int) {
  27120. m._type = &i
  27121. m.add_type = nil
  27122. }
  27123. // GetType returns the value of the "type" field in the mutation.
  27124. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  27125. v := m._type
  27126. if v == nil {
  27127. return
  27128. }
  27129. return *v, true
  27130. }
  27131. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  27132. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27134. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  27135. if !m.op.Is(OpUpdateOne) {
  27136. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27137. }
  27138. if m.id == nil || m.oldValue == nil {
  27139. return v, errors.New("OldType requires an ID field in the mutation")
  27140. }
  27141. oldValue, err := m.oldValue(ctx)
  27142. if err != nil {
  27143. return v, fmt.Errorf("querying old value for OldType: %w", err)
  27144. }
  27145. return oldValue.Type, nil
  27146. }
  27147. // AddType adds i to the "type" field.
  27148. func (m *UsageStatisticMonthMutation) AddType(i int) {
  27149. if m.add_type != nil {
  27150. *m.add_type += i
  27151. } else {
  27152. m.add_type = &i
  27153. }
  27154. }
  27155. // AddedType returns the value that was added to the "type" field in this mutation.
  27156. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  27157. v := m.add_type
  27158. if v == nil {
  27159. return
  27160. }
  27161. return *v, true
  27162. }
  27163. // ResetType resets all changes to the "type" field.
  27164. func (m *UsageStatisticMonthMutation) ResetType() {
  27165. m._type = nil
  27166. m.add_type = nil
  27167. }
  27168. // SetBotID sets the "bot_id" field.
  27169. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  27170. m.bot_id = &s
  27171. }
  27172. // BotID returns the value of the "bot_id" field in the mutation.
  27173. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  27174. v := m.bot_id
  27175. if v == nil {
  27176. return
  27177. }
  27178. return *v, true
  27179. }
  27180. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  27181. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27183. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  27184. if !m.op.Is(OpUpdateOne) {
  27185. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27186. }
  27187. if m.id == nil || m.oldValue == nil {
  27188. return v, errors.New("OldBotID requires an ID field in the mutation")
  27189. }
  27190. oldValue, err := m.oldValue(ctx)
  27191. if err != nil {
  27192. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27193. }
  27194. return oldValue.BotID, nil
  27195. }
  27196. // ClearBotID clears the value of the "bot_id" field.
  27197. func (m *UsageStatisticMonthMutation) ClearBotID() {
  27198. m.bot_id = nil
  27199. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  27200. }
  27201. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  27202. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  27203. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  27204. return ok
  27205. }
  27206. // ResetBotID resets all changes to the "bot_id" field.
  27207. func (m *UsageStatisticMonthMutation) ResetBotID() {
  27208. m.bot_id = nil
  27209. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  27210. }
  27211. // SetOrganizationID sets the "organization_id" field.
  27212. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  27213. m.organization_id = &u
  27214. m.addorganization_id = nil
  27215. }
  27216. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27217. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  27218. v := m.organization_id
  27219. if v == nil {
  27220. return
  27221. }
  27222. return *v, true
  27223. }
  27224. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  27225. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27227. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27228. if !m.op.Is(OpUpdateOne) {
  27229. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27230. }
  27231. if m.id == nil || m.oldValue == nil {
  27232. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27233. }
  27234. oldValue, err := m.oldValue(ctx)
  27235. if err != nil {
  27236. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27237. }
  27238. return oldValue.OrganizationID, nil
  27239. }
  27240. // AddOrganizationID adds u to the "organization_id" field.
  27241. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  27242. if m.addorganization_id != nil {
  27243. *m.addorganization_id += u
  27244. } else {
  27245. m.addorganization_id = &u
  27246. }
  27247. }
  27248. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27249. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  27250. v := m.addorganization_id
  27251. if v == nil {
  27252. return
  27253. }
  27254. return *v, true
  27255. }
  27256. // ClearOrganizationID clears the value of the "organization_id" field.
  27257. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  27258. m.organization_id = nil
  27259. m.addorganization_id = nil
  27260. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  27261. }
  27262. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27263. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  27264. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  27265. return ok
  27266. }
  27267. // ResetOrganizationID resets all changes to the "organization_id" field.
  27268. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  27269. m.organization_id = nil
  27270. m.addorganization_id = nil
  27271. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  27272. }
  27273. // SetAiResponse sets the "ai_response" field.
  27274. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  27275. m.ai_response = &u
  27276. m.addai_response = nil
  27277. }
  27278. // AiResponse returns the value of the "ai_response" field in the mutation.
  27279. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  27280. v := m.ai_response
  27281. if v == nil {
  27282. return
  27283. }
  27284. return *v, true
  27285. }
  27286. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  27287. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27289. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  27290. if !m.op.Is(OpUpdateOne) {
  27291. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  27292. }
  27293. if m.id == nil || m.oldValue == nil {
  27294. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  27295. }
  27296. oldValue, err := m.oldValue(ctx)
  27297. if err != nil {
  27298. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  27299. }
  27300. return oldValue.AiResponse, nil
  27301. }
  27302. // AddAiResponse adds u to the "ai_response" field.
  27303. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  27304. if m.addai_response != nil {
  27305. *m.addai_response += u
  27306. } else {
  27307. m.addai_response = &u
  27308. }
  27309. }
  27310. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  27311. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  27312. v := m.addai_response
  27313. if v == nil {
  27314. return
  27315. }
  27316. return *v, true
  27317. }
  27318. // ResetAiResponse resets all changes to the "ai_response" field.
  27319. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  27320. m.ai_response = nil
  27321. m.addai_response = nil
  27322. }
  27323. // SetSopRun sets the "sop_run" field.
  27324. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  27325. m.sop_run = &u
  27326. m.addsop_run = nil
  27327. }
  27328. // SopRun returns the value of the "sop_run" field in the mutation.
  27329. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  27330. v := m.sop_run
  27331. if v == nil {
  27332. return
  27333. }
  27334. return *v, true
  27335. }
  27336. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  27337. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27339. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  27340. if !m.op.Is(OpUpdateOne) {
  27341. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  27342. }
  27343. if m.id == nil || m.oldValue == nil {
  27344. return v, errors.New("OldSopRun requires an ID field in the mutation")
  27345. }
  27346. oldValue, err := m.oldValue(ctx)
  27347. if err != nil {
  27348. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  27349. }
  27350. return oldValue.SopRun, nil
  27351. }
  27352. // AddSopRun adds u to the "sop_run" field.
  27353. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  27354. if m.addsop_run != nil {
  27355. *m.addsop_run += u
  27356. } else {
  27357. m.addsop_run = &u
  27358. }
  27359. }
  27360. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  27361. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  27362. v := m.addsop_run
  27363. if v == nil {
  27364. return
  27365. }
  27366. return *v, true
  27367. }
  27368. // ResetSopRun resets all changes to the "sop_run" field.
  27369. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  27370. m.sop_run = nil
  27371. m.addsop_run = nil
  27372. }
  27373. // SetTotalFriend sets the "total_friend" field.
  27374. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  27375. m.total_friend = &u
  27376. m.addtotal_friend = nil
  27377. }
  27378. // TotalFriend returns the value of the "total_friend" field in the mutation.
  27379. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  27380. v := m.total_friend
  27381. if v == nil {
  27382. return
  27383. }
  27384. return *v, true
  27385. }
  27386. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  27387. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27389. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  27390. if !m.op.Is(OpUpdateOne) {
  27391. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  27392. }
  27393. if m.id == nil || m.oldValue == nil {
  27394. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  27395. }
  27396. oldValue, err := m.oldValue(ctx)
  27397. if err != nil {
  27398. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  27399. }
  27400. return oldValue.TotalFriend, nil
  27401. }
  27402. // AddTotalFriend adds u to the "total_friend" field.
  27403. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  27404. if m.addtotal_friend != nil {
  27405. *m.addtotal_friend += u
  27406. } else {
  27407. m.addtotal_friend = &u
  27408. }
  27409. }
  27410. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  27411. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  27412. v := m.addtotal_friend
  27413. if v == nil {
  27414. return
  27415. }
  27416. return *v, true
  27417. }
  27418. // ResetTotalFriend resets all changes to the "total_friend" field.
  27419. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  27420. m.total_friend = nil
  27421. m.addtotal_friend = nil
  27422. }
  27423. // SetTotalGroup sets the "total_group" field.
  27424. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  27425. m.total_group = &u
  27426. m.addtotal_group = nil
  27427. }
  27428. // TotalGroup returns the value of the "total_group" field in the mutation.
  27429. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  27430. v := m.total_group
  27431. if v == nil {
  27432. return
  27433. }
  27434. return *v, true
  27435. }
  27436. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  27437. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27439. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  27440. if !m.op.Is(OpUpdateOne) {
  27441. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  27442. }
  27443. if m.id == nil || m.oldValue == nil {
  27444. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  27445. }
  27446. oldValue, err := m.oldValue(ctx)
  27447. if err != nil {
  27448. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  27449. }
  27450. return oldValue.TotalGroup, nil
  27451. }
  27452. // AddTotalGroup adds u to the "total_group" field.
  27453. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  27454. if m.addtotal_group != nil {
  27455. *m.addtotal_group += u
  27456. } else {
  27457. m.addtotal_group = &u
  27458. }
  27459. }
  27460. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  27461. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  27462. v := m.addtotal_group
  27463. if v == nil {
  27464. return
  27465. }
  27466. return *v, true
  27467. }
  27468. // ResetTotalGroup resets all changes to the "total_group" field.
  27469. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  27470. m.total_group = nil
  27471. m.addtotal_group = nil
  27472. }
  27473. // SetAccountBalance sets the "account_balance" field.
  27474. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  27475. m.account_balance = &u
  27476. m.addaccount_balance = nil
  27477. }
  27478. // AccountBalance returns the value of the "account_balance" field in the mutation.
  27479. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  27480. v := m.account_balance
  27481. if v == nil {
  27482. return
  27483. }
  27484. return *v, true
  27485. }
  27486. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  27487. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27489. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  27490. if !m.op.Is(OpUpdateOne) {
  27491. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  27492. }
  27493. if m.id == nil || m.oldValue == nil {
  27494. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  27495. }
  27496. oldValue, err := m.oldValue(ctx)
  27497. if err != nil {
  27498. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  27499. }
  27500. return oldValue.AccountBalance, nil
  27501. }
  27502. // AddAccountBalance adds u to the "account_balance" field.
  27503. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  27504. if m.addaccount_balance != nil {
  27505. *m.addaccount_balance += u
  27506. } else {
  27507. m.addaccount_balance = &u
  27508. }
  27509. }
  27510. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  27511. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  27512. v := m.addaccount_balance
  27513. if v == nil {
  27514. return
  27515. }
  27516. return *v, true
  27517. }
  27518. // ResetAccountBalance resets all changes to the "account_balance" field.
  27519. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  27520. m.account_balance = nil
  27521. m.addaccount_balance = nil
  27522. }
  27523. // SetConsumeToken sets the "consume_token" field.
  27524. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  27525. m.consume_token = &u
  27526. m.addconsume_token = nil
  27527. }
  27528. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  27529. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  27530. v := m.consume_token
  27531. if v == nil {
  27532. return
  27533. }
  27534. return *v, true
  27535. }
  27536. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  27537. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27539. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  27540. if !m.op.Is(OpUpdateOne) {
  27541. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  27542. }
  27543. if m.id == nil || m.oldValue == nil {
  27544. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  27545. }
  27546. oldValue, err := m.oldValue(ctx)
  27547. if err != nil {
  27548. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  27549. }
  27550. return oldValue.ConsumeToken, nil
  27551. }
  27552. // AddConsumeToken adds u to the "consume_token" field.
  27553. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  27554. if m.addconsume_token != nil {
  27555. *m.addconsume_token += u
  27556. } else {
  27557. m.addconsume_token = &u
  27558. }
  27559. }
  27560. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  27561. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  27562. v := m.addconsume_token
  27563. if v == nil {
  27564. return
  27565. }
  27566. return *v, true
  27567. }
  27568. // ResetConsumeToken resets all changes to the "consume_token" field.
  27569. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  27570. m.consume_token = nil
  27571. m.addconsume_token = nil
  27572. }
  27573. // SetActiveUser sets the "active_user" field.
  27574. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  27575. m.active_user = &u
  27576. m.addactive_user = nil
  27577. }
  27578. // ActiveUser returns the value of the "active_user" field in the mutation.
  27579. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  27580. v := m.active_user
  27581. if v == nil {
  27582. return
  27583. }
  27584. return *v, true
  27585. }
  27586. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  27587. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27589. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  27590. if !m.op.Is(OpUpdateOne) {
  27591. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  27592. }
  27593. if m.id == nil || m.oldValue == nil {
  27594. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  27595. }
  27596. oldValue, err := m.oldValue(ctx)
  27597. if err != nil {
  27598. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  27599. }
  27600. return oldValue.ActiveUser, nil
  27601. }
  27602. // AddActiveUser adds u to the "active_user" field.
  27603. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  27604. if m.addactive_user != nil {
  27605. *m.addactive_user += u
  27606. } else {
  27607. m.addactive_user = &u
  27608. }
  27609. }
  27610. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  27611. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  27612. v := m.addactive_user
  27613. if v == nil {
  27614. return
  27615. }
  27616. return *v, true
  27617. }
  27618. // ResetActiveUser resets all changes to the "active_user" field.
  27619. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  27620. m.active_user = nil
  27621. m.addactive_user = nil
  27622. }
  27623. // SetNewUser sets the "new_user" field.
  27624. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  27625. m.new_user = &i
  27626. m.addnew_user = nil
  27627. }
  27628. // NewUser returns the value of the "new_user" field in the mutation.
  27629. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  27630. v := m.new_user
  27631. if v == nil {
  27632. return
  27633. }
  27634. return *v, true
  27635. }
  27636. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  27637. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27639. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  27640. if !m.op.Is(OpUpdateOne) {
  27641. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  27642. }
  27643. if m.id == nil || m.oldValue == nil {
  27644. return v, errors.New("OldNewUser requires an ID field in the mutation")
  27645. }
  27646. oldValue, err := m.oldValue(ctx)
  27647. if err != nil {
  27648. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  27649. }
  27650. return oldValue.NewUser, nil
  27651. }
  27652. // AddNewUser adds i to the "new_user" field.
  27653. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  27654. if m.addnew_user != nil {
  27655. *m.addnew_user += i
  27656. } else {
  27657. m.addnew_user = &i
  27658. }
  27659. }
  27660. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  27661. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  27662. v := m.addnew_user
  27663. if v == nil {
  27664. return
  27665. }
  27666. return *v, true
  27667. }
  27668. // ResetNewUser resets all changes to the "new_user" field.
  27669. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  27670. m.new_user = nil
  27671. m.addnew_user = nil
  27672. }
  27673. // SetLabelDist sets the "label_dist" field.
  27674. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  27675. m.label_dist = &ctd
  27676. m.appendlabel_dist = nil
  27677. }
  27678. // LabelDist returns the value of the "label_dist" field in the mutation.
  27679. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  27680. v := m.label_dist
  27681. if v == nil {
  27682. return
  27683. }
  27684. return *v, true
  27685. }
  27686. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  27687. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27689. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  27690. if !m.op.Is(OpUpdateOne) {
  27691. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  27692. }
  27693. if m.id == nil || m.oldValue == nil {
  27694. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  27695. }
  27696. oldValue, err := m.oldValue(ctx)
  27697. if err != nil {
  27698. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  27699. }
  27700. return oldValue.LabelDist, nil
  27701. }
  27702. // AppendLabelDist adds ctd to the "label_dist" field.
  27703. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  27704. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  27705. }
  27706. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  27707. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  27708. if len(m.appendlabel_dist) == 0 {
  27709. return nil, false
  27710. }
  27711. return m.appendlabel_dist, true
  27712. }
  27713. // ResetLabelDist resets all changes to the "label_dist" field.
  27714. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  27715. m.label_dist = nil
  27716. m.appendlabel_dist = nil
  27717. }
  27718. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  27719. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  27720. m.predicates = append(m.predicates, ps...)
  27721. }
  27722. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  27723. // users can use type-assertion to append predicates that do not depend on any generated package.
  27724. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  27725. p := make([]predicate.UsageStatisticMonth, len(ps))
  27726. for i := range ps {
  27727. p[i] = ps[i]
  27728. }
  27729. m.Where(p...)
  27730. }
  27731. // Op returns the operation name.
  27732. func (m *UsageStatisticMonthMutation) Op() Op {
  27733. return m.op
  27734. }
  27735. // SetOp allows setting the mutation operation.
  27736. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  27737. m.op = op
  27738. }
  27739. // Type returns the node type of this mutation (UsageStatisticMonth).
  27740. func (m *UsageStatisticMonthMutation) Type() string {
  27741. return m.typ
  27742. }
  27743. // Fields returns all fields that were changed during this mutation. Note that in
  27744. // order to get all numeric fields that were incremented/decremented, call
  27745. // AddedFields().
  27746. func (m *UsageStatisticMonthMutation) Fields() []string {
  27747. fields := make([]string, 0, 17)
  27748. if m.created_at != nil {
  27749. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  27750. }
  27751. if m.updated_at != nil {
  27752. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  27753. }
  27754. if m.status != nil {
  27755. fields = append(fields, usagestatisticmonth.FieldStatus)
  27756. }
  27757. if m.deleted_at != nil {
  27758. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  27759. }
  27760. if m.addtime != nil {
  27761. fields = append(fields, usagestatisticmonth.FieldAddtime)
  27762. }
  27763. if m._type != nil {
  27764. fields = append(fields, usagestatisticmonth.FieldType)
  27765. }
  27766. if m.bot_id != nil {
  27767. fields = append(fields, usagestatisticmonth.FieldBotID)
  27768. }
  27769. if m.organization_id != nil {
  27770. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  27771. }
  27772. if m.ai_response != nil {
  27773. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  27774. }
  27775. if m.sop_run != nil {
  27776. fields = append(fields, usagestatisticmonth.FieldSopRun)
  27777. }
  27778. if m.total_friend != nil {
  27779. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  27780. }
  27781. if m.total_group != nil {
  27782. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  27783. }
  27784. if m.account_balance != nil {
  27785. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  27786. }
  27787. if m.consume_token != nil {
  27788. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  27789. }
  27790. if m.active_user != nil {
  27791. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  27792. }
  27793. if m.new_user != nil {
  27794. fields = append(fields, usagestatisticmonth.FieldNewUser)
  27795. }
  27796. if m.label_dist != nil {
  27797. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  27798. }
  27799. return fields
  27800. }
  27801. // Field returns the value of a field with the given name. The second boolean
  27802. // return value indicates that this field was not set, or was not defined in the
  27803. // schema.
  27804. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  27805. switch name {
  27806. case usagestatisticmonth.FieldCreatedAt:
  27807. return m.CreatedAt()
  27808. case usagestatisticmonth.FieldUpdatedAt:
  27809. return m.UpdatedAt()
  27810. case usagestatisticmonth.FieldStatus:
  27811. return m.Status()
  27812. case usagestatisticmonth.FieldDeletedAt:
  27813. return m.DeletedAt()
  27814. case usagestatisticmonth.FieldAddtime:
  27815. return m.Addtime()
  27816. case usagestatisticmonth.FieldType:
  27817. return m.GetType()
  27818. case usagestatisticmonth.FieldBotID:
  27819. return m.BotID()
  27820. case usagestatisticmonth.FieldOrganizationID:
  27821. return m.OrganizationID()
  27822. case usagestatisticmonth.FieldAiResponse:
  27823. return m.AiResponse()
  27824. case usagestatisticmonth.FieldSopRun:
  27825. return m.SopRun()
  27826. case usagestatisticmonth.FieldTotalFriend:
  27827. return m.TotalFriend()
  27828. case usagestatisticmonth.FieldTotalGroup:
  27829. return m.TotalGroup()
  27830. case usagestatisticmonth.FieldAccountBalance:
  27831. return m.AccountBalance()
  27832. case usagestatisticmonth.FieldConsumeToken:
  27833. return m.ConsumeToken()
  27834. case usagestatisticmonth.FieldActiveUser:
  27835. return m.ActiveUser()
  27836. case usagestatisticmonth.FieldNewUser:
  27837. return m.NewUser()
  27838. case usagestatisticmonth.FieldLabelDist:
  27839. return m.LabelDist()
  27840. }
  27841. return nil, false
  27842. }
  27843. // OldField returns the old value of the field from the database. An error is
  27844. // returned if the mutation operation is not UpdateOne, or the query to the
  27845. // database failed.
  27846. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27847. switch name {
  27848. case usagestatisticmonth.FieldCreatedAt:
  27849. return m.OldCreatedAt(ctx)
  27850. case usagestatisticmonth.FieldUpdatedAt:
  27851. return m.OldUpdatedAt(ctx)
  27852. case usagestatisticmonth.FieldStatus:
  27853. return m.OldStatus(ctx)
  27854. case usagestatisticmonth.FieldDeletedAt:
  27855. return m.OldDeletedAt(ctx)
  27856. case usagestatisticmonth.FieldAddtime:
  27857. return m.OldAddtime(ctx)
  27858. case usagestatisticmonth.FieldType:
  27859. return m.OldType(ctx)
  27860. case usagestatisticmonth.FieldBotID:
  27861. return m.OldBotID(ctx)
  27862. case usagestatisticmonth.FieldOrganizationID:
  27863. return m.OldOrganizationID(ctx)
  27864. case usagestatisticmonth.FieldAiResponse:
  27865. return m.OldAiResponse(ctx)
  27866. case usagestatisticmonth.FieldSopRun:
  27867. return m.OldSopRun(ctx)
  27868. case usagestatisticmonth.FieldTotalFriend:
  27869. return m.OldTotalFriend(ctx)
  27870. case usagestatisticmonth.FieldTotalGroup:
  27871. return m.OldTotalGroup(ctx)
  27872. case usagestatisticmonth.FieldAccountBalance:
  27873. return m.OldAccountBalance(ctx)
  27874. case usagestatisticmonth.FieldConsumeToken:
  27875. return m.OldConsumeToken(ctx)
  27876. case usagestatisticmonth.FieldActiveUser:
  27877. return m.OldActiveUser(ctx)
  27878. case usagestatisticmonth.FieldNewUser:
  27879. return m.OldNewUser(ctx)
  27880. case usagestatisticmonth.FieldLabelDist:
  27881. return m.OldLabelDist(ctx)
  27882. }
  27883. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  27884. }
  27885. // SetField sets the value of a field with the given name. It returns an error if
  27886. // the field is not defined in the schema, or if the type mismatched the field
  27887. // type.
  27888. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  27889. switch name {
  27890. case usagestatisticmonth.FieldCreatedAt:
  27891. v, ok := value.(time.Time)
  27892. if !ok {
  27893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27894. }
  27895. m.SetCreatedAt(v)
  27896. return nil
  27897. case usagestatisticmonth.FieldUpdatedAt:
  27898. v, ok := value.(time.Time)
  27899. if !ok {
  27900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27901. }
  27902. m.SetUpdatedAt(v)
  27903. return nil
  27904. case usagestatisticmonth.FieldStatus:
  27905. v, ok := value.(uint8)
  27906. if !ok {
  27907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27908. }
  27909. m.SetStatus(v)
  27910. return nil
  27911. case usagestatisticmonth.FieldDeletedAt:
  27912. v, ok := value.(time.Time)
  27913. if !ok {
  27914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27915. }
  27916. m.SetDeletedAt(v)
  27917. return nil
  27918. case usagestatisticmonth.FieldAddtime:
  27919. v, ok := value.(uint64)
  27920. if !ok {
  27921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27922. }
  27923. m.SetAddtime(v)
  27924. return nil
  27925. case usagestatisticmonth.FieldType:
  27926. v, ok := value.(int)
  27927. if !ok {
  27928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27929. }
  27930. m.SetType(v)
  27931. return nil
  27932. case usagestatisticmonth.FieldBotID:
  27933. v, ok := value.(string)
  27934. if !ok {
  27935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27936. }
  27937. m.SetBotID(v)
  27938. return nil
  27939. case usagestatisticmonth.FieldOrganizationID:
  27940. v, ok := value.(uint64)
  27941. if !ok {
  27942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27943. }
  27944. m.SetOrganizationID(v)
  27945. return nil
  27946. case usagestatisticmonth.FieldAiResponse:
  27947. v, ok := value.(uint64)
  27948. if !ok {
  27949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27950. }
  27951. m.SetAiResponse(v)
  27952. return nil
  27953. case usagestatisticmonth.FieldSopRun:
  27954. v, ok := value.(uint64)
  27955. if !ok {
  27956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27957. }
  27958. m.SetSopRun(v)
  27959. return nil
  27960. case usagestatisticmonth.FieldTotalFriend:
  27961. v, ok := value.(uint64)
  27962. if !ok {
  27963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27964. }
  27965. m.SetTotalFriend(v)
  27966. return nil
  27967. case usagestatisticmonth.FieldTotalGroup:
  27968. v, ok := value.(uint64)
  27969. if !ok {
  27970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27971. }
  27972. m.SetTotalGroup(v)
  27973. return nil
  27974. case usagestatisticmonth.FieldAccountBalance:
  27975. v, ok := value.(uint64)
  27976. if !ok {
  27977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27978. }
  27979. m.SetAccountBalance(v)
  27980. return nil
  27981. case usagestatisticmonth.FieldConsumeToken:
  27982. v, ok := value.(uint64)
  27983. if !ok {
  27984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27985. }
  27986. m.SetConsumeToken(v)
  27987. return nil
  27988. case usagestatisticmonth.FieldActiveUser:
  27989. v, ok := value.(uint64)
  27990. if !ok {
  27991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27992. }
  27993. m.SetActiveUser(v)
  27994. return nil
  27995. case usagestatisticmonth.FieldNewUser:
  27996. v, ok := value.(int64)
  27997. if !ok {
  27998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27999. }
  28000. m.SetNewUser(v)
  28001. return nil
  28002. case usagestatisticmonth.FieldLabelDist:
  28003. v, ok := value.([]custom_types.LabelDist)
  28004. if !ok {
  28005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28006. }
  28007. m.SetLabelDist(v)
  28008. return nil
  28009. }
  28010. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  28011. }
  28012. // AddedFields returns all numeric fields that were incremented/decremented during
  28013. // this mutation.
  28014. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  28015. var fields []string
  28016. if m.addstatus != nil {
  28017. fields = append(fields, usagestatisticmonth.FieldStatus)
  28018. }
  28019. if m.addaddtime != nil {
  28020. fields = append(fields, usagestatisticmonth.FieldAddtime)
  28021. }
  28022. if m.add_type != nil {
  28023. fields = append(fields, usagestatisticmonth.FieldType)
  28024. }
  28025. if m.addorganization_id != nil {
  28026. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  28027. }
  28028. if m.addai_response != nil {
  28029. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  28030. }
  28031. if m.addsop_run != nil {
  28032. fields = append(fields, usagestatisticmonth.FieldSopRun)
  28033. }
  28034. if m.addtotal_friend != nil {
  28035. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  28036. }
  28037. if m.addtotal_group != nil {
  28038. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  28039. }
  28040. if m.addaccount_balance != nil {
  28041. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  28042. }
  28043. if m.addconsume_token != nil {
  28044. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  28045. }
  28046. if m.addactive_user != nil {
  28047. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  28048. }
  28049. if m.addnew_user != nil {
  28050. fields = append(fields, usagestatisticmonth.FieldNewUser)
  28051. }
  28052. return fields
  28053. }
  28054. // AddedField returns the numeric value that was incremented/decremented on a field
  28055. // with the given name. The second boolean return value indicates that this field
  28056. // was not set, or was not defined in the schema.
  28057. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  28058. switch name {
  28059. case usagestatisticmonth.FieldStatus:
  28060. return m.AddedStatus()
  28061. case usagestatisticmonth.FieldAddtime:
  28062. return m.AddedAddtime()
  28063. case usagestatisticmonth.FieldType:
  28064. return m.AddedType()
  28065. case usagestatisticmonth.FieldOrganizationID:
  28066. return m.AddedOrganizationID()
  28067. case usagestatisticmonth.FieldAiResponse:
  28068. return m.AddedAiResponse()
  28069. case usagestatisticmonth.FieldSopRun:
  28070. return m.AddedSopRun()
  28071. case usagestatisticmonth.FieldTotalFriend:
  28072. return m.AddedTotalFriend()
  28073. case usagestatisticmonth.FieldTotalGroup:
  28074. return m.AddedTotalGroup()
  28075. case usagestatisticmonth.FieldAccountBalance:
  28076. return m.AddedAccountBalance()
  28077. case usagestatisticmonth.FieldConsumeToken:
  28078. return m.AddedConsumeToken()
  28079. case usagestatisticmonth.FieldActiveUser:
  28080. return m.AddedActiveUser()
  28081. case usagestatisticmonth.FieldNewUser:
  28082. return m.AddedNewUser()
  28083. }
  28084. return nil, false
  28085. }
  28086. // AddField adds the value to the field with the given name. It returns an error if
  28087. // the field is not defined in the schema, or if the type mismatched the field
  28088. // type.
  28089. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  28090. switch name {
  28091. case usagestatisticmonth.FieldStatus:
  28092. v, ok := value.(int8)
  28093. if !ok {
  28094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28095. }
  28096. m.AddStatus(v)
  28097. return nil
  28098. case usagestatisticmonth.FieldAddtime:
  28099. v, ok := value.(int64)
  28100. if !ok {
  28101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28102. }
  28103. m.AddAddtime(v)
  28104. return nil
  28105. case usagestatisticmonth.FieldType:
  28106. v, ok := value.(int)
  28107. if !ok {
  28108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28109. }
  28110. m.AddType(v)
  28111. return nil
  28112. case usagestatisticmonth.FieldOrganizationID:
  28113. v, ok := value.(int64)
  28114. if !ok {
  28115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28116. }
  28117. m.AddOrganizationID(v)
  28118. return nil
  28119. case usagestatisticmonth.FieldAiResponse:
  28120. v, ok := value.(int64)
  28121. if !ok {
  28122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28123. }
  28124. m.AddAiResponse(v)
  28125. return nil
  28126. case usagestatisticmonth.FieldSopRun:
  28127. v, ok := value.(int64)
  28128. if !ok {
  28129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28130. }
  28131. m.AddSopRun(v)
  28132. return nil
  28133. case usagestatisticmonth.FieldTotalFriend:
  28134. v, ok := value.(int64)
  28135. if !ok {
  28136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28137. }
  28138. m.AddTotalFriend(v)
  28139. return nil
  28140. case usagestatisticmonth.FieldTotalGroup:
  28141. v, ok := value.(int64)
  28142. if !ok {
  28143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28144. }
  28145. m.AddTotalGroup(v)
  28146. return nil
  28147. case usagestatisticmonth.FieldAccountBalance:
  28148. v, ok := value.(int64)
  28149. if !ok {
  28150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28151. }
  28152. m.AddAccountBalance(v)
  28153. return nil
  28154. case usagestatisticmonth.FieldConsumeToken:
  28155. v, ok := value.(int64)
  28156. if !ok {
  28157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28158. }
  28159. m.AddConsumeToken(v)
  28160. return nil
  28161. case usagestatisticmonth.FieldActiveUser:
  28162. v, ok := value.(int64)
  28163. if !ok {
  28164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28165. }
  28166. m.AddActiveUser(v)
  28167. return nil
  28168. case usagestatisticmonth.FieldNewUser:
  28169. v, ok := value.(int64)
  28170. if !ok {
  28171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28172. }
  28173. m.AddNewUser(v)
  28174. return nil
  28175. }
  28176. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  28177. }
  28178. // ClearedFields returns all nullable fields that were cleared during this
  28179. // mutation.
  28180. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  28181. var fields []string
  28182. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  28183. fields = append(fields, usagestatisticmonth.FieldStatus)
  28184. }
  28185. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  28186. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  28187. }
  28188. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  28189. fields = append(fields, usagestatisticmonth.FieldBotID)
  28190. }
  28191. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  28192. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  28193. }
  28194. return fields
  28195. }
  28196. // FieldCleared returns a boolean indicating if a field with the given name was
  28197. // cleared in this mutation.
  28198. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  28199. _, ok := m.clearedFields[name]
  28200. return ok
  28201. }
  28202. // ClearField clears the value of the field with the given name. It returns an
  28203. // error if the field is not defined in the schema.
  28204. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  28205. switch name {
  28206. case usagestatisticmonth.FieldStatus:
  28207. m.ClearStatus()
  28208. return nil
  28209. case usagestatisticmonth.FieldDeletedAt:
  28210. m.ClearDeletedAt()
  28211. return nil
  28212. case usagestatisticmonth.FieldBotID:
  28213. m.ClearBotID()
  28214. return nil
  28215. case usagestatisticmonth.FieldOrganizationID:
  28216. m.ClearOrganizationID()
  28217. return nil
  28218. }
  28219. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  28220. }
  28221. // ResetField resets all changes in the mutation for the field with the given name.
  28222. // It returns an error if the field is not defined in the schema.
  28223. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  28224. switch name {
  28225. case usagestatisticmonth.FieldCreatedAt:
  28226. m.ResetCreatedAt()
  28227. return nil
  28228. case usagestatisticmonth.FieldUpdatedAt:
  28229. m.ResetUpdatedAt()
  28230. return nil
  28231. case usagestatisticmonth.FieldStatus:
  28232. m.ResetStatus()
  28233. return nil
  28234. case usagestatisticmonth.FieldDeletedAt:
  28235. m.ResetDeletedAt()
  28236. return nil
  28237. case usagestatisticmonth.FieldAddtime:
  28238. m.ResetAddtime()
  28239. return nil
  28240. case usagestatisticmonth.FieldType:
  28241. m.ResetType()
  28242. return nil
  28243. case usagestatisticmonth.FieldBotID:
  28244. m.ResetBotID()
  28245. return nil
  28246. case usagestatisticmonth.FieldOrganizationID:
  28247. m.ResetOrganizationID()
  28248. return nil
  28249. case usagestatisticmonth.FieldAiResponse:
  28250. m.ResetAiResponse()
  28251. return nil
  28252. case usagestatisticmonth.FieldSopRun:
  28253. m.ResetSopRun()
  28254. return nil
  28255. case usagestatisticmonth.FieldTotalFriend:
  28256. m.ResetTotalFriend()
  28257. return nil
  28258. case usagestatisticmonth.FieldTotalGroup:
  28259. m.ResetTotalGroup()
  28260. return nil
  28261. case usagestatisticmonth.FieldAccountBalance:
  28262. m.ResetAccountBalance()
  28263. return nil
  28264. case usagestatisticmonth.FieldConsumeToken:
  28265. m.ResetConsumeToken()
  28266. return nil
  28267. case usagestatisticmonth.FieldActiveUser:
  28268. m.ResetActiveUser()
  28269. return nil
  28270. case usagestatisticmonth.FieldNewUser:
  28271. m.ResetNewUser()
  28272. return nil
  28273. case usagestatisticmonth.FieldLabelDist:
  28274. m.ResetLabelDist()
  28275. return nil
  28276. }
  28277. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  28278. }
  28279. // AddedEdges returns all edge names that were set/added in this mutation.
  28280. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  28281. edges := make([]string, 0, 0)
  28282. return edges
  28283. }
  28284. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28285. // name in this mutation.
  28286. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  28287. return nil
  28288. }
  28289. // RemovedEdges returns all edge names that were removed in this mutation.
  28290. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  28291. edges := make([]string, 0, 0)
  28292. return edges
  28293. }
  28294. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28295. // the given name in this mutation.
  28296. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  28297. return nil
  28298. }
  28299. // ClearedEdges returns all edge names that were cleared in this mutation.
  28300. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  28301. edges := make([]string, 0, 0)
  28302. return edges
  28303. }
  28304. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28305. // was cleared in this mutation.
  28306. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  28307. return false
  28308. }
  28309. // ClearEdge clears the value of the edge with the given name. It returns an error
  28310. // if that edge is not defined in the schema.
  28311. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  28312. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  28313. }
  28314. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28315. // It returns an error if the edge is not defined in the schema.
  28316. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  28317. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  28318. }
  28319. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  28320. type UsageTotalMutation struct {
  28321. config
  28322. op Op
  28323. typ string
  28324. id *uint64
  28325. created_at *time.Time
  28326. updated_at *time.Time
  28327. status *uint8
  28328. addstatus *int8
  28329. _type *int
  28330. add_type *int
  28331. bot_id *string
  28332. total_tokens *uint64
  28333. addtotal_tokens *int64
  28334. start_index *uint64
  28335. addstart_index *int64
  28336. end_index *uint64
  28337. addend_index *int64
  28338. organization_id *uint64
  28339. addorganization_id *int64
  28340. clearedFields map[string]struct{}
  28341. done bool
  28342. oldValue func(context.Context) (*UsageTotal, error)
  28343. predicates []predicate.UsageTotal
  28344. }
  28345. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  28346. // usagetotalOption allows management of the mutation configuration using functional options.
  28347. type usagetotalOption func(*UsageTotalMutation)
  28348. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  28349. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  28350. m := &UsageTotalMutation{
  28351. config: c,
  28352. op: op,
  28353. typ: TypeUsageTotal,
  28354. clearedFields: make(map[string]struct{}),
  28355. }
  28356. for _, opt := range opts {
  28357. opt(m)
  28358. }
  28359. return m
  28360. }
  28361. // withUsageTotalID sets the ID field of the mutation.
  28362. func withUsageTotalID(id uint64) usagetotalOption {
  28363. return func(m *UsageTotalMutation) {
  28364. var (
  28365. err error
  28366. once sync.Once
  28367. value *UsageTotal
  28368. )
  28369. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  28370. once.Do(func() {
  28371. if m.done {
  28372. err = errors.New("querying old values post mutation is not allowed")
  28373. } else {
  28374. value, err = m.Client().UsageTotal.Get(ctx, id)
  28375. }
  28376. })
  28377. return value, err
  28378. }
  28379. m.id = &id
  28380. }
  28381. }
  28382. // withUsageTotal sets the old UsageTotal of the mutation.
  28383. func withUsageTotal(node *UsageTotal) usagetotalOption {
  28384. return func(m *UsageTotalMutation) {
  28385. m.oldValue = func(context.Context) (*UsageTotal, error) {
  28386. return node, nil
  28387. }
  28388. m.id = &node.ID
  28389. }
  28390. }
  28391. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28392. // executed in a transaction (ent.Tx), a transactional client is returned.
  28393. func (m UsageTotalMutation) Client() *Client {
  28394. client := &Client{config: m.config}
  28395. client.init()
  28396. return client
  28397. }
  28398. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28399. // it returns an error otherwise.
  28400. func (m UsageTotalMutation) Tx() (*Tx, error) {
  28401. if _, ok := m.driver.(*txDriver); !ok {
  28402. return nil, errors.New("ent: mutation is not running in a transaction")
  28403. }
  28404. tx := &Tx{config: m.config}
  28405. tx.init()
  28406. return tx, nil
  28407. }
  28408. // SetID sets the value of the id field. Note that this
  28409. // operation is only accepted on creation of UsageTotal entities.
  28410. func (m *UsageTotalMutation) SetID(id uint64) {
  28411. m.id = &id
  28412. }
  28413. // ID returns the ID value in the mutation. Note that the ID is only available
  28414. // if it was provided to the builder or after it was returned from the database.
  28415. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  28416. if m.id == nil {
  28417. return
  28418. }
  28419. return *m.id, true
  28420. }
  28421. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28422. // That means, if the mutation is applied within a transaction with an isolation level such
  28423. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28424. // or updated by the mutation.
  28425. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  28426. switch {
  28427. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28428. id, exists := m.ID()
  28429. if exists {
  28430. return []uint64{id}, nil
  28431. }
  28432. fallthrough
  28433. case m.op.Is(OpUpdate | OpDelete):
  28434. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  28435. default:
  28436. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28437. }
  28438. }
  28439. // SetCreatedAt sets the "created_at" field.
  28440. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  28441. m.created_at = &t
  28442. }
  28443. // CreatedAt returns the value of the "created_at" field in the mutation.
  28444. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  28445. v := m.created_at
  28446. if v == nil {
  28447. return
  28448. }
  28449. return *v, true
  28450. }
  28451. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  28452. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28454. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28455. if !m.op.Is(OpUpdateOne) {
  28456. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28457. }
  28458. if m.id == nil || m.oldValue == nil {
  28459. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28460. }
  28461. oldValue, err := m.oldValue(ctx)
  28462. if err != nil {
  28463. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28464. }
  28465. return oldValue.CreatedAt, nil
  28466. }
  28467. // ResetCreatedAt resets all changes to the "created_at" field.
  28468. func (m *UsageTotalMutation) ResetCreatedAt() {
  28469. m.created_at = nil
  28470. }
  28471. // SetUpdatedAt sets the "updated_at" field.
  28472. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  28473. m.updated_at = &t
  28474. }
  28475. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28476. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  28477. v := m.updated_at
  28478. if v == nil {
  28479. return
  28480. }
  28481. return *v, true
  28482. }
  28483. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  28484. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28486. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28487. if !m.op.Is(OpUpdateOne) {
  28488. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28489. }
  28490. if m.id == nil || m.oldValue == nil {
  28491. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28492. }
  28493. oldValue, err := m.oldValue(ctx)
  28494. if err != nil {
  28495. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28496. }
  28497. return oldValue.UpdatedAt, nil
  28498. }
  28499. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28500. func (m *UsageTotalMutation) ResetUpdatedAt() {
  28501. m.updated_at = nil
  28502. }
  28503. // SetStatus sets the "status" field.
  28504. func (m *UsageTotalMutation) SetStatus(u uint8) {
  28505. m.status = &u
  28506. m.addstatus = nil
  28507. }
  28508. // Status returns the value of the "status" field in the mutation.
  28509. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  28510. v := m.status
  28511. if v == nil {
  28512. return
  28513. }
  28514. return *v, true
  28515. }
  28516. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  28517. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28519. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28520. if !m.op.Is(OpUpdateOne) {
  28521. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28522. }
  28523. if m.id == nil || m.oldValue == nil {
  28524. return v, errors.New("OldStatus requires an ID field in the mutation")
  28525. }
  28526. oldValue, err := m.oldValue(ctx)
  28527. if err != nil {
  28528. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28529. }
  28530. return oldValue.Status, nil
  28531. }
  28532. // AddStatus adds u to the "status" field.
  28533. func (m *UsageTotalMutation) AddStatus(u int8) {
  28534. if m.addstatus != nil {
  28535. *m.addstatus += u
  28536. } else {
  28537. m.addstatus = &u
  28538. }
  28539. }
  28540. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28541. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  28542. v := m.addstatus
  28543. if v == nil {
  28544. return
  28545. }
  28546. return *v, true
  28547. }
  28548. // ClearStatus clears the value of the "status" field.
  28549. func (m *UsageTotalMutation) ClearStatus() {
  28550. m.status = nil
  28551. m.addstatus = nil
  28552. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  28553. }
  28554. // StatusCleared returns if the "status" field was cleared in this mutation.
  28555. func (m *UsageTotalMutation) StatusCleared() bool {
  28556. _, ok := m.clearedFields[usagetotal.FieldStatus]
  28557. return ok
  28558. }
  28559. // ResetStatus resets all changes to the "status" field.
  28560. func (m *UsageTotalMutation) ResetStatus() {
  28561. m.status = nil
  28562. m.addstatus = nil
  28563. delete(m.clearedFields, usagetotal.FieldStatus)
  28564. }
  28565. // SetType sets the "type" field.
  28566. func (m *UsageTotalMutation) SetType(i int) {
  28567. m._type = &i
  28568. m.add_type = nil
  28569. }
  28570. // GetType returns the value of the "type" field in the mutation.
  28571. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  28572. v := m._type
  28573. if v == nil {
  28574. return
  28575. }
  28576. return *v, true
  28577. }
  28578. // OldType returns the old "type" field's value of the UsageTotal entity.
  28579. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28581. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  28582. if !m.op.Is(OpUpdateOne) {
  28583. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28584. }
  28585. if m.id == nil || m.oldValue == nil {
  28586. return v, errors.New("OldType requires an ID field in the mutation")
  28587. }
  28588. oldValue, err := m.oldValue(ctx)
  28589. if err != nil {
  28590. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28591. }
  28592. return oldValue.Type, nil
  28593. }
  28594. // AddType adds i to the "type" field.
  28595. func (m *UsageTotalMutation) AddType(i int) {
  28596. if m.add_type != nil {
  28597. *m.add_type += i
  28598. } else {
  28599. m.add_type = &i
  28600. }
  28601. }
  28602. // AddedType returns the value that was added to the "type" field in this mutation.
  28603. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  28604. v := m.add_type
  28605. if v == nil {
  28606. return
  28607. }
  28608. return *v, true
  28609. }
  28610. // ClearType clears the value of the "type" field.
  28611. func (m *UsageTotalMutation) ClearType() {
  28612. m._type = nil
  28613. m.add_type = nil
  28614. m.clearedFields[usagetotal.FieldType] = struct{}{}
  28615. }
  28616. // TypeCleared returns if the "type" field was cleared in this mutation.
  28617. func (m *UsageTotalMutation) TypeCleared() bool {
  28618. _, ok := m.clearedFields[usagetotal.FieldType]
  28619. return ok
  28620. }
  28621. // ResetType resets all changes to the "type" field.
  28622. func (m *UsageTotalMutation) ResetType() {
  28623. m._type = nil
  28624. m.add_type = nil
  28625. delete(m.clearedFields, usagetotal.FieldType)
  28626. }
  28627. // SetBotID sets the "bot_id" field.
  28628. func (m *UsageTotalMutation) SetBotID(s string) {
  28629. m.bot_id = &s
  28630. }
  28631. // BotID returns the value of the "bot_id" field in the mutation.
  28632. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  28633. v := m.bot_id
  28634. if v == nil {
  28635. return
  28636. }
  28637. return *v, true
  28638. }
  28639. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  28640. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28642. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  28643. if !m.op.Is(OpUpdateOne) {
  28644. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28645. }
  28646. if m.id == nil || m.oldValue == nil {
  28647. return v, errors.New("OldBotID requires an ID field in the mutation")
  28648. }
  28649. oldValue, err := m.oldValue(ctx)
  28650. if err != nil {
  28651. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28652. }
  28653. return oldValue.BotID, nil
  28654. }
  28655. // ResetBotID resets all changes to the "bot_id" field.
  28656. func (m *UsageTotalMutation) ResetBotID() {
  28657. m.bot_id = nil
  28658. }
  28659. // SetTotalTokens sets the "total_tokens" field.
  28660. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  28661. m.total_tokens = &u
  28662. m.addtotal_tokens = nil
  28663. }
  28664. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  28665. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  28666. v := m.total_tokens
  28667. if v == nil {
  28668. return
  28669. }
  28670. return *v, true
  28671. }
  28672. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  28673. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28675. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  28676. if !m.op.Is(OpUpdateOne) {
  28677. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  28678. }
  28679. if m.id == nil || m.oldValue == nil {
  28680. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  28681. }
  28682. oldValue, err := m.oldValue(ctx)
  28683. if err != nil {
  28684. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  28685. }
  28686. return oldValue.TotalTokens, nil
  28687. }
  28688. // AddTotalTokens adds u to the "total_tokens" field.
  28689. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  28690. if m.addtotal_tokens != nil {
  28691. *m.addtotal_tokens += u
  28692. } else {
  28693. m.addtotal_tokens = &u
  28694. }
  28695. }
  28696. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  28697. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  28698. v := m.addtotal_tokens
  28699. if v == nil {
  28700. return
  28701. }
  28702. return *v, true
  28703. }
  28704. // ClearTotalTokens clears the value of the "total_tokens" field.
  28705. func (m *UsageTotalMutation) ClearTotalTokens() {
  28706. m.total_tokens = nil
  28707. m.addtotal_tokens = nil
  28708. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  28709. }
  28710. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  28711. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  28712. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  28713. return ok
  28714. }
  28715. // ResetTotalTokens resets all changes to the "total_tokens" field.
  28716. func (m *UsageTotalMutation) ResetTotalTokens() {
  28717. m.total_tokens = nil
  28718. m.addtotal_tokens = nil
  28719. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  28720. }
  28721. // SetStartIndex sets the "start_index" field.
  28722. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  28723. m.start_index = &u
  28724. m.addstart_index = nil
  28725. }
  28726. // StartIndex returns the value of the "start_index" field in the mutation.
  28727. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  28728. v := m.start_index
  28729. if v == nil {
  28730. return
  28731. }
  28732. return *v, true
  28733. }
  28734. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  28735. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28737. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  28738. if !m.op.Is(OpUpdateOne) {
  28739. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  28740. }
  28741. if m.id == nil || m.oldValue == nil {
  28742. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  28743. }
  28744. oldValue, err := m.oldValue(ctx)
  28745. if err != nil {
  28746. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  28747. }
  28748. return oldValue.StartIndex, nil
  28749. }
  28750. // AddStartIndex adds u to the "start_index" field.
  28751. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  28752. if m.addstart_index != nil {
  28753. *m.addstart_index += u
  28754. } else {
  28755. m.addstart_index = &u
  28756. }
  28757. }
  28758. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  28759. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  28760. v := m.addstart_index
  28761. if v == nil {
  28762. return
  28763. }
  28764. return *v, true
  28765. }
  28766. // ClearStartIndex clears the value of the "start_index" field.
  28767. func (m *UsageTotalMutation) ClearStartIndex() {
  28768. m.start_index = nil
  28769. m.addstart_index = nil
  28770. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  28771. }
  28772. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  28773. func (m *UsageTotalMutation) StartIndexCleared() bool {
  28774. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  28775. return ok
  28776. }
  28777. // ResetStartIndex resets all changes to the "start_index" field.
  28778. func (m *UsageTotalMutation) ResetStartIndex() {
  28779. m.start_index = nil
  28780. m.addstart_index = nil
  28781. delete(m.clearedFields, usagetotal.FieldStartIndex)
  28782. }
  28783. // SetEndIndex sets the "end_index" field.
  28784. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  28785. m.end_index = &u
  28786. m.addend_index = nil
  28787. }
  28788. // EndIndex returns the value of the "end_index" field in the mutation.
  28789. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  28790. v := m.end_index
  28791. if v == nil {
  28792. return
  28793. }
  28794. return *v, true
  28795. }
  28796. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  28797. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28799. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  28800. if !m.op.Is(OpUpdateOne) {
  28801. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  28802. }
  28803. if m.id == nil || m.oldValue == nil {
  28804. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  28805. }
  28806. oldValue, err := m.oldValue(ctx)
  28807. if err != nil {
  28808. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  28809. }
  28810. return oldValue.EndIndex, nil
  28811. }
  28812. // AddEndIndex adds u to the "end_index" field.
  28813. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  28814. if m.addend_index != nil {
  28815. *m.addend_index += u
  28816. } else {
  28817. m.addend_index = &u
  28818. }
  28819. }
  28820. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  28821. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  28822. v := m.addend_index
  28823. if v == nil {
  28824. return
  28825. }
  28826. return *v, true
  28827. }
  28828. // ClearEndIndex clears the value of the "end_index" field.
  28829. func (m *UsageTotalMutation) ClearEndIndex() {
  28830. m.end_index = nil
  28831. m.addend_index = nil
  28832. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  28833. }
  28834. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  28835. func (m *UsageTotalMutation) EndIndexCleared() bool {
  28836. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  28837. return ok
  28838. }
  28839. // ResetEndIndex resets all changes to the "end_index" field.
  28840. func (m *UsageTotalMutation) ResetEndIndex() {
  28841. m.end_index = nil
  28842. m.addend_index = nil
  28843. delete(m.clearedFields, usagetotal.FieldEndIndex)
  28844. }
  28845. // SetOrganizationID sets the "organization_id" field.
  28846. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  28847. m.organization_id = &u
  28848. m.addorganization_id = nil
  28849. }
  28850. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28851. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  28852. v := m.organization_id
  28853. if v == nil {
  28854. return
  28855. }
  28856. return *v, true
  28857. }
  28858. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  28859. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  28860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28861. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28862. if !m.op.Is(OpUpdateOne) {
  28863. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28864. }
  28865. if m.id == nil || m.oldValue == nil {
  28866. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28867. }
  28868. oldValue, err := m.oldValue(ctx)
  28869. if err != nil {
  28870. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28871. }
  28872. return oldValue.OrganizationID, nil
  28873. }
  28874. // AddOrganizationID adds u to the "organization_id" field.
  28875. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  28876. if m.addorganization_id != nil {
  28877. *m.addorganization_id += u
  28878. } else {
  28879. m.addorganization_id = &u
  28880. }
  28881. }
  28882. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28883. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  28884. v := m.addorganization_id
  28885. if v == nil {
  28886. return
  28887. }
  28888. return *v, true
  28889. }
  28890. // ClearOrganizationID clears the value of the "organization_id" field.
  28891. func (m *UsageTotalMutation) ClearOrganizationID() {
  28892. m.organization_id = nil
  28893. m.addorganization_id = nil
  28894. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  28895. }
  28896. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28897. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  28898. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  28899. return ok
  28900. }
  28901. // ResetOrganizationID resets all changes to the "organization_id" field.
  28902. func (m *UsageTotalMutation) ResetOrganizationID() {
  28903. m.organization_id = nil
  28904. m.addorganization_id = nil
  28905. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  28906. }
  28907. // Where appends a list predicates to the UsageTotalMutation builder.
  28908. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  28909. m.predicates = append(m.predicates, ps...)
  28910. }
  28911. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  28912. // users can use type-assertion to append predicates that do not depend on any generated package.
  28913. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  28914. p := make([]predicate.UsageTotal, len(ps))
  28915. for i := range ps {
  28916. p[i] = ps[i]
  28917. }
  28918. m.Where(p...)
  28919. }
  28920. // Op returns the operation name.
  28921. func (m *UsageTotalMutation) Op() Op {
  28922. return m.op
  28923. }
  28924. // SetOp allows setting the mutation operation.
  28925. func (m *UsageTotalMutation) SetOp(op Op) {
  28926. m.op = op
  28927. }
  28928. // Type returns the node type of this mutation (UsageTotal).
  28929. func (m *UsageTotalMutation) Type() string {
  28930. return m.typ
  28931. }
  28932. // Fields returns all fields that were changed during this mutation. Note that in
  28933. // order to get all numeric fields that were incremented/decremented, call
  28934. // AddedFields().
  28935. func (m *UsageTotalMutation) Fields() []string {
  28936. fields := make([]string, 0, 9)
  28937. if m.created_at != nil {
  28938. fields = append(fields, usagetotal.FieldCreatedAt)
  28939. }
  28940. if m.updated_at != nil {
  28941. fields = append(fields, usagetotal.FieldUpdatedAt)
  28942. }
  28943. if m.status != nil {
  28944. fields = append(fields, usagetotal.FieldStatus)
  28945. }
  28946. if m._type != nil {
  28947. fields = append(fields, usagetotal.FieldType)
  28948. }
  28949. if m.bot_id != nil {
  28950. fields = append(fields, usagetotal.FieldBotID)
  28951. }
  28952. if m.total_tokens != nil {
  28953. fields = append(fields, usagetotal.FieldTotalTokens)
  28954. }
  28955. if m.start_index != nil {
  28956. fields = append(fields, usagetotal.FieldStartIndex)
  28957. }
  28958. if m.end_index != nil {
  28959. fields = append(fields, usagetotal.FieldEndIndex)
  28960. }
  28961. if m.organization_id != nil {
  28962. fields = append(fields, usagetotal.FieldOrganizationID)
  28963. }
  28964. return fields
  28965. }
  28966. // Field returns the value of a field with the given name. The second boolean
  28967. // return value indicates that this field was not set, or was not defined in the
  28968. // schema.
  28969. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  28970. switch name {
  28971. case usagetotal.FieldCreatedAt:
  28972. return m.CreatedAt()
  28973. case usagetotal.FieldUpdatedAt:
  28974. return m.UpdatedAt()
  28975. case usagetotal.FieldStatus:
  28976. return m.Status()
  28977. case usagetotal.FieldType:
  28978. return m.GetType()
  28979. case usagetotal.FieldBotID:
  28980. return m.BotID()
  28981. case usagetotal.FieldTotalTokens:
  28982. return m.TotalTokens()
  28983. case usagetotal.FieldStartIndex:
  28984. return m.StartIndex()
  28985. case usagetotal.FieldEndIndex:
  28986. return m.EndIndex()
  28987. case usagetotal.FieldOrganizationID:
  28988. return m.OrganizationID()
  28989. }
  28990. return nil, false
  28991. }
  28992. // OldField returns the old value of the field from the database. An error is
  28993. // returned if the mutation operation is not UpdateOne, or the query to the
  28994. // database failed.
  28995. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28996. switch name {
  28997. case usagetotal.FieldCreatedAt:
  28998. return m.OldCreatedAt(ctx)
  28999. case usagetotal.FieldUpdatedAt:
  29000. return m.OldUpdatedAt(ctx)
  29001. case usagetotal.FieldStatus:
  29002. return m.OldStatus(ctx)
  29003. case usagetotal.FieldType:
  29004. return m.OldType(ctx)
  29005. case usagetotal.FieldBotID:
  29006. return m.OldBotID(ctx)
  29007. case usagetotal.FieldTotalTokens:
  29008. return m.OldTotalTokens(ctx)
  29009. case usagetotal.FieldStartIndex:
  29010. return m.OldStartIndex(ctx)
  29011. case usagetotal.FieldEndIndex:
  29012. return m.OldEndIndex(ctx)
  29013. case usagetotal.FieldOrganizationID:
  29014. return m.OldOrganizationID(ctx)
  29015. }
  29016. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  29017. }
  29018. // SetField sets the value of a field with the given name. It returns an error if
  29019. // the field is not defined in the schema, or if the type mismatched the field
  29020. // type.
  29021. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  29022. switch name {
  29023. case usagetotal.FieldCreatedAt:
  29024. v, ok := value.(time.Time)
  29025. if !ok {
  29026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29027. }
  29028. m.SetCreatedAt(v)
  29029. return nil
  29030. case usagetotal.FieldUpdatedAt:
  29031. v, ok := value.(time.Time)
  29032. if !ok {
  29033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29034. }
  29035. m.SetUpdatedAt(v)
  29036. return nil
  29037. case usagetotal.FieldStatus:
  29038. v, ok := value.(uint8)
  29039. if !ok {
  29040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29041. }
  29042. m.SetStatus(v)
  29043. return nil
  29044. case usagetotal.FieldType:
  29045. v, ok := value.(int)
  29046. if !ok {
  29047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29048. }
  29049. m.SetType(v)
  29050. return nil
  29051. case usagetotal.FieldBotID:
  29052. v, ok := value.(string)
  29053. if !ok {
  29054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29055. }
  29056. m.SetBotID(v)
  29057. return nil
  29058. case usagetotal.FieldTotalTokens:
  29059. v, ok := value.(uint64)
  29060. if !ok {
  29061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29062. }
  29063. m.SetTotalTokens(v)
  29064. return nil
  29065. case usagetotal.FieldStartIndex:
  29066. v, ok := value.(uint64)
  29067. if !ok {
  29068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29069. }
  29070. m.SetStartIndex(v)
  29071. return nil
  29072. case usagetotal.FieldEndIndex:
  29073. v, ok := value.(uint64)
  29074. if !ok {
  29075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29076. }
  29077. m.SetEndIndex(v)
  29078. return nil
  29079. case usagetotal.FieldOrganizationID:
  29080. v, ok := value.(uint64)
  29081. if !ok {
  29082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29083. }
  29084. m.SetOrganizationID(v)
  29085. return nil
  29086. }
  29087. return fmt.Errorf("unknown UsageTotal field %s", name)
  29088. }
  29089. // AddedFields returns all numeric fields that were incremented/decremented during
  29090. // this mutation.
  29091. func (m *UsageTotalMutation) AddedFields() []string {
  29092. var fields []string
  29093. if m.addstatus != nil {
  29094. fields = append(fields, usagetotal.FieldStatus)
  29095. }
  29096. if m.add_type != nil {
  29097. fields = append(fields, usagetotal.FieldType)
  29098. }
  29099. if m.addtotal_tokens != nil {
  29100. fields = append(fields, usagetotal.FieldTotalTokens)
  29101. }
  29102. if m.addstart_index != nil {
  29103. fields = append(fields, usagetotal.FieldStartIndex)
  29104. }
  29105. if m.addend_index != nil {
  29106. fields = append(fields, usagetotal.FieldEndIndex)
  29107. }
  29108. if m.addorganization_id != nil {
  29109. fields = append(fields, usagetotal.FieldOrganizationID)
  29110. }
  29111. return fields
  29112. }
  29113. // AddedField returns the numeric value that was incremented/decremented on a field
  29114. // with the given name. The second boolean return value indicates that this field
  29115. // was not set, or was not defined in the schema.
  29116. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  29117. switch name {
  29118. case usagetotal.FieldStatus:
  29119. return m.AddedStatus()
  29120. case usagetotal.FieldType:
  29121. return m.AddedType()
  29122. case usagetotal.FieldTotalTokens:
  29123. return m.AddedTotalTokens()
  29124. case usagetotal.FieldStartIndex:
  29125. return m.AddedStartIndex()
  29126. case usagetotal.FieldEndIndex:
  29127. return m.AddedEndIndex()
  29128. case usagetotal.FieldOrganizationID:
  29129. return m.AddedOrganizationID()
  29130. }
  29131. return nil, false
  29132. }
  29133. // AddField adds the value to the field with the given name. It returns an error if
  29134. // the field is not defined in the schema, or if the type mismatched the field
  29135. // type.
  29136. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  29137. switch name {
  29138. case usagetotal.FieldStatus:
  29139. v, ok := value.(int8)
  29140. if !ok {
  29141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29142. }
  29143. m.AddStatus(v)
  29144. return nil
  29145. case usagetotal.FieldType:
  29146. v, ok := value.(int)
  29147. if !ok {
  29148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29149. }
  29150. m.AddType(v)
  29151. return nil
  29152. case usagetotal.FieldTotalTokens:
  29153. v, ok := value.(int64)
  29154. if !ok {
  29155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29156. }
  29157. m.AddTotalTokens(v)
  29158. return nil
  29159. case usagetotal.FieldStartIndex:
  29160. v, ok := value.(int64)
  29161. if !ok {
  29162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29163. }
  29164. m.AddStartIndex(v)
  29165. return nil
  29166. case usagetotal.FieldEndIndex:
  29167. v, ok := value.(int64)
  29168. if !ok {
  29169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29170. }
  29171. m.AddEndIndex(v)
  29172. return nil
  29173. case usagetotal.FieldOrganizationID:
  29174. v, ok := value.(int64)
  29175. if !ok {
  29176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29177. }
  29178. m.AddOrganizationID(v)
  29179. return nil
  29180. }
  29181. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  29182. }
  29183. // ClearedFields returns all nullable fields that were cleared during this
  29184. // mutation.
  29185. func (m *UsageTotalMutation) ClearedFields() []string {
  29186. var fields []string
  29187. if m.FieldCleared(usagetotal.FieldStatus) {
  29188. fields = append(fields, usagetotal.FieldStatus)
  29189. }
  29190. if m.FieldCleared(usagetotal.FieldType) {
  29191. fields = append(fields, usagetotal.FieldType)
  29192. }
  29193. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  29194. fields = append(fields, usagetotal.FieldTotalTokens)
  29195. }
  29196. if m.FieldCleared(usagetotal.FieldStartIndex) {
  29197. fields = append(fields, usagetotal.FieldStartIndex)
  29198. }
  29199. if m.FieldCleared(usagetotal.FieldEndIndex) {
  29200. fields = append(fields, usagetotal.FieldEndIndex)
  29201. }
  29202. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  29203. fields = append(fields, usagetotal.FieldOrganizationID)
  29204. }
  29205. return fields
  29206. }
  29207. // FieldCleared returns a boolean indicating if a field with the given name was
  29208. // cleared in this mutation.
  29209. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  29210. _, ok := m.clearedFields[name]
  29211. return ok
  29212. }
  29213. // ClearField clears the value of the field with the given name. It returns an
  29214. // error if the field is not defined in the schema.
  29215. func (m *UsageTotalMutation) ClearField(name string) error {
  29216. switch name {
  29217. case usagetotal.FieldStatus:
  29218. m.ClearStatus()
  29219. return nil
  29220. case usagetotal.FieldType:
  29221. m.ClearType()
  29222. return nil
  29223. case usagetotal.FieldTotalTokens:
  29224. m.ClearTotalTokens()
  29225. return nil
  29226. case usagetotal.FieldStartIndex:
  29227. m.ClearStartIndex()
  29228. return nil
  29229. case usagetotal.FieldEndIndex:
  29230. m.ClearEndIndex()
  29231. return nil
  29232. case usagetotal.FieldOrganizationID:
  29233. m.ClearOrganizationID()
  29234. return nil
  29235. }
  29236. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  29237. }
  29238. // ResetField resets all changes in the mutation for the field with the given name.
  29239. // It returns an error if the field is not defined in the schema.
  29240. func (m *UsageTotalMutation) ResetField(name string) error {
  29241. switch name {
  29242. case usagetotal.FieldCreatedAt:
  29243. m.ResetCreatedAt()
  29244. return nil
  29245. case usagetotal.FieldUpdatedAt:
  29246. m.ResetUpdatedAt()
  29247. return nil
  29248. case usagetotal.FieldStatus:
  29249. m.ResetStatus()
  29250. return nil
  29251. case usagetotal.FieldType:
  29252. m.ResetType()
  29253. return nil
  29254. case usagetotal.FieldBotID:
  29255. m.ResetBotID()
  29256. return nil
  29257. case usagetotal.FieldTotalTokens:
  29258. m.ResetTotalTokens()
  29259. return nil
  29260. case usagetotal.FieldStartIndex:
  29261. m.ResetStartIndex()
  29262. return nil
  29263. case usagetotal.FieldEndIndex:
  29264. m.ResetEndIndex()
  29265. return nil
  29266. case usagetotal.FieldOrganizationID:
  29267. m.ResetOrganizationID()
  29268. return nil
  29269. }
  29270. return fmt.Errorf("unknown UsageTotal field %s", name)
  29271. }
  29272. // AddedEdges returns all edge names that were set/added in this mutation.
  29273. func (m *UsageTotalMutation) AddedEdges() []string {
  29274. edges := make([]string, 0, 0)
  29275. return edges
  29276. }
  29277. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29278. // name in this mutation.
  29279. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  29280. return nil
  29281. }
  29282. // RemovedEdges returns all edge names that were removed in this mutation.
  29283. func (m *UsageTotalMutation) RemovedEdges() []string {
  29284. edges := make([]string, 0, 0)
  29285. return edges
  29286. }
  29287. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29288. // the given name in this mutation.
  29289. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  29290. return nil
  29291. }
  29292. // ClearedEdges returns all edge names that were cleared in this mutation.
  29293. func (m *UsageTotalMutation) ClearedEdges() []string {
  29294. edges := make([]string, 0, 0)
  29295. return edges
  29296. }
  29297. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29298. // was cleared in this mutation.
  29299. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  29300. return false
  29301. }
  29302. // ClearEdge clears the value of the edge with the given name. It returns an error
  29303. // if that edge is not defined in the schema.
  29304. func (m *UsageTotalMutation) ClearEdge(name string) error {
  29305. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  29306. }
  29307. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29308. // It returns an error if the edge is not defined in the schema.
  29309. func (m *UsageTotalMutation) ResetEdge(name string) error {
  29310. return fmt.Errorf("unknown UsageTotal edge %s", name)
  29311. }
  29312. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  29313. type WorkExperienceMutation struct {
  29314. config
  29315. op Op
  29316. typ string
  29317. id *uint64
  29318. created_at *time.Time
  29319. updated_at *time.Time
  29320. deleted_at *time.Time
  29321. start_date *time.Time
  29322. end_date *time.Time
  29323. company *string
  29324. experience *string
  29325. organization_id *uint64
  29326. addorganization_id *int64
  29327. clearedFields map[string]struct{}
  29328. employee *uint64
  29329. clearedemployee bool
  29330. done bool
  29331. oldValue func(context.Context) (*WorkExperience, error)
  29332. predicates []predicate.WorkExperience
  29333. }
  29334. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  29335. // workexperienceOption allows management of the mutation configuration using functional options.
  29336. type workexperienceOption func(*WorkExperienceMutation)
  29337. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  29338. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  29339. m := &WorkExperienceMutation{
  29340. config: c,
  29341. op: op,
  29342. typ: TypeWorkExperience,
  29343. clearedFields: make(map[string]struct{}),
  29344. }
  29345. for _, opt := range opts {
  29346. opt(m)
  29347. }
  29348. return m
  29349. }
  29350. // withWorkExperienceID sets the ID field of the mutation.
  29351. func withWorkExperienceID(id uint64) workexperienceOption {
  29352. return func(m *WorkExperienceMutation) {
  29353. var (
  29354. err error
  29355. once sync.Once
  29356. value *WorkExperience
  29357. )
  29358. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  29359. once.Do(func() {
  29360. if m.done {
  29361. err = errors.New("querying old values post mutation is not allowed")
  29362. } else {
  29363. value, err = m.Client().WorkExperience.Get(ctx, id)
  29364. }
  29365. })
  29366. return value, err
  29367. }
  29368. m.id = &id
  29369. }
  29370. }
  29371. // withWorkExperience sets the old WorkExperience of the mutation.
  29372. func withWorkExperience(node *WorkExperience) workexperienceOption {
  29373. return func(m *WorkExperienceMutation) {
  29374. m.oldValue = func(context.Context) (*WorkExperience, error) {
  29375. return node, nil
  29376. }
  29377. m.id = &node.ID
  29378. }
  29379. }
  29380. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29381. // executed in a transaction (ent.Tx), a transactional client is returned.
  29382. func (m WorkExperienceMutation) Client() *Client {
  29383. client := &Client{config: m.config}
  29384. client.init()
  29385. return client
  29386. }
  29387. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29388. // it returns an error otherwise.
  29389. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  29390. if _, ok := m.driver.(*txDriver); !ok {
  29391. return nil, errors.New("ent: mutation is not running in a transaction")
  29392. }
  29393. tx := &Tx{config: m.config}
  29394. tx.init()
  29395. return tx, nil
  29396. }
  29397. // SetID sets the value of the id field. Note that this
  29398. // operation is only accepted on creation of WorkExperience entities.
  29399. func (m *WorkExperienceMutation) SetID(id uint64) {
  29400. m.id = &id
  29401. }
  29402. // ID returns the ID value in the mutation. Note that the ID is only available
  29403. // if it was provided to the builder or after it was returned from the database.
  29404. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  29405. if m.id == nil {
  29406. return
  29407. }
  29408. return *m.id, true
  29409. }
  29410. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29411. // That means, if the mutation is applied within a transaction with an isolation level such
  29412. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29413. // or updated by the mutation.
  29414. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  29415. switch {
  29416. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29417. id, exists := m.ID()
  29418. if exists {
  29419. return []uint64{id}, nil
  29420. }
  29421. fallthrough
  29422. case m.op.Is(OpUpdate | OpDelete):
  29423. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  29424. default:
  29425. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29426. }
  29427. }
  29428. // SetCreatedAt sets the "created_at" field.
  29429. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  29430. m.created_at = &t
  29431. }
  29432. // CreatedAt returns the value of the "created_at" field in the mutation.
  29433. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  29434. v := m.created_at
  29435. if v == nil {
  29436. return
  29437. }
  29438. return *v, true
  29439. }
  29440. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  29441. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29443. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29444. if !m.op.Is(OpUpdateOne) {
  29445. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29446. }
  29447. if m.id == nil || m.oldValue == nil {
  29448. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29449. }
  29450. oldValue, err := m.oldValue(ctx)
  29451. if err != nil {
  29452. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29453. }
  29454. return oldValue.CreatedAt, nil
  29455. }
  29456. // ResetCreatedAt resets all changes to the "created_at" field.
  29457. func (m *WorkExperienceMutation) ResetCreatedAt() {
  29458. m.created_at = nil
  29459. }
  29460. // SetUpdatedAt sets the "updated_at" field.
  29461. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  29462. m.updated_at = &t
  29463. }
  29464. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29465. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  29466. v := m.updated_at
  29467. if v == nil {
  29468. return
  29469. }
  29470. return *v, true
  29471. }
  29472. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  29473. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29475. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29476. if !m.op.Is(OpUpdateOne) {
  29477. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29478. }
  29479. if m.id == nil || m.oldValue == nil {
  29480. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29481. }
  29482. oldValue, err := m.oldValue(ctx)
  29483. if err != nil {
  29484. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29485. }
  29486. return oldValue.UpdatedAt, nil
  29487. }
  29488. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29489. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  29490. m.updated_at = nil
  29491. }
  29492. // SetDeletedAt sets the "deleted_at" field.
  29493. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  29494. m.deleted_at = &t
  29495. }
  29496. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29497. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  29498. v := m.deleted_at
  29499. if v == nil {
  29500. return
  29501. }
  29502. return *v, true
  29503. }
  29504. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  29505. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29507. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29508. if !m.op.Is(OpUpdateOne) {
  29509. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29510. }
  29511. if m.id == nil || m.oldValue == nil {
  29512. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29513. }
  29514. oldValue, err := m.oldValue(ctx)
  29515. if err != nil {
  29516. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29517. }
  29518. return oldValue.DeletedAt, nil
  29519. }
  29520. // ClearDeletedAt clears the value of the "deleted_at" field.
  29521. func (m *WorkExperienceMutation) ClearDeletedAt() {
  29522. m.deleted_at = nil
  29523. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  29524. }
  29525. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29526. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  29527. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  29528. return ok
  29529. }
  29530. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29531. func (m *WorkExperienceMutation) ResetDeletedAt() {
  29532. m.deleted_at = nil
  29533. delete(m.clearedFields, workexperience.FieldDeletedAt)
  29534. }
  29535. // SetEmployeeID sets the "employee_id" field.
  29536. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  29537. m.employee = &u
  29538. }
  29539. // EmployeeID returns the value of the "employee_id" field in the mutation.
  29540. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  29541. v := m.employee
  29542. if v == nil {
  29543. return
  29544. }
  29545. return *v, true
  29546. }
  29547. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  29548. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29550. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  29551. if !m.op.Is(OpUpdateOne) {
  29552. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  29553. }
  29554. if m.id == nil || m.oldValue == nil {
  29555. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  29556. }
  29557. oldValue, err := m.oldValue(ctx)
  29558. if err != nil {
  29559. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  29560. }
  29561. return oldValue.EmployeeID, nil
  29562. }
  29563. // ResetEmployeeID resets all changes to the "employee_id" field.
  29564. func (m *WorkExperienceMutation) ResetEmployeeID() {
  29565. m.employee = nil
  29566. }
  29567. // SetStartDate sets the "start_date" field.
  29568. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  29569. m.start_date = &t
  29570. }
  29571. // StartDate returns the value of the "start_date" field in the mutation.
  29572. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  29573. v := m.start_date
  29574. if v == nil {
  29575. return
  29576. }
  29577. return *v, true
  29578. }
  29579. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  29580. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29582. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  29583. if !m.op.Is(OpUpdateOne) {
  29584. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  29585. }
  29586. if m.id == nil || m.oldValue == nil {
  29587. return v, errors.New("OldStartDate requires an ID field in the mutation")
  29588. }
  29589. oldValue, err := m.oldValue(ctx)
  29590. if err != nil {
  29591. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  29592. }
  29593. return oldValue.StartDate, nil
  29594. }
  29595. // ResetStartDate resets all changes to the "start_date" field.
  29596. func (m *WorkExperienceMutation) ResetStartDate() {
  29597. m.start_date = nil
  29598. }
  29599. // SetEndDate sets the "end_date" field.
  29600. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  29601. m.end_date = &t
  29602. }
  29603. // EndDate returns the value of the "end_date" field in the mutation.
  29604. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  29605. v := m.end_date
  29606. if v == nil {
  29607. return
  29608. }
  29609. return *v, true
  29610. }
  29611. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  29612. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29614. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  29615. if !m.op.Is(OpUpdateOne) {
  29616. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  29617. }
  29618. if m.id == nil || m.oldValue == nil {
  29619. return v, errors.New("OldEndDate requires an ID field in the mutation")
  29620. }
  29621. oldValue, err := m.oldValue(ctx)
  29622. if err != nil {
  29623. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  29624. }
  29625. return oldValue.EndDate, nil
  29626. }
  29627. // ResetEndDate resets all changes to the "end_date" field.
  29628. func (m *WorkExperienceMutation) ResetEndDate() {
  29629. m.end_date = nil
  29630. }
  29631. // SetCompany sets the "company" field.
  29632. func (m *WorkExperienceMutation) SetCompany(s string) {
  29633. m.company = &s
  29634. }
  29635. // Company returns the value of the "company" field in the mutation.
  29636. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  29637. v := m.company
  29638. if v == nil {
  29639. return
  29640. }
  29641. return *v, true
  29642. }
  29643. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  29644. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29646. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  29647. if !m.op.Is(OpUpdateOne) {
  29648. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  29649. }
  29650. if m.id == nil || m.oldValue == nil {
  29651. return v, errors.New("OldCompany requires an ID field in the mutation")
  29652. }
  29653. oldValue, err := m.oldValue(ctx)
  29654. if err != nil {
  29655. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  29656. }
  29657. return oldValue.Company, nil
  29658. }
  29659. // ResetCompany resets all changes to the "company" field.
  29660. func (m *WorkExperienceMutation) ResetCompany() {
  29661. m.company = nil
  29662. }
  29663. // SetExperience sets the "experience" field.
  29664. func (m *WorkExperienceMutation) SetExperience(s string) {
  29665. m.experience = &s
  29666. }
  29667. // Experience returns the value of the "experience" field in the mutation.
  29668. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  29669. v := m.experience
  29670. if v == nil {
  29671. return
  29672. }
  29673. return *v, true
  29674. }
  29675. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  29676. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29678. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  29679. if !m.op.Is(OpUpdateOne) {
  29680. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  29681. }
  29682. if m.id == nil || m.oldValue == nil {
  29683. return v, errors.New("OldExperience requires an ID field in the mutation")
  29684. }
  29685. oldValue, err := m.oldValue(ctx)
  29686. if err != nil {
  29687. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  29688. }
  29689. return oldValue.Experience, nil
  29690. }
  29691. // ResetExperience resets all changes to the "experience" field.
  29692. func (m *WorkExperienceMutation) ResetExperience() {
  29693. m.experience = nil
  29694. }
  29695. // SetOrganizationID sets the "organization_id" field.
  29696. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  29697. m.organization_id = &u
  29698. m.addorganization_id = nil
  29699. }
  29700. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29701. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  29702. v := m.organization_id
  29703. if v == nil {
  29704. return
  29705. }
  29706. return *v, true
  29707. }
  29708. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  29709. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  29710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29711. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29712. if !m.op.Is(OpUpdateOne) {
  29713. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29714. }
  29715. if m.id == nil || m.oldValue == nil {
  29716. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29717. }
  29718. oldValue, err := m.oldValue(ctx)
  29719. if err != nil {
  29720. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29721. }
  29722. return oldValue.OrganizationID, nil
  29723. }
  29724. // AddOrganizationID adds u to the "organization_id" field.
  29725. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  29726. if m.addorganization_id != nil {
  29727. *m.addorganization_id += u
  29728. } else {
  29729. m.addorganization_id = &u
  29730. }
  29731. }
  29732. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29733. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  29734. v := m.addorganization_id
  29735. if v == nil {
  29736. return
  29737. }
  29738. return *v, true
  29739. }
  29740. // ResetOrganizationID resets all changes to the "organization_id" field.
  29741. func (m *WorkExperienceMutation) ResetOrganizationID() {
  29742. m.organization_id = nil
  29743. m.addorganization_id = nil
  29744. }
  29745. // ClearEmployee clears the "employee" edge to the Employee entity.
  29746. func (m *WorkExperienceMutation) ClearEmployee() {
  29747. m.clearedemployee = true
  29748. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  29749. }
  29750. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  29751. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  29752. return m.clearedemployee
  29753. }
  29754. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  29755. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29756. // EmployeeID instead. It exists only for internal usage by the builders.
  29757. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  29758. if id := m.employee; id != nil {
  29759. ids = append(ids, *id)
  29760. }
  29761. return
  29762. }
  29763. // ResetEmployee resets all changes to the "employee" edge.
  29764. func (m *WorkExperienceMutation) ResetEmployee() {
  29765. m.employee = nil
  29766. m.clearedemployee = false
  29767. }
  29768. // Where appends a list predicates to the WorkExperienceMutation builder.
  29769. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  29770. m.predicates = append(m.predicates, ps...)
  29771. }
  29772. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  29773. // users can use type-assertion to append predicates that do not depend on any generated package.
  29774. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  29775. p := make([]predicate.WorkExperience, len(ps))
  29776. for i := range ps {
  29777. p[i] = ps[i]
  29778. }
  29779. m.Where(p...)
  29780. }
  29781. // Op returns the operation name.
  29782. func (m *WorkExperienceMutation) Op() Op {
  29783. return m.op
  29784. }
  29785. // SetOp allows setting the mutation operation.
  29786. func (m *WorkExperienceMutation) SetOp(op Op) {
  29787. m.op = op
  29788. }
  29789. // Type returns the node type of this mutation (WorkExperience).
  29790. func (m *WorkExperienceMutation) Type() string {
  29791. return m.typ
  29792. }
  29793. // Fields returns all fields that were changed during this mutation. Note that in
  29794. // order to get all numeric fields that were incremented/decremented, call
  29795. // AddedFields().
  29796. func (m *WorkExperienceMutation) Fields() []string {
  29797. fields := make([]string, 0, 9)
  29798. if m.created_at != nil {
  29799. fields = append(fields, workexperience.FieldCreatedAt)
  29800. }
  29801. if m.updated_at != nil {
  29802. fields = append(fields, workexperience.FieldUpdatedAt)
  29803. }
  29804. if m.deleted_at != nil {
  29805. fields = append(fields, workexperience.FieldDeletedAt)
  29806. }
  29807. if m.employee != nil {
  29808. fields = append(fields, workexperience.FieldEmployeeID)
  29809. }
  29810. if m.start_date != nil {
  29811. fields = append(fields, workexperience.FieldStartDate)
  29812. }
  29813. if m.end_date != nil {
  29814. fields = append(fields, workexperience.FieldEndDate)
  29815. }
  29816. if m.company != nil {
  29817. fields = append(fields, workexperience.FieldCompany)
  29818. }
  29819. if m.experience != nil {
  29820. fields = append(fields, workexperience.FieldExperience)
  29821. }
  29822. if m.organization_id != nil {
  29823. fields = append(fields, workexperience.FieldOrganizationID)
  29824. }
  29825. return fields
  29826. }
  29827. // Field returns the value of a field with the given name. The second boolean
  29828. // return value indicates that this field was not set, or was not defined in the
  29829. // schema.
  29830. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  29831. switch name {
  29832. case workexperience.FieldCreatedAt:
  29833. return m.CreatedAt()
  29834. case workexperience.FieldUpdatedAt:
  29835. return m.UpdatedAt()
  29836. case workexperience.FieldDeletedAt:
  29837. return m.DeletedAt()
  29838. case workexperience.FieldEmployeeID:
  29839. return m.EmployeeID()
  29840. case workexperience.FieldStartDate:
  29841. return m.StartDate()
  29842. case workexperience.FieldEndDate:
  29843. return m.EndDate()
  29844. case workexperience.FieldCompany:
  29845. return m.Company()
  29846. case workexperience.FieldExperience:
  29847. return m.Experience()
  29848. case workexperience.FieldOrganizationID:
  29849. return m.OrganizationID()
  29850. }
  29851. return nil, false
  29852. }
  29853. // OldField returns the old value of the field from the database. An error is
  29854. // returned if the mutation operation is not UpdateOne, or the query to the
  29855. // database failed.
  29856. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29857. switch name {
  29858. case workexperience.FieldCreatedAt:
  29859. return m.OldCreatedAt(ctx)
  29860. case workexperience.FieldUpdatedAt:
  29861. return m.OldUpdatedAt(ctx)
  29862. case workexperience.FieldDeletedAt:
  29863. return m.OldDeletedAt(ctx)
  29864. case workexperience.FieldEmployeeID:
  29865. return m.OldEmployeeID(ctx)
  29866. case workexperience.FieldStartDate:
  29867. return m.OldStartDate(ctx)
  29868. case workexperience.FieldEndDate:
  29869. return m.OldEndDate(ctx)
  29870. case workexperience.FieldCompany:
  29871. return m.OldCompany(ctx)
  29872. case workexperience.FieldExperience:
  29873. return m.OldExperience(ctx)
  29874. case workexperience.FieldOrganizationID:
  29875. return m.OldOrganizationID(ctx)
  29876. }
  29877. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  29878. }
  29879. // SetField sets the value of a field with the given name. It returns an error if
  29880. // the field is not defined in the schema, or if the type mismatched the field
  29881. // type.
  29882. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  29883. switch name {
  29884. case workexperience.FieldCreatedAt:
  29885. v, ok := value.(time.Time)
  29886. if !ok {
  29887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29888. }
  29889. m.SetCreatedAt(v)
  29890. return nil
  29891. case workexperience.FieldUpdatedAt:
  29892. v, ok := value.(time.Time)
  29893. if !ok {
  29894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29895. }
  29896. m.SetUpdatedAt(v)
  29897. return nil
  29898. case workexperience.FieldDeletedAt:
  29899. v, ok := value.(time.Time)
  29900. if !ok {
  29901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29902. }
  29903. m.SetDeletedAt(v)
  29904. return nil
  29905. case workexperience.FieldEmployeeID:
  29906. v, ok := value.(uint64)
  29907. if !ok {
  29908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29909. }
  29910. m.SetEmployeeID(v)
  29911. return nil
  29912. case workexperience.FieldStartDate:
  29913. v, ok := value.(time.Time)
  29914. if !ok {
  29915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29916. }
  29917. m.SetStartDate(v)
  29918. return nil
  29919. case workexperience.FieldEndDate:
  29920. v, ok := value.(time.Time)
  29921. if !ok {
  29922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29923. }
  29924. m.SetEndDate(v)
  29925. return nil
  29926. case workexperience.FieldCompany:
  29927. v, ok := value.(string)
  29928. if !ok {
  29929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29930. }
  29931. m.SetCompany(v)
  29932. return nil
  29933. case workexperience.FieldExperience:
  29934. v, ok := value.(string)
  29935. if !ok {
  29936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29937. }
  29938. m.SetExperience(v)
  29939. return nil
  29940. case workexperience.FieldOrganizationID:
  29941. v, ok := value.(uint64)
  29942. if !ok {
  29943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29944. }
  29945. m.SetOrganizationID(v)
  29946. return nil
  29947. }
  29948. return fmt.Errorf("unknown WorkExperience field %s", name)
  29949. }
  29950. // AddedFields returns all numeric fields that were incremented/decremented during
  29951. // this mutation.
  29952. func (m *WorkExperienceMutation) AddedFields() []string {
  29953. var fields []string
  29954. if m.addorganization_id != nil {
  29955. fields = append(fields, workexperience.FieldOrganizationID)
  29956. }
  29957. return fields
  29958. }
  29959. // AddedField returns the numeric value that was incremented/decremented on a field
  29960. // with the given name. The second boolean return value indicates that this field
  29961. // was not set, or was not defined in the schema.
  29962. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  29963. switch name {
  29964. case workexperience.FieldOrganizationID:
  29965. return m.AddedOrganizationID()
  29966. }
  29967. return nil, false
  29968. }
  29969. // AddField adds the value to the field with the given name. It returns an error if
  29970. // the field is not defined in the schema, or if the type mismatched the field
  29971. // type.
  29972. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  29973. switch name {
  29974. case workexperience.FieldOrganizationID:
  29975. v, ok := value.(int64)
  29976. if !ok {
  29977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29978. }
  29979. m.AddOrganizationID(v)
  29980. return nil
  29981. }
  29982. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  29983. }
  29984. // ClearedFields returns all nullable fields that were cleared during this
  29985. // mutation.
  29986. func (m *WorkExperienceMutation) ClearedFields() []string {
  29987. var fields []string
  29988. if m.FieldCleared(workexperience.FieldDeletedAt) {
  29989. fields = append(fields, workexperience.FieldDeletedAt)
  29990. }
  29991. return fields
  29992. }
  29993. // FieldCleared returns a boolean indicating if a field with the given name was
  29994. // cleared in this mutation.
  29995. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  29996. _, ok := m.clearedFields[name]
  29997. return ok
  29998. }
  29999. // ClearField clears the value of the field with the given name. It returns an
  30000. // error if the field is not defined in the schema.
  30001. func (m *WorkExperienceMutation) ClearField(name string) error {
  30002. switch name {
  30003. case workexperience.FieldDeletedAt:
  30004. m.ClearDeletedAt()
  30005. return nil
  30006. }
  30007. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  30008. }
  30009. // ResetField resets all changes in the mutation for the field with the given name.
  30010. // It returns an error if the field is not defined in the schema.
  30011. func (m *WorkExperienceMutation) ResetField(name string) error {
  30012. switch name {
  30013. case workexperience.FieldCreatedAt:
  30014. m.ResetCreatedAt()
  30015. return nil
  30016. case workexperience.FieldUpdatedAt:
  30017. m.ResetUpdatedAt()
  30018. return nil
  30019. case workexperience.FieldDeletedAt:
  30020. m.ResetDeletedAt()
  30021. return nil
  30022. case workexperience.FieldEmployeeID:
  30023. m.ResetEmployeeID()
  30024. return nil
  30025. case workexperience.FieldStartDate:
  30026. m.ResetStartDate()
  30027. return nil
  30028. case workexperience.FieldEndDate:
  30029. m.ResetEndDate()
  30030. return nil
  30031. case workexperience.FieldCompany:
  30032. m.ResetCompany()
  30033. return nil
  30034. case workexperience.FieldExperience:
  30035. m.ResetExperience()
  30036. return nil
  30037. case workexperience.FieldOrganizationID:
  30038. m.ResetOrganizationID()
  30039. return nil
  30040. }
  30041. return fmt.Errorf("unknown WorkExperience field %s", name)
  30042. }
  30043. // AddedEdges returns all edge names that were set/added in this mutation.
  30044. func (m *WorkExperienceMutation) AddedEdges() []string {
  30045. edges := make([]string, 0, 1)
  30046. if m.employee != nil {
  30047. edges = append(edges, workexperience.EdgeEmployee)
  30048. }
  30049. return edges
  30050. }
  30051. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30052. // name in this mutation.
  30053. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  30054. switch name {
  30055. case workexperience.EdgeEmployee:
  30056. if id := m.employee; id != nil {
  30057. return []ent.Value{*id}
  30058. }
  30059. }
  30060. return nil
  30061. }
  30062. // RemovedEdges returns all edge names that were removed in this mutation.
  30063. func (m *WorkExperienceMutation) RemovedEdges() []string {
  30064. edges := make([]string, 0, 1)
  30065. return edges
  30066. }
  30067. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30068. // the given name in this mutation.
  30069. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  30070. return nil
  30071. }
  30072. // ClearedEdges returns all edge names that were cleared in this mutation.
  30073. func (m *WorkExperienceMutation) ClearedEdges() []string {
  30074. edges := make([]string, 0, 1)
  30075. if m.clearedemployee {
  30076. edges = append(edges, workexperience.EdgeEmployee)
  30077. }
  30078. return edges
  30079. }
  30080. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30081. // was cleared in this mutation.
  30082. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  30083. switch name {
  30084. case workexperience.EdgeEmployee:
  30085. return m.clearedemployee
  30086. }
  30087. return false
  30088. }
  30089. // ClearEdge clears the value of the edge with the given name. It returns an error
  30090. // if that edge is not defined in the schema.
  30091. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  30092. switch name {
  30093. case workexperience.EdgeEmployee:
  30094. m.ClearEmployee()
  30095. return nil
  30096. }
  30097. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  30098. }
  30099. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30100. // It returns an error if the edge is not defined in the schema.
  30101. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  30102. switch name {
  30103. case workexperience.EdgeEmployee:
  30104. m.ResetEmployee()
  30105. return nil
  30106. }
  30107. return fmt.Errorf("unknown WorkExperience edge %s", name)
  30108. }
  30109. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  30110. type WpChatroomMutation struct {
  30111. config
  30112. op Op
  30113. typ string
  30114. id *uint64
  30115. created_at *time.Time
  30116. updated_at *time.Time
  30117. status *uint8
  30118. addstatus *int8
  30119. wx_wxid *string
  30120. chatroom_id *string
  30121. nickname *string
  30122. owner *string
  30123. avatar *string
  30124. member_list *[]string
  30125. appendmember_list []string
  30126. clearedFields map[string]struct{}
  30127. done bool
  30128. oldValue func(context.Context) (*WpChatroom, error)
  30129. predicates []predicate.WpChatroom
  30130. }
  30131. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  30132. // wpchatroomOption allows management of the mutation configuration using functional options.
  30133. type wpchatroomOption func(*WpChatroomMutation)
  30134. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  30135. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  30136. m := &WpChatroomMutation{
  30137. config: c,
  30138. op: op,
  30139. typ: TypeWpChatroom,
  30140. clearedFields: make(map[string]struct{}),
  30141. }
  30142. for _, opt := range opts {
  30143. opt(m)
  30144. }
  30145. return m
  30146. }
  30147. // withWpChatroomID sets the ID field of the mutation.
  30148. func withWpChatroomID(id uint64) wpchatroomOption {
  30149. return func(m *WpChatroomMutation) {
  30150. var (
  30151. err error
  30152. once sync.Once
  30153. value *WpChatroom
  30154. )
  30155. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  30156. once.Do(func() {
  30157. if m.done {
  30158. err = errors.New("querying old values post mutation is not allowed")
  30159. } else {
  30160. value, err = m.Client().WpChatroom.Get(ctx, id)
  30161. }
  30162. })
  30163. return value, err
  30164. }
  30165. m.id = &id
  30166. }
  30167. }
  30168. // withWpChatroom sets the old WpChatroom of the mutation.
  30169. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  30170. return func(m *WpChatroomMutation) {
  30171. m.oldValue = func(context.Context) (*WpChatroom, error) {
  30172. return node, nil
  30173. }
  30174. m.id = &node.ID
  30175. }
  30176. }
  30177. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30178. // executed in a transaction (ent.Tx), a transactional client is returned.
  30179. func (m WpChatroomMutation) Client() *Client {
  30180. client := &Client{config: m.config}
  30181. client.init()
  30182. return client
  30183. }
  30184. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30185. // it returns an error otherwise.
  30186. func (m WpChatroomMutation) Tx() (*Tx, error) {
  30187. if _, ok := m.driver.(*txDriver); !ok {
  30188. return nil, errors.New("ent: mutation is not running in a transaction")
  30189. }
  30190. tx := &Tx{config: m.config}
  30191. tx.init()
  30192. return tx, nil
  30193. }
  30194. // SetID sets the value of the id field. Note that this
  30195. // operation is only accepted on creation of WpChatroom entities.
  30196. func (m *WpChatroomMutation) SetID(id uint64) {
  30197. m.id = &id
  30198. }
  30199. // ID returns the ID value in the mutation. Note that the ID is only available
  30200. // if it was provided to the builder or after it was returned from the database.
  30201. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  30202. if m.id == nil {
  30203. return
  30204. }
  30205. return *m.id, true
  30206. }
  30207. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30208. // That means, if the mutation is applied within a transaction with an isolation level such
  30209. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30210. // or updated by the mutation.
  30211. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  30212. switch {
  30213. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30214. id, exists := m.ID()
  30215. if exists {
  30216. return []uint64{id}, nil
  30217. }
  30218. fallthrough
  30219. case m.op.Is(OpUpdate | OpDelete):
  30220. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  30221. default:
  30222. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30223. }
  30224. }
  30225. // SetCreatedAt sets the "created_at" field.
  30226. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  30227. m.created_at = &t
  30228. }
  30229. // CreatedAt returns the value of the "created_at" field in the mutation.
  30230. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  30231. v := m.created_at
  30232. if v == nil {
  30233. return
  30234. }
  30235. return *v, true
  30236. }
  30237. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  30238. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30240. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30241. if !m.op.Is(OpUpdateOne) {
  30242. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30243. }
  30244. if m.id == nil || m.oldValue == nil {
  30245. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30246. }
  30247. oldValue, err := m.oldValue(ctx)
  30248. if err != nil {
  30249. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30250. }
  30251. return oldValue.CreatedAt, nil
  30252. }
  30253. // ResetCreatedAt resets all changes to the "created_at" field.
  30254. func (m *WpChatroomMutation) ResetCreatedAt() {
  30255. m.created_at = nil
  30256. }
  30257. // SetUpdatedAt sets the "updated_at" field.
  30258. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  30259. m.updated_at = &t
  30260. }
  30261. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30262. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  30263. v := m.updated_at
  30264. if v == nil {
  30265. return
  30266. }
  30267. return *v, true
  30268. }
  30269. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  30270. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30272. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30273. if !m.op.Is(OpUpdateOne) {
  30274. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30275. }
  30276. if m.id == nil || m.oldValue == nil {
  30277. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30278. }
  30279. oldValue, err := m.oldValue(ctx)
  30280. if err != nil {
  30281. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30282. }
  30283. return oldValue.UpdatedAt, nil
  30284. }
  30285. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30286. func (m *WpChatroomMutation) ResetUpdatedAt() {
  30287. m.updated_at = nil
  30288. }
  30289. // SetStatus sets the "status" field.
  30290. func (m *WpChatroomMutation) SetStatus(u uint8) {
  30291. m.status = &u
  30292. m.addstatus = nil
  30293. }
  30294. // Status returns the value of the "status" field in the mutation.
  30295. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  30296. v := m.status
  30297. if v == nil {
  30298. return
  30299. }
  30300. return *v, true
  30301. }
  30302. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  30303. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30305. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30306. if !m.op.Is(OpUpdateOne) {
  30307. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30308. }
  30309. if m.id == nil || m.oldValue == nil {
  30310. return v, errors.New("OldStatus requires an ID field in the mutation")
  30311. }
  30312. oldValue, err := m.oldValue(ctx)
  30313. if err != nil {
  30314. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30315. }
  30316. return oldValue.Status, nil
  30317. }
  30318. // AddStatus adds u to the "status" field.
  30319. func (m *WpChatroomMutation) AddStatus(u int8) {
  30320. if m.addstatus != nil {
  30321. *m.addstatus += u
  30322. } else {
  30323. m.addstatus = &u
  30324. }
  30325. }
  30326. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30327. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  30328. v := m.addstatus
  30329. if v == nil {
  30330. return
  30331. }
  30332. return *v, true
  30333. }
  30334. // ClearStatus clears the value of the "status" field.
  30335. func (m *WpChatroomMutation) ClearStatus() {
  30336. m.status = nil
  30337. m.addstatus = nil
  30338. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  30339. }
  30340. // StatusCleared returns if the "status" field was cleared in this mutation.
  30341. func (m *WpChatroomMutation) StatusCleared() bool {
  30342. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  30343. return ok
  30344. }
  30345. // ResetStatus resets all changes to the "status" field.
  30346. func (m *WpChatroomMutation) ResetStatus() {
  30347. m.status = nil
  30348. m.addstatus = nil
  30349. delete(m.clearedFields, wpchatroom.FieldStatus)
  30350. }
  30351. // SetWxWxid sets the "wx_wxid" field.
  30352. func (m *WpChatroomMutation) SetWxWxid(s string) {
  30353. m.wx_wxid = &s
  30354. }
  30355. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  30356. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  30357. v := m.wx_wxid
  30358. if v == nil {
  30359. return
  30360. }
  30361. return *v, true
  30362. }
  30363. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  30364. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30366. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  30367. if !m.op.Is(OpUpdateOne) {
  30368. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  30369. }
  30370. if m.id == nil || m.oldValue == nil {
  30371. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  30372. }
  30373. oldValue, err := m.oldValue(ctx)
  30374. if err != nil {
  30375. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  30376. }
  30377. return oldValue.WxWxid, nil
  30378. }
  30379. // ResetWxWxid resets all changes to the "wx_wxid" field.
  30380. func (m *WpChatroomMutation) ResetWxWxid() {
  30381. m.wx_wxid = nil
  30382. }
  30383. // SetChatroomID sets the "chatroom_id" field.
  30384. func (m *WpChatroomMutation) SetChatroomID(s string) {
  30385. m.chatroom_id = &s
  30386. }
  30387. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  30388. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  30389. v := m.chatroom_id
  30390. if v == nil {
  30391. return
  30392. }
  30393. return *v, true
  30394. }
  30395. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  30396. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30398. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  30399. if !m.op.Is(OpUpdateOne) {
  30400. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  30401. }
  30402. if m.id == nil || m.oldValue == nil {
  30403. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  30404. }
  30405. oldValue, err := m.oldValue(ctx)
  30406. if err != nil {
  30407. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  30408. }
  30409. return oldValue.ChatroomID, nil
  30410. }
  30411. // ResetChatroomID resets all changes to the "chatroom_id" field.
  30412. func (m *WpChatroomMutation) ResetChatroomID() {
  30413. m.chatroom_id = nil
  30414. }
  30415. // SetNickname sets the "nickname" field.
  30416. func (m *WpChatroomMutation) SetNickname(s string) {
  30417. m.nickname = &s
  30418. }
  30419. // Nickname returns the value of the "nickname" field in the mutation.
  30420. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  30421. v := m.nickname
  30422. if v == nil {
  30423. return
  30424. }
  30425. return *v, true
  30426. }
  30427. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  30428. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30430. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  30431. if !m.op.Is(OpUpdateOne) {
  30432. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  30433. }
  30434. if m.id == nil || m.oldValue == nil {
  30435. return v, errors.New("OldNickname requires an ID field in the mutation")
  30436. }
  30437. oldValue, err := m.oldValue(ctx)
  30438. if err != nil {
  30439. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  30440. }
  30441. return oldValue.Nickname, nil
  30442. }
  30443. // ResetNickname resets all changes to the "nickname" field.
  30444. func (m *WpChatroomMutation) ResetNickname() {
  30445. m.nickname = nil
  30446. }
  30447. // SetOwner sets the "owner" field.
  30448. func (m *WpChatroomMutation) SetOwner(s string) {
  30449. m.owner = &s
  30450. }
  30451. // Owner returns the value of the "owner" field in the mutation.
  30452. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  30453. v := m.owner
  30454. if v == nil {
  30455. return
  30456. }
  30457. return *v, true
  30458. }
  30459. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  30460. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30462. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  30463. if !m.op.Is(OpUpdateOne) {
  30464. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  30465. }
  30466. if m.id == nil || m.oldValue == nil {
  30467. return v, errors.New("OldOwner requires an ID field in the mutation")
  30468. }
  30469. oldValue, err := m.oldValue(ctx)
  30470. if err != nil {
  30471. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  30472. }
  30473. return oldValue.Owner, nil
  30474. }
  30475. // ResetOwner resets all changes to the "owner" field.
  30476. func (m *WpChatroomMutation) ResetOwner() {
  30477. m.owner = nil
  30478. }
  30479. // SetAvatar sets the "avatar" field.
  30480. func (m *WpChatroomMutation) SetAvatar(s string) {
  30481. m.avatar = &s
  30482. }
  30483. // Avatar returns the value of the "avatar" field in the mutation.
  30484. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  30485. v := m.avatar
  30486. if v == nil {
  30487. return
  30488. }
  30489. return *v, true
  30490. }
  30491. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  30492. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30494. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  30495. if !m.op.Is(OpUpdateOne) {
  30496. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  30497. }
  30498. if m.id == nil || m.oldValue == nil {
  30499. return v, errors.New("OldAvatar requires an ID field in the mutation")
  30500. }
  30501. oldValue, err := m.oldValue(ctx)
  30502. if err != nil {
  30503. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  30504. }
  30505. return oldValue.Avatar, nil
  30506. }
  30507. // ResetAvatar resets all changes to the "avatar" field.
  30508. func (m *WpChatroomMutation) ResetAvatar() {
  30509. m.avatar = nil
  30510. }
  30511. // SetMemberList sets the "member_list" field.
  30512. func (m *WpChatroomMutation) SetMemberList(s []string) {
  30513. m.member_list = &s
  30514. m.appendmember_list = nil
  30515. }
  30516. // MemberList returns the value of the "member_list" field in the mutation.
  30517. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  30518. v := m.member_list
  30519. if v == nil {
  30520. return
  30521. }
  30522. return *v, true
  30523. }
  30524. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  30525. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30527. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  30528. if !m.op.Is(OpUpdateOne) {
  30529. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  30530. }
  30531. if m.id == nil || m.oldValue == nil {
  30532. return v, errors.New("OldMemberList requires an ID field in the mutation")
  30533. }
  30534. oldValue, err := m.oldValue(ctx)
  30535. if err != nil {
  30536. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  30537. }
  30538. return oldValue.MemberList, nil
  30539. }
  30540. // AppendMemberList adds s to the "member_list" field.
  30541. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  30542. m.appendmember_list = append(m.appendmember_list, s...)
  30543. }
  30544. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  30545. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  30546. if len(m.appendmember_list) == 0 {
  30547. return nil, false
  30548. }
  30549. return m.appendmember_list, true
  30550. }
  30551. // ResetMemberList resets all changes to the "member_list" field.
  30552. func (m *WpChatroomMutation) ResetMemberList() {
  30553. m.member_list = nil
  30554. m.appendmember_list = nil
  30555. }
  30556. // Where appends a list predicates to the WpChatroomMutation builder.
  30557. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  30558. m.predicates = append(m.predicates, ps...)
  30559. }
  30560. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  30561. // users can use type-assertion to append predicates that do not depend on any generated package.
  30562. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  30563. p := make([]predicate.WpChatroom, len(ps))
  30564. for i := range ps {
  30565. p[i] = ps[i]
  30566. }
  30567. m.Where(p...)
  30568. }
  30569. // Op returns the operation name.
  30570. func (m *WpChatroomMutation) Op() Op {
  30571. return m.op
  30572. }
  30573. // SetOp allows setting the mutation operation.
  30574. func (m *WpChatroomMutation) SetOp(op Op) {
  30575. m.op = op
  30576. }
  30577. // Type returns the node type of this mutation (WpChatroom).
  30578. func (m *WpChatroomMutation) Type() string {
  30579. return m.typ
  30580. }
  30581. // Fields returns all fields that were changed during this mutation. Note that in
  30582. // order to get all numeric fields that were incremented/decremented, call
  30583. // AddedFields().
  30584. func (m *WpChatroomMutation) Fields() []string {
  30585. fields := make([]string, 0, 9)
  30586. if m.created_at != nil {
  30587. fields = append(fields, wpchatroom.FieldCreatedAt)
  30588. }
  30589. if m.updated_at != nil {
  30590. fields = append(fields, wpchatroom.FieldUpdatedAt)
  30591. }
  30592. if m.status != nil {
  30593. fields = append(fields, wpchatroom.FieldStatus)
  30594. }
  30595. if m.wx_wxid != nil {
  30596. fields = append(fields, wpchatroom.FieldWxWxid)
  30597. }
  30598. if m.chatroom_id != nil {
  30599. fields = append(fields, wpchatroom.FieldChatroomID)
  30600. }
  30601. if m.nickname != nil {
  30602. fields = append(fields, wpchatroom.FieldNickname)
  30603. }
  30604. if m.owner != nil {
  30605. fields = append(fields, wpchatroom.FieldOwner)
  30606. }
  30607. if m.avatar != nil {
  30608. fields = append(fields, wpchatroom.FieldAvatar)
  30609. }
  30610. if m.member_list != nil {
  30611. fields = append(fields, wpchatroom.FieldMemberList)
  30612. }
  30613. return fields
  30614. }
  30615. // Field returns the value of a field with the given name. The second boolean
  30616. // return value indicates that this field was not set, or was not defined in the
  30617. // schema.
  30618. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  30619. switch name {
  30620. case wpchatroom.FieldCreatedAt:
  30621. return m.CreatedAt()
  30622. case wpchatroom.FieldUpdatedAt:
  30623. return m.UpdatedAt()
  30624. case wpchatroom.FieldStatus:
  30625. return m.Status()
  30626. case wpchatroom.FieldWxWxid:
  30627. return m.WxWxid()
  30628. case wpchatroom.FieldChatroomID:
  30629. return m.ChatroomID()
  30630. case wpchatroom.FieldNickname:
  30631. return m.Nickname()
  30632. case wpchatroom.FieldOwner:
  30633. return m.Owner()
  30634. case wpchatroom.FieldAvatar:
  30635. return m.Avatar()
  30636. case wpchatroom.FieldMemberList:
  30637. return m.MemberList()
  30638. }
  30639. return nil, false
  30640. }
  30641. // OldField returns the old value of the field from the database. An error is
  30642. // returned if the mutation operation is not UpdateOne, or the query to the
  30643. // database failed.
  30644. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30645. switch name {
  30646. case wpchatroom.FieldCreatedAt:
  30647. return m.OldCreatedAt(ctx)
  30648. case wpchatroom.FieldUpdatedAt:
  30649. return m.OldUpdatedAt(ctx)
  30650. case wpchatroom.FieldStatus:
  30651. return m.OldStatus(ctx)
  30652. case wpchatroom.FieldWxWxid:
  30653. return m.OldWxWxid(ctx)
  30654. case wpchatroom.FieldChatroomID:
  30655. return m.OldChatroomID(ctx)
  30656. case wpchatroom.FieldNickname:
  30657. return m.OldNickname(ctx)
  30658. case wpchatroom.FieldOwner:
  30659. return m.OldOwner(ctx)
  30660. case wpchatroom.FieldAvatar:
  30661. return m.OldAvatar(ctx)
  30662. case wpchatroom.FieldMemberList:
  30663. return m.OldMemberList(ctx)
  30664. }
  30665. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  30666. }
  30667. // SetField sets the value of a field with the given name. It returns an error if
  30668. // the field is not defined in the schema, or if the type mismatched the field
  30669. // type.
  30670. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  30671. switch name {
  30672. case wpchatroom.FieldCreatedAt:
  30673. v, ok := value.(time.Time)
  30674. if !ok {
  30675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30676. }
  30677. m.SetCreatedAt(v)
  30678. return nil
  30679. case wpchatroom.FieldUpdatedAt:
  30680. v, ok := value.(time.Time)
  30681. if !ok {
  30682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30683. }
  30684. m.SetUpdatedAt(v)
  30685. return nil
  30686. case wpchatroom.FieldStatus:
  30687. v, ok := value.(uint8)
  30688. if !ok {
  30689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30690. }
  30691. m.SetStatus(v)
  30692. return nil
  30693. case wpchatroom.FieldWxWxid:
  30694. v, ok := value.(string)
  30695. if !ok {
  30696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30697. }
  30698. m.SetWxWxid(v)
  30699. return nil
  30700. case wpchatroom.FieldChatroomID:
  30701. v, ok := value.(string)
  30702. if !ok {
  30703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30704. }
  30705. m.SetChatroomID(v)
  30706. return nil
  30707. case wpchatroom.FieldNickname:
  30708. v, ok := value.(string)
  30709. if !ok {
  30710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30711. }
  30712. m.SetNickname(v)
  30713. return nil
  30714. case wpchatroom.FieldOwner:
  30715. v, ok := value.(string)
  30716. if !ok {
  30717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30718. }
  30719. m.SetOwner(v)
  30720. return nil
  30721. case wpchatroom.FieldAvatar:
  30722. v, ok := value.(string)
  30723. if !ok {
  30724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30725. }
  30726. m.SetAvatar(v)
  30727. return nil
  30728. case wpchatroom.FieldMemberList:
  30729. v, ok := value.([]string)
  30730. if !ok {
  30731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30732. }
  30733. m.SetMemberList(v)
  30734. return nil
  30735. }
  30736. return fmt.Errorf("unknown WpChatroom field %s", name)
  30737. }
  30738. // AddedFields returns all numeric fields that were incremented/decremented during
  30739. // this mutation.
  30740. func (m *WpChatroomMutation) AddedFields() []string {
  30741. var fields []string
  30742. if m.addstatus != nil {
  30743. fields = append(fields, wpchatroom.FieldStatus)
  30744. }
  30745. return fields
  30746. }
  30747. // AddedField returns the numeric value that was incremented/decremented on a field
  30748. // with the given name. The second boolean return value indicates that this field
  30749. // was not set, or was not defined in the schema.
  30750. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  30751. switch name {
  30752. case wpchatroom.FieldStatus:
  30753. return m.AddedStatus()
  30754. }
  30755. return nil, false
  30756. }
  30757. // AddField adds the value to the field with the given name. It returns an error if
  30758. // the field is not defined in the schema, or if the type mismatched the field
  30759. // type.
  30760. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  30761. switch name {
  30762. case wpchatroom.FieldStatus:
  30763. v, ok := value.(int8)
  30764. if !ok {
  30765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30766. }
  30767. m.AddStatus(v)
  30768. return nil
  30769. }
  30770. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  30771. }
  30772. // ClearedFields returns all nullable fields that were cleared during this
  30773. // mutation.
  30774. func (m *WpChatroomMutation) ClearedFields() []string {
  30775. var fields []string
  30776. if m.FieldCleared(wpchatroom.FieldStatus) {
  30777. fields = append(fields, wpchatroom.FieldStatus)
  30778. }
  30779. return fields
  30780. }
  30781. // FieldCleared returns a boolean indicating if a field with the given name was
  30782. // cleared in this mutation.
  30783. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  30784. _, ok := m.clearedFields[name]
  30785. return ok
  30786. }
  30787. // ClearField clears the value of the field with the given name. It returns an
  30788. // error if the field is not defined in the schema.
  30789. func (m *WpChatroomMutation) ClearField(name string) error {
  30790. switch name {
  30791. case wpchatroom.FieldStatus:
  30792. m.ClearStatus()
  30793. return nil
  30794. }
  30795. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  30796. }
  30797. // ResetField resets all changes in the mutation for the field with the given name.
  30798. // It returns an error if the field is not defined in the schema.
  30799. func (m *WpChatroomMutation) ResetField(name string) error {
  30800. switch name {
  30801. case wpchatroom.FieldCreatedAt:
  30802. m.ResetCreatedAt()
  30803. return nil
  30804. case wpchatroom.FieldUpdatedAt:
  30805. m.ResetUpdatedAt()
  30806. return nil
  30807. case wpchatroom.FieldStatus:
  30808. m.ResetStatus()
  30809. return nil
  30810. case wpchatroom.FieldWxWxid:
  30811. m.ResetWxWxid()
  30812. return nil
  30813. case wpchatroom.FieldChatroomID:
  30814. m.ResetChatroomID()
  30815. return nil
  30816. case wpchatroom.FieldNickname:
  30817. m.ResetNickname()
  30818. return nil
  30819. case wpchatroom.FieldOwner:
  30820. m.ResetOwner()
  30821. return nil
  30822. case wpchatroom.FieldAvatar:
  30823. m.ResetAvatar()
  30824. return nil
  30825. case wpchatroom.FieldMemberList:
  30826. m.ResetMemberList()
  30827. return nil
  30828. }
  30829. return fmt.Errorf("unknown WpChatroom field %s", name)
  30830. }
  30831. // AddedEdges returns all edge names that were set/added in this mutation.
  30832. func (m *WpChatroomMutation) AddedEdges() []string {
  30833. edges := make([]string, 0, 0)
  30834. return edges
  30835. }
  30836. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30837. // name in this mutation.
  30838. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  30839. return nil
  30840. }
  30841. // RemovedEdges returns all edge names that were removed in this mutation.
  30842. func (m *WpChatroomMutation) RemovedEdges() []string {
  30843. edges := make([]string, 0, 0)
  30844. return edges
  30845. }
  30846. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30847. // the given name in this mutation.
  30848. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  30849. return nil
  30850. }
  30851. // ClearedEdges returns all edge names that were cleared in this mutation.
  30852. func (m *WpChatroomMutation) ClearedEdges() []string {
  30853. edges := make([]string, 0, 0)
  30854. return edges
  30855. }
  30856. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30857. // was cleared in this mutation.
  30858. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  30859. return false
  30860. }
  30861. // ClearEdge clears the value of the edge with the given name. It returns an error
  30862. // if that edge is not defined in the schema.
  30863. func (m *WpChatroomMutation) ClearEdge(name string) error {
  30864. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  30865. }
  30866. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30867. // It returns an error if the edge is not defined in the schema.
  30868. func (m *WpChatroomMutation) ResetEdge(name string) error {
  30869. return fmt.Errorf("unknown WpChatroom edge %s", name)
  30870. }
  30871. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  30872. type WpChatroomMemberMutation struct {
  30873. config
  30874. op Op
  30875. typ string
  30876. id *uint64
  30877. created_at *time.Time
  30878. updated_at *time.Time
  30879. status *uint8
  30880. addstatus *int8
  30881. wx_wxid *string
  30882. wxid *string
  30883. nickname *string
  30884. avatar *string
  30885. clearedFields map[string]struct{}
  30886. done bool
  30887. oldValue func(context.Context) (*WpChatroomMember, error)
  30888. predicates []predicate.WpChatroomMember
  30889. }
  30890. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  30891. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  30892. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  30893. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  30894. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  30895. m := &WpChatroomMemberMutation{
  30896. config: c,
  30897. op: op,
  30898. typ: TypeWpChatroomMember,
  30899. clearedFields: make(map[string]struct{}),
  30900. }
  30901. for _, opt := range opts {
  30902. opt(m)
  30903. }
  30904. return m
  30905. }
  30906. // withWpChatroomMemberID sets the ID field of the mutation.
  30907. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  30908. return func(m *WpChatroomMemberMutation) {
  30909. var (
  30910. err error
  30911. once sync.Once
  30912. value *WpChatroomMember
  30913. )
  30914. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  30915. once.Do(func() {
  30916. if m.done {
  30917. err = errors.New("querying old values post mutation is not allowed")
  30918. } else {
  30919. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  30920. }
  30921. })
  30922. return value, err
  30923. }
  30924. m.id = &id
  30925. }
  30926. }
  30927. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  30928. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  30929. return func(m *WpChatroomMemberMutation) {
  30930. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  30931. return node, nil
  30932. }
  30933. m.id = &node.ID
  30934. }
  30935. }
  30936. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30937. // executed in a transaction (ent.Tx), a transactional client is returned.
  30938. func (m WpChatroomMemberMutation) Client() *Client {
  30939. client := &Client{config: m.config}
  30940. client.init()
  30941. return client
  30942. }
  30943. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30944. // it returns an error otherwise.
  30945. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  30946. if _, ok := m.driver.(*txDriver); !ok {
  30947. return nil, errors.New("ent: mutation is not running in a transaction")
  30948. }
  30949. tx := &Tx{config: m.config}
  30950. tx.init()
  30951. return tx, nil
  30952. }
  30953. // SetID sets the value of the id field. Note that this
  30954. // operation is only accepted on creation of WpChatroomMember entities.
  30955. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  30956. m.id = &id
  30957. }
  30958. // ID returns the ID value in the mutation. Note that the ID is only available
  30959. // if it was provided to the builder or after it was returned from the database.
  30960. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  30961. if m.id == nil {
  30962. return
  30963. }
  30964. return *m.id, true
  30965. }
  30966. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30967. // That means, if the mutation is applied within a transaction with an isolation level such
  30968. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30969. // or updated by the mutation.
  30970. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  30971. switch {
  30972. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30973. id, exists := m.ID()
  30974. if exists {
  30975. return []uint64{id}, nil
  30976. }
  30977. fallthrough
  30978. case m.op.Is(OpUpdate | OpDelete):
  30979. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  30980. default:
  30981. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30982. }
  30983. }
  30984. // SetCreatedAt sets the "created_at" field.
  30985. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  30986. m.created_at = &t
  30987. }
  30988. // CreatedAt returns the value of the "created_at" field in the mutation.
  30989. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  30990. v := m.created_at
  30991. if v == nil {
  30992. return
  30993. }
  30994. return *v, true
  30995. }
  30996. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  30997. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  30998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30999. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31000. if !m.op.Is(OpUpdateOne) {
  31001. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31002. }
  31003. if m.id == nil || m.oldValue == nil {
  31004. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31005. }
  31006. oldValue, err := m.oldValue(ctx)
  31007. if err != nil {
  31008. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31009. }
  31010. return oldValue.CreatedAt, nil
  31011. }
  31012. // ResetCreatedAt resets all changes to the "created_at" field.
  31013. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  31014. m.created_at = nil
  31015. }
  31016. // SetUpdatedAt sets the "updated_at" field.
  31017. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  31018. m.updated_at = &t
  31019. }
  31020. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31021. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  31022. v := m.updated_at
  31023. if v == nil {
  31024. return
  31025. }
  31026. return *v, true
  31027. }
  31028. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  31029. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31031. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31032. if !m.op.Is(OpUpdateOne) {
  31033. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31034. }
  31035. if m.id == nil || m.oldValue == nil {
  31036. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31037. }
  31038. oldValue, err := m.oldValue(ctx)
  31039. if err != nil {
  31040. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31041. }
  31042. return oldValue.UpdatedAt, nil
  31043. }
  31044. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31045. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  31046. m.updated_at = nil
  31047. }
  31048. // SetStatus sets the "status" field.
  31049. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  31050. m.status = &u
  31051. m.addstatus = nil
  31052. }
  31053. // Status returns the value of the "status" field in the mutation.
  31054. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  31055. v := m.status
  31056. if v == nil {
  31057. return
  31058. }
  31059. return *v, true
  31060. }
  31061. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  31062. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31064. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31065. if !m.op.Is(OpUpdateOne) {
  31066. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31067. }
  31068. if m.id == nil || m.oldValue == nil {
  31069. return v, errors.New("OldStatus requires an ID field in the mutation")
  31070. }
  31071. oldValue, err := m.oldValue(ctx)
  31072. if err != nil {
  31073. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31074. }
  31075. return oldValue.Status, nil
  31076. }
  31077. // AddStatus adds u to the "status" field.
  31078. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  31079. if m.addstatus != nil {
  31080. *m.addstatus += u
  31081. } else {
  31082. m.addstatus = &u
  31083. }
  31084. }
  31085. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31086. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  31087. v := m.addstatus
  31088. if v == nil {
  31089. return
  31090. }
  31091. return *v, true
  31092. }
  31093. // ClearStatus clears the value of the "status" field.
  31094. func (m *WpChatroomMemberMutation) ClearStatus() {
  31095. m.status = nil
  31096. m.addstatus = nil
  31097. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  31098. }
  31099. // StatusCleared returns if the "status" field was cleared in this mutation.
  31100. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  31101. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  31102. return ok
  31103. }
  31104. // ResetStatus resets all changes to the "status" field.
  31105. func (m *WpChatroomMemberMutation) ResetStatus() {
  31106. m.status = nil
  31107. m.addstatus = nil
  31108. delete(m.clearedFields, wpchatroommember.FieldStatus)
  31109. }
  31110. // SetWxWxid sets the "wx_wxid" field.
  31111. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  31112. m.wx_wxid = &s
  31113. }
  31114. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  31115. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  31116. v := m.wx_wxid
  31117. if v == nil {
  31118. return
  31119. }
  31120. return *v, true
  31121. }
  31122. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  31123. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31125. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  31126. if !m.op.Is(OpUpdateOne) {
  31127. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  31128. }
  31129. if m.id == nil || m.oldValue == nil {
  31130. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  31131. }
  31132. oldValue, err := m.oldValue(ctx)
  31133. if err != nil {
  31134. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  31135. }
  31136. return oldValue.WxWxid, nil
  31137. }
  31138. // ResetWxWxid resets all changes to the "wx_wxid" field.
  31139. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  31140. m.wx_wxid = nil
  31141. }
  31142. // SetWxid sets the "wxid" field.
  31143. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  31144. m.wxid = &s
  31145. }
  31146. // Wxid returns the value of the "wxid" field in the mutation.
  31147. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  31148. v := m.wxid
  31149. if v == nil {
  31150. return
  31151. }
  31152. return *v, true
  31153. }
  31154. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  31155. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31157. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  31158. if !m.op.Is(OpUpdateOne) {
  31159. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  31160. }
  31161. if m.id == nil || m.oldValue == nil {
  31162. return v, errors.New("OldWxid requires an ID field in the mutation")
  31163. }
  31164. oldValue, err := m.oldValue(ctx)
  31165. if err != nil {
  31166. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  31167. }
  31168. return oldValue.Wxid, nil
  31169. }
  31170. // ResetWxid resets all changes to the "wxid" field.
  31171. func (m *WpChatroomMemberMutation) ResetWxid() {
  31172. m.wxid = nil
  31173. }
  31174. // SetNickname sets the "nickname" field.
  31175. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  31176. m.nickname = &s
  31177. }
  31178. // Nickname returns the value of the "nickname" field in the mutation.
  31179. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  31180. v := m.nickname
  31181. if v == nil {
  31182. return
  31183. }
  31184. return *v, true
  31185. }
  31186. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  31187. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31189. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  31190. if !m.op.Is(OpUpdateOne) {
  31191. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  31192. }
  31193. if m.id == nil || m.oldValue == nil {
  31194. return v, errors.New("OldNickname requires an ID field in the mutation")
  31195. }
  31196. oldValue, err := m.oldValue(ctx)
  31197. if err != nil {
  31198. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  31199. }
  31200. return oldValue.Nickname, nil
  31201. }
  31202. // ResetNickname resets all changes to the "nickname" field.
  31203. func (m *WpChatroomMemberMutation) ResetNickname() {
  31204. m.nickname = nil
  31205. }
  31206. // SetAvatar sets the "avatar" field.
  31207. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  31208. m.avatar = &s
  31209. }
  31210. // Avatar returns the value of the "avatar" field in the mutation.
  31211. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  31212. v := m.avatar
  31213. if v == nil {
  31214. return
  31215. }
  31216. return *v, true
  31217. }
  31218. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  31219. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31221. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  31222. if !m.op.Is(OpUpdateOne) {
  31223. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  31224. }
  31225. if m.id == nil || m.oldValue == nil {
  31226. return v, errors.New("OldAvatar requires an ID field in the mutation")
  31227. }
  31228. oldValue, err := m.oldValue(ctx)
  31229. if err != nil {
  31230. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  31231. }
  31232. return oldValue.Avatar, nil
  31233. }
  31234. // ResetAvatar resets all changes to the "avatar" field.
  31235. func (m *WpChatroomMemberMutation) ResetAvatar() {
  31236. m.avatar = nil
  31237. }
  31238. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  31239. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  31240. m.predicates = append(m.predicates, ps...)
  31241. }
  31242. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  31243. // users can use type-assertion to append predicates that do not depend on any generated package.
  31244. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  31245. p := make([]predicate.WpChatroomMember, len(ps))
  31246. for i := range ps {
  31247. p[i] = ps[i]
  31248. }
  31249. m.Where(p...)
  31250. }
  31251. // Op returns the operation name.
  31252. func (m *WpChatroomMemberMutation) Op() Op {
  31253. return m.op
  31254. }
  31255. // SetOp allows setting the mutation operation.
  31256. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  31257. m.op = op
  31258. }
  31259. // Type returns the node type of this mutation (WpChatroomMember).
  31260. func (m *WpChatroomMemberMutation) Type() string {
  31261. return m.typ
  31262. }
  31263. // Fields returns all fields that were changed during this mutation. Note that in
  31264. // order to get all numeric fields that were incremented/decremented, call
  31265. // AddedFields().
  31266. func (m *WpChatroomMemberMutation) Fields() []string {
  31267. fields := make([]string, 0, 7)
  31268. if m.created_at != nil {
  31269. fields = append(fields, wpchatroommember.FieldCreatedAt)
  31270. }
  31271. if m.updated_at != nil {
  31272. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  31273. }
  31274. if m.status != nil {
  31275. fields = append(fields, wpchatroommember.FieldStatus)
  31276. }
  31277. if m.wx_wxid != nil {
  31278. fields = append(fields, wpchatroommember.FieldWxWxid)
  31279. }
  31280. if m.wxid != nil {
  31281. fields = append(fields, wpchatroommember.FieldWxid)
  31282. }
  31283. if m.nickname != nil {
  31284. fields = append(fields, wpchatroommember.FieldNickname)
  31285. }
  31286. if m.avatar != nil {
  31287. fields = append(fields, wpchatroommember.FieldAvatar)
  31288. }
  31289. return fields
  31290. }
  31291. // Field returns the value of a field with the given name. The second boolean
  31292. // return value indicates that this field was not set, or was not defined in the
  31293. // schema.
  31294. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  31295. switch name {
  31296. case wpchatroommember.FieldCreatedAt:
  31297. return m.CreatedAt()
  31298. case wpchatroommember.FieldUpdatedAt:
  31299. return m.UpdatedAt()
  31300. case wpchatroommember.FieldStatus:
  31301. return m.Status()
  31302. case wpchatroommember.FieldWxWxid:
  31303. return m.WxWxid()
  31304. case wpchatroommember.FieldWxid:
  31305. return m.Wxid()
  31306. case wpchatroommember.FieldNickname:
  31307. return m.Nickname()
  31308. case wpchatroommember.FieldAvatar:
  31309. return m.Avatar()
  31310. }
  31311. return nil, false
  31312. }
  31313. // OldField returns the old value of the field from the database. An error is
  31314. // returned if the mutation operation is not UpdateOne, or the query to the
  31315. // database failed.
  31316. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31317. switch name {
  31318. case wpchatroommember.FieldCreatedAt:
  31319. return m.OldCreatedAt(ctx)
  31320. case wpchatroommember.FieldUpdatedAt:
  31321. return m.OldUpdatedAt(ctx)
  31322. case wpchatroommember.FieldStatus:
  31323. return m.OldStatus(ctx)
  31324. case wpchatroommember.FieldWxWxid:
  31325. return m.OldWxWxid(ctx)
  31326. case wpchatroommember.FieldWxid:
  31327. return m.OldWxid(ctx)
  31328. case wpchatroommember.FieldNickname:
  31329. return m.OldNickname(ctx)
  31330. case wpchatroommember.FieldAvatar:
  31331. return m.OldAvatar(ctx)
  31332. }
  31333. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  31334. }
  31335. // SetField sets the value of a field with the given name. It returns an error if
  31336. // the field is not defined in the schema, or if the type mismatched the field
  31337. // type.
  31338. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  31339. switch name {
  31340. case wpchatroommember.FieldCreatedAt:
  31341. v, ok := value.(time.Time)
  31342. if !ok {
  31343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31344. }
  31345. m.SetCreatedAt(v)
  31346. return nil
  31347. case wpchatroommember.FieldUpdatedAt:
  31348. v, ok := value.(time.Time)
  31349. if !ok {
  31350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31351. }
  31352. m.SetUpdatedAt(v)
  31353. return nil
  31354. case wpchatroommember.FieldStatus:
  31355. v, ok := value.(uint8)
  31356. if !ok {
  31357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31358. }
  31359. m.SetStatus(v)
  31360. return nil
  31361. case wpchatroommember.FieldWxWxid:
  31362. v, ok := value.(string)
  31363. if !ok {
  31364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31365. }
  31366. m.SetWxWxid(v)
  31367. return nil
  31368. case wpchatroommember.FieldWxid:
  31369. v, ok := value.(string)
  31370. if !ok {
  31371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31372. }
  31373. m.SetWxid(v)
  31374. return nil
  31375. case wpchatroommember.FieldNickname:
  31376. v, ok := value.(string)
  31377. if !ok {
  31378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31379. }
  31380. m.SetNickname(v)
  31381. return nil
  31382. case wpchatroommember.FieldAvatar:
  31383. v, ok := value.(string)
  31384. if !ok {
  31385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31386. }
  31387. m.SetAvatar(v)
  31388. return nil
  31389. }
  31390. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  31391. }
  31392. // AddedFields returns all numeric fields that were incremented/decremented during
  31393. // this mutation.
  31394. func (m *WpChatroomMemberMutation) AddedFields() []string {
  31395. var fields []string
  31396. if m.addstatus != nil {
  31397. fields = append(fields, wpchatroommember.FieldStatus)
  31398. }
  31399. return fields
  31400. }
  31401. // AddedField returns the numeric value that was incremented/decremented on a field
  31402. // with the given name. The second boolean return value indicates that this field
  31403. // was not set, or was not defined in the schema.
  31404. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  31405. switch name {
  31406. case wpchatroommember.FieldStatus:
  31407. return m.AddedStatus()
  31408. }
  31409. return nil, false
  31410. }
  31411. // AddField adds the value to the field with the given name. It returns an error if
  31412. // the field is not defined in the schema, or if the type mismatched the field
  31413. // type.
  31414. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  31415. switch name {
  31416. case wpchatroommember.FieldStatus:
  31417. v, ok := value.(int8)
  31418. if !ok {
  31419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31420. }
  31421. m.AddStatus(v)
  31422. return nil
  31423. }
  31424. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  31425. }
  31426. // ClearedFields returns all nullable fields that were cleared during this
  31427. // mutation.
  31428. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  31429. var fields []string
  31430. if m.FieldCleared(wpchatroommember.FieldStatus) {
  31431. fields = append(fields, wpchatroommember.FieldStatus)
  31432. }
  31433. return fields
  31434. }
  31435. // FieldCleared returns a boolean indicating if a field with the given name was
  31436. // cleared in this mutation.
  31437. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  31438. _, ok := m.clearedFields[name]
  31439. return ok
  31440. }
  31441. // ClearField clears the value of the field with the given name. It returns an
  31442. // error if the field is not defined in the schema.
  31443. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  31444. switch name {
  31445. case wpchatroommember.FieldStatus:
  31446. m.ClearStatus()
  31447. return nil
  31448. }
  31449. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  31450. }
  31451. // ResetField resets all changes in the mutation for the field with the given name.
  31452. // It returns an error if the field is not defined in the schema.
  31453. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  31454. switch name {
  31455. case wpchatroommember.FieldCreatedAt:
  31456. m.ResetCreatedAt()
  31457. return nil
  31458. case wpchatroommember.FieldUpdatedAt:
  31459. m.ResetUpdatedAt()
  31460. return nil
  31461. case wpchatroommember.FieldStatus:
  31462. m.ResetStatus()
  31463. return nil
  31464. case wpchatroommember.FieldWxWxid:
  31465. m.ResetWxWxid()
  31466. return nil
  31467. case wpchatroommember.FieldWxid:
  31468. m.ResetWxid()
  31469. return nil
  31470. case wpchatroommember.FieldNickname:
  31471. m.ResetNickname()
  31472. return nil
  31473. case wpchatroommember.FieldAvatar:
  31474. m.ResetAvatar()
  31475. return nil
  31476. }
  31477. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  31478. }
  31479. // AddedEdges returns all edge names that were set/added in this mutation.
  31480. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  31481. edges := make([]string, 0, 0)
  31482. return edges
  31483. }
  31484. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31485. // name in this mutation.
  31486. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  31487. return nil
  31488. }
  31489. // RemovedEdges returns all edge names that were removed in this mutation.
  31490. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  31491. edges := make([]string, 0, 0)
  31492. return edges
  31493. }
  31494. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31495. // the given name in this mutation.
  31496. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  31497. return nil
  31498. }
  31499. // ClearedEdges returns all edge names that were cleared in this mutation.
  31500. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  31501. edges := make([]string, 0, 0)
  31502. return edges
  31503. }
  31504. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31505. // was cleared in this mutation.
  31506. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  31507. return false
  31508. }
  31509. // ClearEdge clears the value of the edge with the given name. It returns an error
  31510. // if that edge is not defined in the schema.
  31511. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  31512. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  31513. }
  31514. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31515. // It returns an error if the edge is not defined in the schema.
  31516. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  31517. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  31518. }
  31519. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  31520. type WxMutation struct {
  31521. config
  31522. op Op
  31523. typ string
  31524. id *uint64
  31525. created_at *time.Time
  31526. updated_at *time.Time
  31527. status *uint8
  31528. addstatus *int8
  31529. deleted_at *time.Time
  31530. port *string
  31531. process_id *string
  31532. callback *string
  31533. wxid *string
  31534. account *string
  31535. nickname *string
  31536. tel *string
  31537. head_big *string
  31538. organization_id *uint64
  31539. addorganization_id *int64
  31540. api_base *string
  31541. api_key *string
  31542. allow_list *[]string
  31543. appendallow_list []string
  31544. group_allow_list *[]string
  31545. appendgroup_allow_list []string
  31546. block_list *[]string
  31547. appendblock_list []string
  31548. group_block_list *[]string
  31549. appendgroup_block_list []string
  31550. clearedFields map[string]struct{}
  31551. server *uint64
  31552. clearedserver bool
  31553. agent *uint64
  31554. clearedagent bool
  31555. done bool
  31556. oldValue func(context.Context) (*Wx, error)
  31557. predicates []predicate.Wx
  31558. }
  31559. var _ ent.Mutation = (*WxMutation)(nil)
  31560. // wxOption allows management of the mutation configuration using functional options.
  31561. type wxOption func(*WxMutation)
  31562. // newWxMutation creates new mutation for the Wx entity.
  31563. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  31564. m := &WxMutation{
  31565. config: c,
  31566. op: op,
  31567. typ: TypeWx,
  31568. clearedFields: make(map[string]struct{}),
  31569. }
  31570. for _, opt := range opts {
  31571. opt(m)
  31572. }
  31573. return m
  31574. }
  31575. // withWxID sets the ID field of the mutation.
  31576. func withWxID(id uint64) wxOption {
  31577. return func(m *WxMutation) {
  31578. var (
  31579. err error
  31580. once sync.Once
  31581. value *Wx
  31582. )
  31583. m.oldValue = func(ctx context.Context) (*Wx, error) {
  31584. once.Do(func() {
  31585. if m.done {
  31586. err = errors.New("querying old values post mutation is not allowed")
  31587. } else {
  31588. value, err = m.Client().Wx.Get(ctx, id)
  31589. }
  31590. })
  31591. return value, err
  31592. }
  31593. m.id = &id
  31594. }
  31595. }
  31596. // withWx sets the old Wx of the mutation.
  31597. func withWx(node *Wx) wxOption {
  31598. return func(m *WxMutation) {
  31599. m.oldValue = func(context.Context) (*Wx, error) {
  31600. return node, nil
  31601. }
  31602. m.id = &node.ID
  31603. }
  31604. }
  31605. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31606. // executed in a transaction (ent.Tx), a transactional client is returned.
  31607. func (m WxMutation) Client() *Client {
  31608. client := &Client{config: m.config}
  31609. client.init()
  31610. return client
  31611. }
  31612. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31613. // it returns an error otherwise.
  31614. func (m WxMutation) Tx() (*Tx, error) {
  31615. if _, ok := m.driver.(*txDriver); !ok {
  31616. return nil, errors.New("ent: mutation is not running in a transaction")
  31617. }
  31618. tx := &Tx{config: m.config}
  31619. tx.init()
  31620. return tx, nil
  31621. }
  31622. // SetID sets the value of the id field. Note that this
  31623. // operation is only accepted on creation of Wx entities.
  31624. func (m *WxMutation) SetID(id uint64) {
  31625. m.id = &id
  31626. }
  31627. // ID returns the ID value in the mutation. Note that the ID is only available
  31628. // if it was provided to the builder or after it was returned from the database.
  31629. func (m *WxMutation) ID() (id uint64, exists bool) {
  31630. if m.id == nil {
  31631. return
  31632. }
  31633. return *m.id, true
  31634. }
  31635. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31636. // That means, if the mutation is applied within a transaction with an isolation level such
  31637. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31638. // or updated by the mutation.
  31639. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  31640. switch {
  31641. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31642. id, exists := m.ID()
  31643. if exists {
  31644. return []uint64{id}, nil
  31645. }
  31646. fallthrough
  31647. case m.op.Is(OpUpdate | OpDelete):
  31648. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  31649. default:
  31650. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31651. }
  31652. }
  31653. // SetCreatedAt sets the "created_at" field.
  31654. func (m *WxMutation) SetCreatedAt(t time.Time) {
  31655. m.created_at = &t
  31656. }
  31657. // CreatedAt returns the value of the "created_at" field in the mutation.
  31658. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  31659. v := m.created_at
  31660. if v == nil {
  31661. return
  31662. }
  31663. return *v, true
  31664. }
  31665. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  31666. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31668. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31669. if !m.op.Is(OpUpdateOne) {
  31670. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31671. }
  31672. if m.id == nil || m.oldValue == nil {
  31673. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31674. }
  31675. oldValue, err := m.oldValue(ctx)
  31676. if err != nil {
  31677. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31678. }
  31679. return oldValue.CreatedAt, nil
  31680. }
  31681. // ResetCreatedAt resets all changes to the "created_at" field.
  31682. func (m *WxMutation) ResetCreatedAt() {
  31683. m.created_at = nil
  31684. }
  31685. // SetUpdatedAt sets the "updated_at" field.
  31686. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  31687. m.updated_at = &t
  31688. }
  31689. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31690. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  31691. v := m.updated_at
  31692. if v == nil {
  31693. return
  31694. }
  31695. return *v, true
  31696. }
  31697. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  31698. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31700. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31701. if !m.op.Is(OpUpdateOne) {
  31702. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31703. }
  31704. if m.id == nil || m.oldValue == nil {
  31705. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31706. }
  31707. oldValue, err := m.oldValue(ctx)
  31708. if err != nil {
  31709. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31710. }
  31711. return oldValue.UpdatedAt, nil
  31712. }
  31713. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31714. func (m *WxMutation) ResetUpdatedAt() {
  31715. m.updated_at = nil
  31716. }
  31717. // SetStatus sets the "status" field.
  31718. func (m *WxMutation) SetStatus(u uint8) {
  31719. m.status = &u
  31720. m.addstatus = nil
  31721. }
  31722. // Status returns the value of the "status" field in the mutation.
  31723. func (m *WxMutation) Status() (r uint8, exists bool) {
  31724. v := m.status
  31725. if v == nil {
  31726. return
  31727. }
  31728. return *v, true
  31729. }
  31730. // OldStatus returns the old "status" field's value of the Wx entity.
  31731. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31733. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31734. if !m.op.Is(OpUpdateOne) {
  31735. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31736. }
  31737. if m.id == nil || m.oldValue == nil {
  31738. return v, errors.New("OldStatus requires an ID field in the mutation")
  31739. }
  31740. oldValue, err := m.oldValue(ctx)
  31741. if err != nil {
  31742. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31743. }
  31744. return oldValue.Status, nil
  31745. }
  31746. // AddStatus adds u to the "status" field.
  31747. func (m *WxMutation) AddStatus(u int8) {
  31748. if m.addstatus != nil {
  31749. *m.addstatus += u
  31750. } else {
  31751. m.addstatus = &u
  31752. }
  31753. }
  31754. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31755. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  31756. v := m.addstatus
  31757. if v == nil {
  31758. return
  31759. }
  31760. return *v, true
  31761. }
  31762. // ClearStatus clears the value of the "status" field.
  31763. func (m *WxMutation) ClearStatus() {
  31764. m.status = nil
  31765. m.addstatus = nil
  31766. m.clearedFields[wx.FieldStatus] = struct{}{}
  31767. }
  31768. // StatusCleared returns if the "status" field was cleared in this mutation.
  31769. func (m *WxMutation) StatusCleared() bool {
  31770. _, ok := m.clearedFields[wx.FieldStatus]
  31771. return ok
  31772. }
  31773. // ResetStatus resets all changes to the "status" field.
  31774. func (m *WxMutation) ResetStatus() {
  31775. m.status = nil
  31776. m.addstatus = nil
  31777. delete(m.clearedFields, wx.FieldStatus)
  31778. }
  31779. // SetDeletedAt sets the "deleted_at" field.
  31780. func (m *WxMutation) SetDeletedAt(t time.Time) {
  31781. m.deleted_at = &t
  31782. }
  31783. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31784. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  31785. v := m.deleted_at
  31786. if v == nil {
  31787. return
  31788. }
  31789. return *v, true
  31790. }
  31791. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  31792. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31794. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31795. if !m.op.Is(OpUpdateOne) {
  31796. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31797. }
  31798. if m.id == nil || m.oldValue == nil {
  31799. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31800. }
  31801. oldValue, err := m.oldValue(ctx)
  31802. if err != nil {
  31803. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31804. }
  31805. return oldValue.DeletedAt, nil
  31806. }
  31807. // ClearDeletedAt clears the value of the "deleted_at" field.
  31808. func (m *WxMutation) ClearDeletedAt() {
  31809. m.deleted_at = nil
  31810. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  31811. }
  31812. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31813. func (m *WxMutation) DeletedAtCleared() bool {
  31814. _, ok := m.clearedFields[wx.FieldDeletedAt]
  31815. return ok
  31816. }
  31817. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31818. func (m *WxMutation) ResetDeletedAt() {
  31819. m.deleted_at = nil
  31820. delete(m.clearedFields, wx.FieldDeletedAt)
  31821. }
  31822. // SetServerID sets the "server_id" field.
  31823. func (m *WxMutation) SetServerID(u uint64) {
  31824. m.server = &u
  31825. }
  31826. // ServerID returns the value of the "server_id" field in the mutation.
  31827. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  31828. v := m.server
  31829. if v == nil {
  31830. return
  31831. }
  31832. return *v, true
  31833. }
  31834. // OldServerID returns the old "server_id" field's value of the Wx entity.
  31835. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31837. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  31838. if !m.op.Is(OpUpdateOne) {
  31839. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  31840. }
  31841. if m.id == nil || m.oldValue == nil {
  31842. return v, errors.New("OldServerID requires an ID field in the mutation")
  31843. }
  31844. oldValue, err := m.oldValue(ctx)
  31845. if err != nil {
  31846. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  31847. }
  31848. return oldValue.ServerID, nil
  31849. }
  31850. // ClearServerID clears the value of the "server_id" field.
  31851. func (m *WxMutation) ClearServerID() {
  31852. m.server = nil
  31853. m.clearedFields[wx.FieldServerID] = struct{}{}
  31854. }
  31855. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  31856. func (m *WxMutation) ServerIDCleared() bool {
  31857. _, ok := m.clearedFields[wx.FieldServerID]
  31858. return ok
  31859. }
  31860. // ResetServerID resets all changes to the "server_id" field.
  31861. func (m *WxMutation) ResetServerID() {
  31862. m.server = nil
  31863. delete(m.clearedFields, wx.FieldServerID)
  31864. }
  31865. // SetPort sets the "port" field.
  31866. func (m *WxMutation) SetPort(s string) {
  31867. m.port = &s
  31868. }
  31869. // Port returns the value of the "port" field in the mutation.
  31870. func (m *WxMutation) Port() (r string, exists bool) {
  31871. v := m.port
  31872. if v == nil {
  31873. return
  31874. }
  31875. return *v, true
  31876. }
  31877. // OldPort returns the old "port" field's value of the Wx entity.
  31878. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31880. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  31881. if !m.op.Is(OpUpdateOne) {
  31882. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  31883. }
  31884. if m.id == nil || m.oldValue == nil {
  31885. return v, errors.New("OldPort requires an ID field in the mutation")
  31886. }
  31887. oldValue, err := m.oldValue(ctx)
  31888. if err != nil {
  31889. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  31890. }
  31891. return oldValue.Port, nil
  31892. }
  31893. // ResetPort resets all changes to the "port" field.
  31894. func (m *WxMutation) ResetPort() {
  31895. m.port = nil
  31896. }
  31897. // SetProcessID sets the "process_id" field.
  31898. func (m *WxMutation) SetProcessID(s string) {
  31899. m.process_id = &s
  31900. }
  31901. // ProcessID returns the value of the "process_id" field in the mutation.
  31902. func (m *WxMutation) ProcessID() (r string, exists bool) {
  31903. v := m.process_id
  31904. if v == nil {
  31905. return
  31906. }
  31907. return *v, true
  31908. }
  31909. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  31910. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31912. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  31913. if !m.op.Is(OpUpdateOne) {
  31914. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  31915. }
  31916. if m.id == nil || m.oldValue == nil {
  31917. return v, errors.New("OldProcessID requires an ID field in the mutation")
  31918. }
  31919. oldValue, err := m.oldValue(ctx)
  31920. if err != nil {
  31921. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  31922. }
  31923. return oldValue.ProcessID, nil
  31924. }
  31925. // ResetProcessID resets all changes to the "process_id" field.
  31926. func (m *WxMutation) ResetProcessID() {
  31927. m.process_id = nil
  31928. }
  31929. // SetCallback sets the "callback" field.
  31930. func (m *WxMutation) SetCallback(s string) {
  31931. m.callback = &s
  31932. }
  31933. // Callback returns the value of the "callback" field in the mutation.
  31934. func (m *WxMutation) Callback() (r string, exists bool) {
  31935. v := m.callback
  31936. if v == nil {
  31937. return
  31938. }
  31939. return *v, true
  31940. }
  31941. // OldCallback returns the old "callback" field's value of the Wx entity.
  31942. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31944. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  31945. if !m.op.Is(OpUpdateOne) {
  31946. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  31947. }
  31948. if m.id == nil || m.oldValue == nil {
  31949. return v, errors.New("OldCallback requires an ID field in the mutation")
  31950. }
  31951. oldValue, err := m.oldValue(ctx)
  31952. if err != nil {
  31953. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  31954. }
  31955. return oldValue.Callback, nil
  31956. }
  31957. // ResetCallback resets all changes to the "callback" field.
  31958. func (m *WxMutation) ResetCallback() {
  31959. m.callback = nil
  31960. }
  31961. // SetWxid sets the "wxid" field.
  31962. func (m *WxMutation) SetWxid(s string) {
  31963. m.wxid = &s
  31964. }
  31965. // Wxid returns the value of the "wxid" field in the mutation.
  31966. func (m *WxMutation) Wxid() (r string, exists bool) {
  31967. v := m.wxid
  31968. if v == nil {
  31969. return
  31970. }
  31971. return *v, true
  31972. }
  31973. // OldWxid returns the old "wxid" field's value of the Wx entity.
  31974. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  31975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31976. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  31977. if !m.op.Is(OpUpdateOne) {
  31978. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  31979. }
  31980. if m.id == nil || m.oldValue == nil {
  31981. return v, errors.New("OldWxid requires an ID field in the mutation")
  31982. }
  31983. oldValue, err := m.oldValue(ctx)
  31984. if err != nil {
  31985. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  31986. }
  31987. return oldValue.Wxid, nil
  31988. }
  31989. // ResetWxid resets all changes to the "wxid" field.
  31990. func (m *WxMutation) ResetWxid() {
  31991. m.wxid = nil
  31992. }
  31993. // SetAccount sets the "account" field.
  31994. func (m *WxMutation) SetAccount(s string) {
  31995. m.account = &s
  31996. }
  31997. // Account returns the value of the "account" field in the mutation.
  31998. func (m *WxMutation) Account() (r string, exists bool) {
  31999. v := m.account
  32000. if v == nil {
  32001. return
  32002. }
  32003. return *v, true
  32004. }
  32005. // OldAccount returns the old "account" field's value of the Wx entity.
  32006. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32008. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  32009. if !m.op.Is(OpUpdateOne) {
  32010. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  32011. }
  32012. if m.id == nil || m.oldValue == nil {
  32013. return v, errors.New("OldAccount requires an ID field in the mutation")
  32014. }
  32015. oldValue, err := m.oldValue(ctx)
  32016. if err != nil {
  32017. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  32018. }
  32019. return oldValue.Account, nil
  32020. }
  32021. // ResetAccount resets all changes to the "account" field.
  32022. func (m *WxMutation) ResetAccount() {
  32023. m.account = nil
  32024. }
  32025. // SetNickname sets the "nickname" field.
  32026. func (m *WxMutation) SetNickname(s string) {
  32027. m.nickname = &s
  32028. }
  32029. // Nickname returns the value of the "nickname" field in the mutation.
  32030. func (m *WxMutation) Nickname() (r string, exists bool) {
  32031. v := m.nickname
  32032. if v == nil {
  32033. return
  32034. }
  32035. return *v, true
  32036. }
  32037. // OldNickname returns the old "nickname" field's value of the Wx entity.
  32038. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32040. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  32041. if !m.op.Is(OpUpdateOne) {
  32042. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  32043. }
  32044. if m.id == nil || m.oldValue == nil {
  32045. return v, errors.New("OldNickname requires an ID field in the mutation")
  32046. }
  32047. oldValue, err := m.oldValue(ctx)
  32048. if err != nil {
  32049. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  32050. }
  32051. return oldValue.Nickname, nil
  32052. }
  32053. // ResetNickname resets all changes to the "nickname" field.
  32054. func (m *WxMutation) ResetNickname() {
  32055. m.nickname = nil
  32056. }
  32057. // SetTel sets the "tel" field.
  32058. func (m *WxMutation) SetTel(s string) {
  32059. m.tel = &s
  32060. }
  32061. // Tel returns the value of the "tel" field in the mutation.
  32062. func (m *WxMutation) Tel() (r string, exists bool) {
  32063. v := m.tel
  32064. if v == nil {
  32065. return
  32066. }
  32067. return *v, true
  32068. }
  32069. // OldTel returns the old "tel" field's value of the Wx entity.
  32070. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32072. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  32073. if !m.op.Is(OpUpdateOne) {
  32074. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  32075. }
  32076. if m.id == nil || m.oldValue == nil {
  32077. return v, errors.New("OldTel requires an ID field in the mutation")
  32078. }
  32079. oldValue, err := m.oldValue(ctx)
  32080. if err != nil {
  32081. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  32082. }
  32083. return oldValue.Tel, nil
  32084. }
  32085. // ResetTel resets all changes to the "tel" field.
  32086. func (m *WxMutation) ResetTel() {
  32087. m.tel = nil
  32088. }
  32089. // SetHeadBig sets the "head_big" field.
  32090. func (m *WxMutation) SetHeadBig(s string) {
  32091. m.head_big = &s
  32092. }
  32093. // HeadBig returns the value of the "head_big" field in the mutation.
  32094. func (m *WxMutation) HeadBig() (r string, exists bool) {
  32095. v := m.head_big
  32096. if v == nil {
  32097. return
  32098. }
  32099. return *v, true
  32100. }
  32101. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  32102. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32104. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  32105. if !m.op.Is(OpUpdateOne) {
  32106. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  32107. }
  32108. if m.id == nil || m.oldValue == nil {
  32109. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  32110. }
  32111. oldValue, err := m.oldValue(ctx)
  32112. if err != nil {
  32113. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  32114. }
  32115. return oldValue.HeadBig, nil
  32116. }
  32117. // ResetHeadBig resets all changes to the "head_big" field.
  32118. func (m *WxMutation) ResetHeadBig() {
  32119. m.head_big = nil
  32120. }
  32121. // SetOrganizationID sets the "organization_id" field.
  32122. func (m *WxMutation) SetOrganizationID(u uint64) {
  32123. m.organization_id = &u
  32124. m.addorganization_id = nil
  32125. }
  32126. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32127. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  32128. v := m.organization_id
  32129. if v == nil {
  32130. return
  32131. }
  32132. return *v, true
  32133. }
  32134. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  32135. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32137. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32138. if !m.op.Is(OpUpdateOne) {
  32139. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32140. }
  32141. if m.id == nil || m.oldValue == nil {
  32142. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32143. }
  32144. oldValue, err := m.oldValue(ctx)
  32145. if err != nil {
  32146. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32147. }
  32148. return oldValue.OrganizationID, nil
  32149. }
  32150. // AddOrganizationID adds u to the "organization_id" field.
  32151. func (m *WxMutation) AddOrganizationID(u int64) {
  32152. if m.addorganization_id != nil {
  32153. *m.addorganization_id += u
  32154. } else {
  32155. m.addorganization_id = &u
  32156. }
  32157. }
  32158. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32159. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  32160. v := m.addorganization_id
  32161. if v == nil {
  32162. return
  32163. }
  32164. return *v, true
  32165. }
  32166. // ClearOrganizationID clears the value of the "organization_id" field.
  32167. func (m *WxMutation) ClearOrganizationID() {
  32168. m.organization_id = nil
  32169. m.addorganization_id = nil
  32170. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  32171. }
  32172. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32173. func (m *WxMutation) OrganizationIDCleared() bool {
  32174. _, ok := m.clearedFields[wx.FieldOrganizationID]
  32175. return ok
  32176. }
  32177. // ResetOrganizationID resets all changes to the "organization_id" field.
  32178. func (m *WxMutation) ResetOrganizationID() {
  32179. m.organization_id = nil
  32180. m.addorganization_id = nil
  32181. delete(m.clearedFields, wx.FieldOrganizationID)
  32182. }
  32183. // SetAgentID sets the "agent_id" field.
  32184. func (m *WxMutation) SetAgentID(u uint64) {
  32185. m.agent = &u
  32186. }
  32187. // AgentID returns the value of the "agent_id" field in the mutation.
  32188. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  32189. v := m.agent
  32190. if v == nil {
  32191. return
  32192. }
  32193. return *v, true
  32194. }
  32195. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  32196. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32198. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  32199. if !m.op.Is(OpUpdateOne) {
  32200. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  32201. }
  32202. if m.id == nil || m.oldValue == nil {
  32203. return v, errors.New("OldAgentID requires an ID field in the mutation")
  32204. }
  32205. oldValue, err := m.oldValue(ctx)
  32206. if err != nil {
  32207. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  32208. }
  32209. return oldValue.AgentID, nil
  32210. }
  32211. // ResetAgentID resets all changes to the "agent_id" field.
  32212. func (m *WxMutation) ResetAgentID() {
  32213. m.agent = nil
  32214. }
  32215. // SetAPIBase sets the "api_base" field.
  32216. func (m *WxMutation) SetAPIBase(s string) {
  32217. m.api_base = &s
  32218. }
  32219. // APIBase returns the value of the "api_base" field in the mutation.
  32220. func (m *WxMutation) APIBase() (r string, exists bool) {
  32221. v := m.api_base
  32222. if v == nil {
  32223. return
  32224. }
  32225. return *v, true
  32226. }
  32227. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  32228. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32230. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  32231. if !m.op.Is(OpUpdateOne) {
  32232. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  32233. }
  32234. if m.id == nil || m.oldValue == nil {
  32235. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  32236. }
  32237. oldValue, err := m.oldValue(ctx)
  32238. if err != nil {
  32239. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  32240. }
  32241. return oldValue.APIBase, nil
  32242. }
  32243. // ClearAPIBase clears the value of the "api_base" field.
  32244. func (m *WxMutation) ClearAPIBase() {
  32245. m.api_base = nil
  32246. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  32247. }
  32248. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  32249. func (m *WxMutation) APIBaseCleared() bool {
  32250. _, ok := m.clearedFields[wx.FieldAPIBase]
  32251. return ok
  32252. }
  32253. // ResetAPIBase resets all changes to the "api_base" field.
  32254. func (m *WxMutation) ResetAPIBase() {
  32255. m.api_base = nil
  32256. delete(m.clearedFields, wx.FieldAPIBase)
  32257. }
  32258. // SetAPIKey sets the "api_key" field.
  32259. func (m *WxMutation) SetAPIKey(s string) {
  32260. m.api_key = &s
  32261. }
  32262. // APIKey returns the value of the "api_key" field in the mutation.
  32263. func (m *WxMutation) APIKey() (r string, exists bool) {
  32264. v := m.api_key
  32265. if v == nil {
  32266. return
  32267. }
  32268. return *v, true
  32269. }
  32270. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  32271. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32273. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  32274. if !m.op.Is(OpUpdateOne) {
  32275. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  32276. }
  32277. if m.id == nil || m.oldValue == nil {
  32278. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  32279. }
  32280. oldValue, err := m.oldValue(ctx)
  32281. if err != nil {
  32282. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  32283. }
  32284. return oldValue.APIKey, nil
  32285. }
  32286. // ClearAPIKey clears the value of the "api_key" field.
  32287. func (m *WxMutation) ClearAPIKey() {
  32288. m.api_key = nil
  32289. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  32290. }
  32291. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  32292. func (m *WxMutation) APIKeyCleared() bool {
  32293. _, ok := m.clearedFields[wx.FieldAPIKey]
  32294. return ok
  32295. }
  32296. // ResetAPIKey resets all changes to the "api_key" field.
  32297. func (m *WxMutation) ResetAPIKey() {
  32298. m.api_key = nil
  32299. delete(m.clearedFields, wx.FieldAPIKey)
  32300. }
  32301. // SetAllowList sets the "allow_list" field.
  32302. func (m *WxMutation) SetAllowList(s []string) {
  32303. m.allow_list = &s
  32304. m.appendallow_list = nil
  32305. }
  32306. // AllowList returns the value of the "allow_list" field in the mutation.
  32307. func (m *WxMutation) AllowList() (r []string, exists bool) {
  32308. v := m.allow_list
  32309. if v == nil {
  32310. return
  32311. }
  32312. return *v, true
  32313. }
  32314. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  32315. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32317. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  32318. if !m.op.Is(OpUpdateOne) {
  32319. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  32320. }
  32321. if m.id == nil || m.oldValue == nil {
  32322. return v, errors.New("OldAllowList requires an ID field in the mutation")
  32323. }
  32324. oldValue, err := m.oldValue(ctx)
  32325. if err != nil {
  32326. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  32327. }
  32328. return oldValue.AllowList, nil
  32329. }
  32330. // AppendAllowList adds s to the "allow_list" field.
  32331. func (m *WxMutation) AppendAllowList(s []string) {
  32332. m.appendallow_list = append(m.appendallow_list, s...)
  32333. }
  32334. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  32335. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  32336. if len(m.appendallow_list) == 0 {
  32337. return nil, false
  32338. }
  32339. return m.appendallow_list, true
  32340. }
  32341. // ResetAllowList resets all changes to the "allow_list" field.
  32342. func (m *WxMutation) ResetAllowList() {
  32343. m.allow_list = nil
  32344. m.appendallow_list = nil
  32345. }
  32346. // SetGroupAllowList sets the "group_allow_list" field.
  32347. func (m *WxMutation) SetGroupAllowList(s []string) {
  32348. m.group_allow_list = &s
  32349. m.appendgroup_allow_list = nil
  32350. }
  32351. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  32352. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  32353. v := m.group_allow_list
  32354. if v == nil {
  32355. return
  32356. }
  32357. return *v, true
  32358. }
  32359. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  32360. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32362. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  32363. if !m.op.Is(OpUpdateOne) {
  32364. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  32365. }
  32366. if m.id == nil || m.oldValue == nil {
  32367. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  32368. }
  32369. oldValue, err := m.oldValue(ctx)
  32370. if err != nil {
  32371. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  32372. }
  32373. return oldValue.GroupAllowList, nil
  32374. }
  32375. // AppendGroupAllowList adds s to the "group_allow_list" field.
  32376. func (m *WxMutation) AppendGroupAllowList(s []string) {
  32377. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  32378. }
  32379. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  32380. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  32381. if len(m.appendgroup_allow_list) == 0 {
  32382. return nil, false
  32383. }
  32384. return m.appendgroup_allow_list, true
  32385. }
  32386. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  32387. func (m *WxMutation) ResetGroupAllowList() {
  32388. m.group_allow_list = nil
  32389. m.appendgroup_allow_list = nil
  32390. }
  32391. // SetBlockList sets the "block_list" field.
  32392. func (m *WxMutation) SetBlockList(s []string) {
  32393. m.block_list = &s
  32394. m.appendblock_list = nil
  32395. }
  32396. // BlockList returns the value of the "block_list" field in the mutation.
  32397. func (m *WxMutation) BlockList() (r []string, exists bool) {
  32398. v := m.block_list
  32399. if v == nil {
  32400. return
  32401. }
  32402. return *v, true
  32403. }
  32404. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  32405. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32407. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  32408. if !m.op.Is(OpUpdateOne) {
  32409. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  32410. }
  32411. if m.id == nil || m.oldValue == nil {
  32412. return v, errors.New("OldBlockList requires an ID field in the mutation")
  32413. }
  32414. oldValue, err := m.oldValue(ctx)
  32415. if err != nil {
  32416. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  32417. }
  32418. return oldValue.BlockList, nil
  32419. }
  32420. // AppendBlockList adds s to the "block_list" field.
  32421. func (m *WxMutation) AppendBlockList(s []string) {
  32422. m.appendblock_list = append(m.appendblock_list, s...)
  32423. }
  32424. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  32425. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  32426. if len(m.appendblock_list) == 0 {
  32427. return nil, false
  32428. }
  32429. return m.appendblock_list, true
  32430. }
  32431. // ResetBlockList resets all changes to the "block_list" field.
  32432. func (m *WxMutation) ResetBlockList() {
  32433. m.block_list = nil
  32434. m.appendblock_list = nil
  32435. }
  32436. // SetGroupBlockList sets the "group_block_list" field.
  32437. func (m *WxMutation) SetGroupBlockList(s []string) {
  32438. m.group_block_list = &s
  32439. m.appendgroup_block_list = nil
  32440. }
  32441. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  32442. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  32443. v := m.group_block_list
  32444. if v == nil {
  32445. return
  32446. }
  32447. return *v, true
  32448. }
  32449. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  32450. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32452. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  32453. if !m.op.Is(OpUpdateOne) {
  32454. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  32455. }
  32456. if m.id == nil || m.oldValue == nil {
  32457. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  32458. }
  32459. oldValue, err := m.oldValue(ctx)
  32460. if err != nil {
  32461. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  32462. }
  32463. return oldValue.GroupBlockList, nil
  32464. }
  32465. // AppendGroupBlockList adds s to the "group_block_list" field.
  32466. func (m *WxMutation) AppendGroupBlockList(s []string) {
  32467. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  32468. }
  32469. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  32470. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  32471. if len(m.appendgroup_block_list) == 0 {
  32472. return nil, false
  32473. }
  32474. return m.appendgroup_block_list, true
  32475. }
  32476. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  32477. func (m *WxMutation) ResetGroupBlockList() {
  32478. m.group_block_list = nil
  32479. m.appendgroup_block_list = nil
  32480. }
  32481. // ClearServer clears the "server" edge to the Server entity.
  32482. func (m *WxMutation) ClearServer() {
  32483. m.clearedserver = true
  32484. m.clearedFields[wx.FieldServerID] = struct{}{}
  32485. }
  32486. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  32487. func (m *WxMutation) ServerCleared() bool {
  32488. return m.ServerIDCleared() || m.clearedserver
  32489. }
  32490. // ServerIDs returns the "server" edge IDs in the mutation.
  32491. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32492. // ServerID instead. It exists only for internal usage by the builders.
  32493. func (m *WxMutation) ServerIDs() (ids []uint64) {
  32494. if id := m.server; id != nil {
  32495. ids = append(ids, *id)
  32496. }
  32497. return
  32498. }
  32499. // ResetServer resets all changes to the "server" edge.
  32500. func (m *WxMutation) ResetServer() {
  32501. m.server = nil
  32502. m.clearedserver = false
  32503. }
  32504. // ClearAgent clears the "agent" edge to the Agent entity.
  32505. func (m *WxMutation) ClearAgent() {
  32506. m.clearedagent = true
  32507. m.clearedFields[wx.FieldAgentID] = struct{}{}
  32508. }
  32509. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  32510. func (m *WxMutation) AgentCleared() bool {
  32511. return m.clearedagent
  32512. }
  32513. // AgentIDs returns the "agent" edge IDs in the mutation.
  32514. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32515. // AgentID instead. It exists only for internal usage by the builders.
  32516. func (m *WxMutation) AgentIDs() (ids []uint64) {
  32517. if id := m.agent; id != nil {
  32518. ids = append(ids, *id)
  32519. }
  32520. return
  32521. }
  32522. // ResetAgent resets all changes to the "agent" edge.
  32523. func (m *WxMutation) ResetAgent() {
  32524. m.agent = nil
  32525. m.clearedagent = false
  32526. }
  32527. // Where appends a list predicates to the WxMutation builder.
  32528. func (m *WxMutation) Where(ps ...predicate.Wx) {
  32529. m.predicates = append(m.predicates, ps...)
  32530. }
  32531. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  32532. // users can use type-assertion to append predicates that do not depend on any generated package.
  32533. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  32534. p := make([]predicate.Wx, len(ps))
  32535. for i := range ps {
  32536. p[i] = ps[i]
  32537. }
  32538. m.Where(p...)
  32539. }
  32540. // Op returns the operation name.
  32541. func (m *WxMutation) Op() Op {
  32542. return m.op
  32543. }
  32544. // SetOp allows setting the mutation operation.
  32545. func (m *WxMutation) SetOp(op Op) {
  32546. m.op = op
  32547. }
  32548. // Type returns the node type of this mutation (Wx).
  32549. func (m *WxMutation) Type() string {
  32550. return m.typ
  32551. }
  32552. // Fields returns all fields that were changed during this mutation. Note that in
  32553. // order to get all numeric fields that were incremented/decremented, call
  32554. // AddedFields().
  32555. func (m *WxMutation) Fields() []string {
  32556. fields := make([]string, 0, 21)
  32557. if m.created_at != nil {
  32558. fields = append(fields, wx.FieldCreatedAt)
  32559. }
  32560. if m.updated_at != nil {
  32561. fields = append(fields, wx.FieldUpdatedAt)
  32562. }
  32563. if m.status != nil {
  32564. fields = append(fields, wx.FieldStatus)
  32565. }
  32566. if m.deleted_at != nil {
  32567. fields = append(fields, wx.FieldDeletedAt)
  32568. }
  32569. if m.server != nil {
  32570. fields = append(fields, wx.FieldServerID)
  32571. }
  32572. if m.port != nil {
  32573. fields = append(fields, wx.FieldPort)
  32574. }
  32575. if m.process_id != nil {
  32576. fields = append(fields, wx.FieldProcessID)
  32577. }
  32578. if m.callback != nil {
  32579. fields = append(fields, wx.FieldCallback)
  32580. }
  32581. if m.wxid != nil {
  32582. fields = append(fields, wx.FieldWxid)
  32583. }
  32584. if m.account != nil {
  32585. fields = append(fields, wx.FieldAccount)
  32586. }
  32587. if m.nickname != nil {
  32588. fields = append(fields, wx.FieldNickname)
  32589. }
  32590. if m.tel != nil {
  32591. fields = append(fields, wx.FieldTel)
  32592. }
  32593. if m.head_big != nil {
  32594. fields = append(fields, wx.FieldHeadBig)
  32595. }
  32596. if m.organization_id != nil {
  32597. fields = append(fields, wx.FieldOrganizationID)
  32598. }
  32599. if m.agent != nil {
  32600. fields = append(fields, wx.FieldAgentID)
  32601. }
  32602. if m.api_base != nil {
  32603. fields = append(fields, wx.FieldAPIBase)
  32604. }
  32605. if m.api_key != nil {
  32606. fields = append(fields, wx.FieldAPIKey)
  32607. }
  32608. if m.allow_list != nil {
  32609. fields = append(fields, wx.FieldAllowList)
  32610. }
  32611. if m.group_allow_list != nil {
  32612. fields = append(fields, wx.FieldGroupAllowList)
  32613. }
  32614. if m.block_list != nil {
  32615. fields = append(fields, wx.FieldBlockList)
  32616. }
  32617. if m.group_block_list != nil {
  32618. fields = append(fields, wx.FieldGroupBlockList)
  32619. }
  32620. return fields
  32621. }
  32622. // Field returns the value of a field with the given name. The second boolean
  32623. // return value indicates that this field was not set, or was not defined in the
  32624. // schema.
  32625. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  32626. switch name {
  32627. case wx.FieldCreatedAt:
  32628. return m.CreatedAt()
  32629. case wx.FieldUpdatedAt:
  32630. return m.UpdatedAt()
  32631. case wx.FieldStatus:
  32632. return m.Status()
  32633. case wx.FieldDeletedAt:
  32634. return m.DeletedAt()
  32635. case wx.FieldServerID:
  32636. return m.ServerID()
  32637. case wx.FieldPort:
  32638. return m.Port()
  32639. case wx.FieldProcessID:
  32640. return m.ProcessID()
  32641. case wx.FieldCallback:
  32642. return m.Callback()
  32643. case wx.FieldWxid:
  32644. return m.Wxid()
  32645. case wx.FieldAccount:
  32646. return m.Account()
  32647. case wx.FieldNickname:
  32648. return m.Nickname()
  32649. case wx.FieldTel:
  32650. return m.Tel()
  32651. case wx.FieldHeadBig:
  32652. return m.HeadBig()
  32653. case wx.FieldOrganizationID:
  32654. return m.OrganizationID()
  32655. case wx.FieldAgentID:
  32656. return m.AgentID()
  32657. case wx.FieldAPIBase:
  32658. return m.APIBase()
  32659. case wx.FieldAPIKey:
  32660. return m.APIKey()
  32661. case wx.FieldAllowList:
  32662. return m.AllowList()
  32663. case wx.FieldGroupAllowList:
  32664. return m.GroupAllowList()
  32665. case wx.FieldBlockList:
  32666. return m.BlockList()
  32667. case wx.FieldGroupBlockList:
  32668. return m.GroupBlockList()
  32669. }
  32670. return nil, false
  32671. }
  32672. // OldField returns the old value of the field from the database. An error is
  32673. // returned if the mutation operation is not UpdateOne, or the query to the
  32674. // database failed.
  32675. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32676. switch name {
  32677. case wx.FieldCreatedAt:
  32678. return m.OldCreatedAt(ctx)
  32679. case wx.FieldUpdatedAt:
  32680. return m.OldUpdatedAt(ctx)
  32681. case wx.FieldStatus:
  32682. return m.OldStatus(ctx)
  32683. case wx.FieldDeletedAt:
  32684. return m.OldDeletedAt(ctx)
  32685. case wx.FieldServerID:
  32686. return m.OldServerID(ctx)
  32687. case wx.FieldPort:
  32688. return m.OldPort(ctx)
  32689. case wx.FieldProcessID:
  32690. return m.OldProcessID(ctx)
  32691. case wx.FieldCallback:
  32692. return m.OldCallback(ctx)
  32693. case wx.FieldWxid:
  32694. return m.OldWxid(ctx)
  32695. case wx.FieldAccount:
  32696. return m.OldAccount(ctx)
  32697. case wx.FieldNickname:
  32698. return m.OldNickname(ctx)
  32699. case wx.FieldTel:
  32700. return m.OldTel(ctx)
  32701. case wx.FieldHeadBig:
  32702. return m.OldHeadBig(ctx)
  32703. case wx.FieldOrganizationID:
  32704. return m.OldOrganizationID(ctx)
  32705. case wx.FieldAgentID:
  32706. return m.OldAgentID(ctx)
  32707. case wx.FieldAPIBase:
  32708. return m.OldAPIBase(ctx)
  32709. case wx.FieldAPIKey:
  32710. return m.OldAPIKey(ctx)
  32711. case wx.FieldAllowList:
  32712. return m.OldAllowList(ctx)
  32713. case wx.FieldGroupAllowList:
  32714. return m.OldGroupAllowList(ctx)
  32715. case wx.FieldBlockList:
  32716. return m.OldBlockList(ctx)
  32717. case wx.FieldGroupBlockList:
  32718. return m.OldGroupBlockList(ctx)
  32719. }
  32720. return nil, fmt.Errorf("unknown Wx field %s", name)
  32721. }
  32722. // SetField sets the value of a field with the given name. It returns an error if
  32723. // the field is not defined in the schema, or if the type mismatched the field
  32724. // type.
  32725. func (m *WxMutation) SetField(name string, value ent.Value) error {
  32726. switch name {
  32727. case wx.FieldCreatedAt:
  32728. v, ok := value.(time.Time)
  32729. if !ok {
  32730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32731. }
  32732. m.SetCreatedAt(v)
  32733. return nil
  32734. case wx.FieldUpdatedAt:
  32735. v, ok := value.(time.Time)
  32736. if !ok {
  32737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32738. }
  32739. m.SetUpdatedAt(v)
  32740. return nil
  32741. case wx.FieldStatus:
  32742. v, ok := value.(uint8)
  32743. if !ok {
  32744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32745. }
  32746. m.SetStatus(v)
  32747. return nil
  32748. case wx.FieldDeletedAt:
  32749. v, ok := value.(time.Time)
  32750. if !ok {
  32751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32752. }
  32753. m.SetDeletedAt(v)
  32754. return nil
  32755. case wx.FieldServerID:
  32756. v, ok := value.(uint64)
  32757. if !ok {
  32758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32759. }
  32760. m.SetServerID(v)
  32761. return nil
  32762. case wx.FieldPort:
  32763. v, ok := value.(string)
  32764. if !ok {
  32765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32766. }
  32767. m.SetPort(v)
  32768. return nil
  32769. case wx.FieldProcessID:
  32770. v, ok := value.(string)
  32771. if !ok {
  32772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32773. }
  32774. m.SetProcessID(v)
  32775. return nil
  32776. case wx.FieldCallback:
  32777. v, ok := value.(string)
  32778. if !ok {
  32779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32780. }
  32781. m.SetCallback(v)
  32782. return nil
  32783. case wx.FieldWxid:
  32784. v, ok := value.(string)
  32785. if !ok {
  32786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32787. }
  32788. m.SetWxid(v)
  32789. return nil
  32790. case wx.FieldAccount:
  32791. v, ok := value.(string)
  32792. if !ok {
  32793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32794. }
  32795. m.SetAccount(v)
  32796. return nil
  32797. case wx.FieldNickname:
  32798. v, ok := value.(string)
  32799. if !ok {
  32800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32801. }
  32802. m.SetNickname(v)
  32803. return nil
  32804. case wx.FieldTel:
  32805. v, ok := value.(string)
  32806. if !ok {
  32807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32808. }
  32809. m.SetTel(v)
  32810. return nil
  32811. case wx.FieldHeadBig:
  32812. v, ok := value.(string)
  32813. if !ok {
  32814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32815. }
  32816. m.SetHeadBig(v)
  32817. return nil
  32818. case wx.FieldOrganizationID:
  32819. v, ok := value.(uint64)
  32820. if !ok {
  32821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32822. }
  32823. m.SetOrganizationID(v)
  32824. return nil
  32825. case wx.FieldAgentID:
  32826. v, ok := value.(uint64)
  32827. if !ok {
  32828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32829. }
  32830. m.SetAgentID(v)
  32831. return nil
  32832. case wx.FieldAPIBase:
  32833. v, ok := value.(string)
  32834. if !ok {
  32835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32836. }
  32837. m.SetAPIBase(v)
  32838. return nil
  32839. case wx.FieldAPIKey:
  32840. v, ok := value.(string)
  32841. if !ok {
  32842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32843. }
  32844. m.SetAPIKey(v)
  32845. return nil
  32846. case wx.FieldAllowList:
  32847. v, ok := value.([]string)
  32848. if !ok {
  32849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32850. }
  32851. m.SetAllowList(v)
  32852. return nil
  32853. case wx.FieldGroupAllowList:
  32854. v, ok := value.([]string)
  32855. if !ok {
  32856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32857. }
  32858. m.SetGroupAllowList(v)
  32859. return nil
  32860. case wx.FieldBlockList:
  32861. v, ok := value.([]string)
  32862. if !ok {
  32863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32864. }
  32865. m.SetBlockList(v)
  32866. return nil
  32867. case wx.FieldGroupBlockList:
  32868. v, ok := value.([]string)
  32869. if !ok {
  32870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32871. }
  32872. m.SetGroupBlockList(v)
  32873. return nil
  32874. }
  32875. return fmt.Errorf("unknown Wx field %s", name)
  32876. }
  32877. // AddedFields returns all numeric fields that were incremented/decremented during
  32878. // this mutation.
  32879. func (m *WxMutation) AddedFields() []string {
  32880. var fields []string
  32881. if m.addstatus != nil {
  32882. fields = append(fields, wx.FieldStatus)
  32883. }
  32884. if m.addorganization_id != nil {
  32885. fields = append(fields, wx.FieldOrganizationID)
  32886. }
  32887. return fields
  32888. }
  32889. // AddedField returns the numeric value that was incremented/decremented on a field
  32890. // with the given name. The second boolean return value indicates that this field
  32891. // was not set, or was not defined in the schema.
  32892. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  32893. switch name {
  32894. case wx.FieldStatus:
  32895. return m.AddedStatus()
  32896. case wx.FieldOrganizationID:
  32897. return m.AddedOrganizationID()
  32898. }
  32899. return nil, false
  32900. }
  32901. // AddField adds the value to the field with the given name. It returns an error if
  32902. // the field is not defined in the schema, or if the type mismatched the field
  32903. // type.
  32904. func (m *WxMutation) AddField(name string, value ent.Value) error {
  32905. switch name {
  32906. case wx.FieldStatus:
  32907. v, ok := value.(int8)
  32908. if !ok {
  32909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32910. }
  32911. m.AddStatus(v)
  32912. return nil
  32913. case wx.FieldOrganizationID:
  32914. v, ok := value.(int64)
  32915. if !ok {
  32916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32917. }
  32918. m.AddOrganizationID(v)
  32919. return nil
  32920. }
  32921. return fmt.Errorf("unknown Wx numeric field %s", name)
  32922. }
  32923. // ClearedFields returns all nullable fields that were cleared during this
  32924. // mutation.
  32925. func (m *WxMutation) ClearedFields() []string {
  32926. var fields []string
  32927. if m.FieldCleared(wx.FieldStatus) {
  32928. fields = append(fields, wx.FieldStatus)
  32929. }
  32930. if m.FieldCleared(wx.FieldDeletedAt) {
  32931. fields = append(fields, wx.FieldDeletedAt)
  32932. }
  32933. if m.FieldCleared(wx.FieldServerID) {
  32934. fields = append(fields, wx.FieldServerID)
  32935. }
  32936. if m.FieldCleared(wx.FieldOrganizationID) {
  32937. fields = append(fields, wx.FieldOrganizationID)
  32938. }
  32939. if m.FieldCleared(wx.FieldAPIBase) {
  32940. fields = append(fields, wx.FieldAPIBase)
  32941. }
  32942. if m.FieldCleared(wx.FieldAPIKey) {
  32943. fields = append(fields, wx.FieldAPIKey)
  32944. }
  32945. return fields
  32946. }
  32947. // FieldCleared returns a boolean indicating if a field with the given name was
  32948. // cleared in this mutation.
  32949. func (m *WxMutation) FieldCleared(name string) bool {
  32950. _, ok := m.clearedFields[name]
  32951. return ok
  32952. }
  32953. // ClearField clears the value of the field with the given name. It returns an
  32954. // error if the field is not defined in the schema.
  32955. func (m *WxMutation) ClearField(name string) error {
  32956. switch name {
  32957. case wx.FieldStatus:
  32958. m.ClearStatus()
  32959. return nil
  32960. case wx.FieldDeletedAt:
  32961. m.ClearDeletedAt()
  32962. return nil
  32963. case wx.FieldServerID:
  32964. m.ClearServerID()
  32965. return nil
  32966. case wx.FieldOrganizationID:
  32967. m.ClearOrganizationID()
  32968. return nil
  32969. case wx.FieldAPIBase:
  32970. m.ClearAPIBase()
  32971. return nil
  32972. case wx.FieldAPIKey:
  32973. m.ClearAPIKey()
  32974. return nil
  32975. }
  32976. return fmt.Errorf("unknown Wx nullable field %s", name)
  32977. }
  32978. // ResetField resets all changes in the mutation for the field with the given name.
  32979. // It returns an error if the field is not defined in the schema.
  32980. func (m *WxMutation) ResetField(name string) error {
  32981. switch name {
  32982. case wx.FieldCreatedAt:
  32983. m.ResetCreatedAt()
  32984. return nil
  32985. case wx.FieldUpdatedAt:
  32986. m.ResetUpdatedAt()
  32987. return nil
  32988. case wx.FieldStatus:
  32989. m.ResetStatus()
  32990. return nil
  32991. case wx.FieldDeletedAt:
  32992. m.ResetDeletedAt()
  32993. return nil
  32994. case wx.FieldServerID:
  32995. m.ResetServerID()
  32996. return nil
  32997. case wx.FieldPort:
  32998. m.ResetPort()
  32999. return nil
  33000. case wx.FieldProcessID:
  33001. m.ResetProcessID()
  33002. return nil
  33003. case wx.FieldCallback:
  33004. m.ResetCallback()
  33005. return nil
  33006. case wx.FieldWxid:
  33007. m.ResetWxid()
  33008. return nil
  33009. case wx.FieldAccount:
  33010. m.ResetAccount()
  33011. return nil
  33012. case wx.FieldNickname:
  33013. m.ResetNickname()
  33014. return nil
  33015. case wx.FieldTel:
  33016. m.ResetTel()
  33017. return nil
  33018. case wx.FieldHeadBig:
  33019. m.ResetHeadBig()
  33020. return nil
  33021. case wx.FieldOrganizationID:
  33022. m.ResetOrganizationID()
  33023. return nil
  33024. case wx.FieldAgentID:
  33025. m.ResetAgentID()
  33026. return nil
  33027. case wx.FieldAPIBase:
  33028. m.ResetAPIBase()
  33029. return nil
  33030. case wx.FieldAPIKey:
  33031. m.ResetAPIKey()
  33032. return nil
  33033. case wx.FieldAllowList:
  33034. m.ResetAllowList()
  33035. return nil
  33036. case wx.FieldGroupAllowList:
  33037. m.ResetGroupAllowList()
  33038. return nil
  33039. case wx.FieldBlockList:
  33040. m.ResetBlockList()
  33041. return nil
  33042. case wx.FieldGroupBlockList:
  33043. m.ResetGroupBlockList()
  33044. return nil
  33045. }
  33046. return fmt.Errorf("unknown Wx field %s", name)
  33047. }
  33048. // AddedEdges returns all edge names that were set/added in this mutation.
  33049. func (m *WxMutation) AddedEdges() []string {
  33050. edges := make([]string, 0, 2)
  33051. if m.server != nil {
  33052. edges = append(edges, wx.EdgeServer)
  33053. }
  33054. if m.agent != nil {
  33055. edges = append(edges, wx.EdgeAgent)
  33056. }
  33057. return edges
  33058. }
  33059. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33060. // name in this mutation.
  33061. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  33062. switch name {
  33063. case wx.EdgeServer:
  33064. if id := m.server; id != nil {
  33065. return []ent.Value{*id}
  33066. }
  33067. case wx.EdgeAgent:
  33068. if id := m.agent; id != nil {
  33069. return []ent.Value{*id}
  33070. }
  33071. }
  33072. return nil
  33073. }
  33074. // RemovedEdges returns all edge names that were removed in this mutation.
  33075. func (m *WxMutation) RemovedEdges() []string {
  33076. edges := make([]string, 0, 2)
  33077. return edges
  33078. }
  33079. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33080. // the given name in this mutation.
  33081. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  33082. return nil
  33083. }
  33084. // ClearedEdges returns all edge names that were cleared in this mutation.
  33085. func (m *WxMutation) ClearedEdges() []string {
  33086. edges := make([]string, 0, 2)
  33087. if m.clearedserver {
  33088. edges = append(edges, wx.EdgeServer)
  33089. }
  33090. if m.clearedagent {
  33091. edges = append(edges, wx.EdgeAgent)
  33092. }
  33093. return edges
  33094. }
  33095. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33096. // was cleared in this mutation.
  33097. func (m *WxMutation) EdgeCleared(name string) bool {
  33098. switch name {
  33099. case wx.EdgeServer:
  33100. return m.clearedserver
  33101. case wx.EdgeAgent:
  33102. return m.clearedagent
  33103. }
  33104. return false
  33105. }
  33106. // ClearEdge clears the value of the edge with the given name. It returns an error
  33107. // if that edge is not defined in the schema.
  33108. func (m *WxMutation) ClearEdge(name string) error {
  33109. switch name {
  33110. case wx.EdgeServer:
  33111. m.ClearServer()
  33112. return nil
  33113. case wx.EdgeAgent:
  33114. m.ClearAgent()
  33115. return nil
  33116. }
  33117. return fmt.Errorf("unknown Wx unique edge %s", name)
  33118. }
  33119. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33120. // It returns an error if the edge is not defined in the schema.
  33121. func (m *WxMutation) ResetEdge(name string) error {
  33122. switch name {
  33123. case wx.EdgeServer:
  33124. m.ResetServer()
  33125. return nil
  33126. case wx.EdgeAgent:
  33127. m.ResetAgent()
  33128. return nil
  33129. }
  33130. return fmt.Errorf("unknown Wx edge %s", name)
  33131. }
  33132. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  33133. type WxCardMutation struct {
  33134. config
  33135. op Op
  33136. typ string
  33137. id *uint64
  33138. created_at *time.Time
  33139. updated_at *time.Time
  33140. deleted_at *time.Time
  33141. user_id *uint64
  33142. adduser_id *int64
  33143. wx_user_id *uint64
  33144. addwx_user_id *int64
  33145. avatar *string
  33146. logo *string
  33147. name *string
  33148. company *string
  33149. address *string
  33150. phone *string
  33151. official_account *string
  33152. wechat_account *string
  33153. email *string
  33154. api_base *string
  33155. api_key *string
  33156. ai_info *string
  33157. intro *string
  33158. clearedFields map[string]struct{}
  33159. done bool
  33160. oldValue func(context.Context) (*WxCard, error)
  33161. predicates []predicate.WxCard
  33162. }
  33163. var _ ent.Mutation = (*WxCardMutation)(nil)
  33164. // wxcardOption allows management of the mutation configuration using functional options.
  33165. type wxcardOption func(*WxCardMutation)
  33166. // newWxCardMutation creates new mutation for the WxCard entity.
  33167. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  33168. m := &WxCardMutation{
  33169. config: c,
  33170. op: op,
  33171. typ: TypeWxCard,
  33172. clearedFields: make(map[string]struct{}),
  33173. }
  33174. for _, opt := range opts {
  33175. opt(m)
  33176. }
  33177. return m
  33178. }
  33179. // withWxCardID sets the ID field of the mutation.
  33180. func withWxCardID(id uint64) wxcardOption {
  33181. return func(m *WxCardMutation) {
  33182. var (
  33183. err error
  33184. once sync.Once
  33185. value *WxCard
  33186. )
  33187. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  33188. once.Do(func() {
  33189. if m.done {
  33190. err = errors.New("querying old values post mutation is not allowed")
  33191. } else {
  33192. value, err = m.Client().WxCard.Get(ctx, id)
  33193. }
  33194. })
  33195. return value, err
  33196. }
  33197. m.id = &id
  33198. }
  33199. }
  33200. // withWxCard sets the old WxCard of the mutation.
  33201. func withWxCard(node *WxCard) wxcardOption {
  33202. return func(m *WxCardMutation) {
  33203. m.oldValue = func(context.Context) (*WxCard, error) {
  33204. return node, nil
  33205. }
  33206. m.id = &node.ID
  33207. }
  33208. }
  33209. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33210. // executed in a transaction (ent.Tx), a transactional client is returned.
  33211. func (m WxCardMutation) Client() *Client {
  33212. client := &Client{config: m.config}
  33213. client.init()
  33214. return client
  33215. }
  33216. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33217. // it returns an error otherwise.
  33218. func (m WxCardMutation) Tx() (*Tx, error) {
  33219. if _, ok := m.driver.(*txDriver); !ok {
  33220. return nil, errors.New("ent: mutation is not running in a transaction")
  33221. }
  33222. tx := &Tx{config: m.config}
  33223. tx.init()
  33224. return tx, nil
  33225. }
  33226. // SetID sets the value of the id field. Note that this
  33227. // operation is only accepted on creation of WxCard entities.
  33228. func (m *WxCardMutation) SetID(id uint64) {
  33229. m.id = &id
  33230. }
  33231. // ID returns the ID value in the mutation. Note that the ID is only available
  33232. // if it was provided to the builder or after it was returned from the database.
  33233. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  33234. if m.id == nil {
  33235. return
  33236. }
  33237. return *m.id, true
  33238. }
  33239. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33240. // That means, if the mutation is applied within a transaction with an isolation level such
  33241. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33242. // or updated by the mutation.
  33243. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  33244. switch {
  33245. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33246. id, exists := m.ID()
  33247. if exists {
  33248. return []uint64{id}, nil
  33249. }
  33250. fallthrough
  33251. case m.op.Is(OpUpdate | OpDelete):
  33252. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  33253. default:
  33254. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33255. }
  33256. }
  33257. // SetCreatedAt sets the "created_at" field.
  33258. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  33259. m.created_at = &t
  33260. }
  33261. // CreatedAt returns the value of the "created_at" field in the mutation.
  33262. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  33263. v := m.created_at
  33264. if v == nil {
  33265. return
  33266. }
  33267. return *v, true
  33268. }
  33269. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  33270. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33272. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33273. if !m.op.Is(OpUpdateOne) {
  33274. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33275. }
  33276. if m.id == nil || m.oldValue == nil {
  33277. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33278. }
  33279. oldValue, err := m.oldValue(ctx)
  33280. if err != nil {
  33281. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33282. }
  33283. return oldValue.CreatedAt, nil
  33284. }
  33285. // ResetCreatedAt resets all changes to the "created_at" field.
  33286. func (m *WxCardMutation) ResetCreatedAt() {
  33287. m.created_at = nil
  33288. }
  33289. // SetUpdatedAt sets the "updated_at" field.
  33290. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  33291. m.updated_at = &t
  33292. }
  33293. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33294. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  33295. v := m.updated_at
  33296. if v == nil {
  33297. return
  33298. }
  33299. return *v, true
  33300. }
  33301. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  33302. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33304. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33305. if !m.op.Is(OpUpdateOne) {
  33306. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33307. }
  33308. if m.id == nil || m.oldValue == nil {
  33309. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33310. }
  33311. oldValue, err := m.oldValue(ctx)
  33312. if err != nil {
  33313. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33314. }
  33315. return oldValue.UpdatedAt, nil
  33316. }
  33317. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33318. func (m *WxCardMutation) ResetUpdatedAt() {
  33319. m.updated_at = nil
  33320. }
  33321. // SetDeletedAt sets the "deleted_at" field.
  33322. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  33323. m.deleted_at = &t
  33324. }
  33325. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33326. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  33327. v := m.deleted_at
  33328. if v == nil {
  33329. return
  33330. }
  33331. return *v, true
  33332. }
  33333. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  33334. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33336. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33337. if !m.op.Is(OpUpdateOne) {
  33338. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33339. }
  33340. if m.id == nil || m.oldValue == nil {
  33341. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33342. }
  33343. oldValue, err := m.oldValue(ctx)
  33344. if err != nil {
  33345. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33346. }
  33347. return oldValue.DeletedAt, nil
  33348. }
  33349. // ClearDeletedAt clears the value of the "deleted_at" field.
  33350. func (m *WxCardMutation) ClearDeletedAt() {
  33351. m.deleted_at = nil
  33352. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  33353. }
  33354. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33355. func (m *WxCardMutation) DeletedAtCleared() bool {
  33356. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  33357. return ok
  33358. }
  33359. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33360. func (m *WxCardMutation) ResetDeletedAt() {
  33361. m.deleted_at = nil
  33362. delete(m.clearedFields, wxcard.FieldDeletedAt)
  33363. }
  33364. // SetUserID sets the "user_id" field.
  33365. func (m *WxCardMutation) SetUserID(u uint64) {
  33366. m.user_id = &u
  33367. m.adduser_id = nil
  33368. }
  33369. // UserID returns the value of the "user_id" field in the mutation.
  33370. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  33371. v := m.user_id
  33372. if v == nil {
  33373. return
  33374. }
  33375. return *v, true
  33376. }
  33377. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  33378. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33380. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  33381. if !m.op.Is(OpUpdateOne) {
  33382. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  33383. }
  33384. if m.id == nil || m.oldValue == nil {
  33385. return v, errors.New("OldUserID requires an ID field in the mutation")
  33386. }
  33387. oldValue, err := m.oldValue(ctx)
  33388. if err != nil {
  33389. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  33390. }
  33391. return oldValue.UserID, nil
  33392. }
  33393. // AddUserID adds u to the "user_id" field.
  33394. func (m *WxCardMutation) AddUserID(u int64) {
  33395. if m.adduser_id != nil {
  33396. *m.adduser_id += u
  33397. } else {
  33398. m.adduser_id = &u
  33399. }
  33400. }
  33401. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  33402. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  33403. v := m.adduser_id
  33404. if v == nil {
  33405. return
  33406. }
  33407. return *v, true
  33408. }
  33409. // ClearUserID clears the value of the "user_id" field.
  33410. func (m *WxCardMutation) ClearUserID() {
  33411. m.user_id = nil
  33412. m.adduser_id = nil
  33413. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  33414. }
  33415. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  33416. func (m *WxCardMutation) UserIDCleared() bool {
  33417. _, ok := m.clearedFields[wxcard.FieldUserID]
  33418. return ok
  33419. }
  33420. // ResetUserID resets all changes to the "user_id" field.
  33421. func (m *WxCardMutation) ResetUserID() {
  33422. m.user_id = nil
  33423. m.adduser_id = nil
  33424. delete(m.clearedFields, wxcard.FieldUserID)
  33425. }
  33426. // SetWxUserID sets the "wx_user_id" field.
  33427. func (m *WxCardMutation) SetWxUserID(u uint64) {
  33428. m.wx_user_id = &u
  33429. m.addwx_user_id = nil
  33430. }
  33431. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  33432. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  33433. v := m.wx_user_id
  33434. if v == nil {
  33435. return
  33436. }
  33437. return *v, true
  33438. }
  33439. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  33440. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33442. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  33443. if !m.op.Is(OpUpdateOne) {
  33444. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  33445. }
  33446. if m.id == nil || m.oldValue == nil {
  33447. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  33448. }
  33449. oldValue, err := m.oldValue(ctx)
  33450. if err != nil {
  33451. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  33452. }
  33453. return oldValue.WxUserID, nil
  33454. }
  33455. // AddWxUserID adds u to the "wx_user_id" field.
  33456. func (m *WxCardMutation) AddWxUserID(u int64) {
  33457. if m.addwx_user_id != nil {
  33458. *m.addwx_user_id += u
  33459. } else {
  33460. m.addwx_user_id = &u
  33461. }
  33462. }
  33463. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  33464. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  33465. v := m.addwx_user_id
  33466. if v == nil {
  33467. return
  33468. }
  33469. return *v, true
  33470. }
  33471. // ClearWxUserID clears the value of the "wx_user_id" field.
  33472. func (m *WxCardMutation) ClearWxUserID() {
  33473. m.wx_user_id = nil
  33474. m.addwx_user_id = nil
  33475. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  33476. }
  33477. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  33478. func (m *WxCardMutation) WxUserIDCleared() bool {
  33479. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  33480. return ok
  33481. }
  33482. // ResetWxUserID resets all changes to the "wx_user_id" field.
  33483. func (m *WxCardMutation) ResetWxUserID() {
  33484. m.wx_user_id = nil
  33485. m.addwx_user_id = nil
  33486. delete(m.clearedFields, wxcard.FieldWxUserID)
  33487. }
  33488. // SetAvatar sets the "avatar" field.
  33489. func (m *WxCardMutation) SetAvatar(s string) {
  33490. m.avatar = &s
  33491. }
  33492. // Avatar returns the value of the "avatar" field in the mutation.
  33493. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  33494. v := m.avatar
  33495. if v == nil {
  33496. return
  33497. }
  33498. return *v, true
  33499. }
  33500. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  33501. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33503. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  33504. if !m.op.Is(OpUpdateOne) {
  33505. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  33506. }
  33507. if m.id == nil || m.oldValue == nil {
  33508. return v, errors.New("OldAvatar requires an ID field in the mutation")
  33509. }
  33510. oldValue, err := m.oldValue(ctx)
  33511. if err != nil {
  33512. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  33513. }
  33514. return oldValue.Avatar, nil
  33515. }
  33516. // ResetAvatar resets all changes to the "avatar" field.
  33517. func (m *WxCardMutation) ResetAvatar() {
  33518. m.avatar = nil
  33519. }
  33520. // SetLogo sets the "logo" field.
  33521. func (m *WxCardMutation) SetLogo(s string) {
  33522. m.logo = &s
  33523. }
  33524. // Logo returns the value of the "logo" field in the mutation.
  33525. func (m *WxCardMutation) Logo() (r string, exists bool) {
  33526. v := m.logo
  33527. if v == nil {
  33528. return
  33529. }
  33530. return *v, true
  33531. }
  33532. // OldLogo returns the old "logo" field's value of the WxCard entity.
  33533. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33535. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  33536. if !m.op.Is(OpUpdateOne) {
  33537. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  33538. }
  33539. if m.id == nil || m.oldValue == nil {
  33540. return v, errors.New("OldLogo requires an ID field in the mutation")
  33541. }
  33542. oldValue, err := m.oldValue(ctx)
  33543. if err != nil {
  33544. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  33545. }
  33546. return oldValue.Logo, nil
  33547. }
  33548. // ResetLogo resets all changes to the "logo" field.
  33549. func (m *WxCardMutation) ResetLogo() {
  33550. m.logo = nil
  33551. }
  33552. // SetName sets the "name" field.
  33553. func (m *WxCardMutation) SetName(s string) {
  33554. m.name = &s
  33555. }
  33556. // Name returns the value of the "name" field in the mutation.
  33557. func (m *WxCardMutation) Name() (r string, exists bool) {
  33558. v := m.name
  33559. if v == nil {
  33560. return
  33561. }
  33562. return *v, true
  33563. }
  33564. // OldName returns the old "name" field's value of the WxCard entity.
  33565. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33567. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  33568. if !m.op.Is(OpUpdateOne) {
  33569. return v, errors.New("OldName is only allowed on UpdateOne operations")
  33570. }
  33571. if m.id == nil || m.oldValue == nil {
  33572. return v, errors.New("OldName requires an ID field in the mutation")
  33573. }
  33574. oldValue, err := m.oldValue(ctx)
  33575. if err != nil {
  33576. return v, fmt.Errorf("querying old value for OldName: %w", err)
  33577. }
  33578. return oldValue.Name, nil
  33579. }
  33580. // ResetName resets all changes to the "name" field.
  33581. func (m *WxCardMutation) ResetName() {
  33582. m.name = nil
  33583. }
  33584. // SetCompany sets the "company" field.
  33585. func (m *WxCardMutation) SetCompany(s string) {
  33586. m.company = &s
  33587. }
  33588. // Company returns the value of the "company" field in the mutation.
  33589. func (m *WxCardMutation) Company() (r string, exists bool) {
  33590. v := m.company
  33591. if v == nil {
  33592. return
  33593. }
  33594. return *v, true
  33595. }
  33596. // OldCompany returns the old "company" field's value of the WxCard entity.
  33597. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33599. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  33600. if !m.op.Is(OpUpdateOne) {
  33601. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  33602. }
  33603. if m.id == nil || m.oldValue == nil {
  33604. return v, errors.New("OldCompany requires an ID field in the mutation")
  33605. }
  33606. oldValue, err := m.oldValue(ctx)
  33607. if err != nil {
  33608. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  33609. }
  33610. return oldValue.Company, nil
  33611. }
  33612. // ResetCompany resets all changes to the "company" field.
  33613. func (m *WxCardMutation) ResetCompany() {
  33614. m.company = nil
  33615. }
  33616. // SetAddress sets the "address" field.
  33617. func (m *WxCardMutation) SetAddress(s string) {
  33618. m.address = &s
  33619. }
  33620. // Address returns the value of the "address" field in the mutation.
  33621. func (m *WxCardMutation) Address() (r string, exists bool) {
  33622. v := m.address
  33623. if v == nil {
  33624. return
  33625. }
  33626. return *v, true
  33627. }
  33628. // OldAddress returns the old "address" field's value of the WxCard entity.
  33629. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33631. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  33632. if !m.op.Is(OpUpdateOne) {
  33633. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  33634. }
  33635. if m.id == nil || m.oldValue == nil {
  33636. return v, errors.New("OldAddress requires an ID field in the mutation")
  33637. }
  33638. oldValue, err := m.oldValue(ctx)
  33639. if err != nil {
  33640. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  33641. }
  33642. return oldValue.Address, nil
  33643. }
  33644. // ResetAddress resets all changes to the "address" field.
  33645. func (m *WxCardMutation) ResetAddress() {
  33646. m.address = nil
  33647. }
  33648. // SetPhone sets the "phone" field.
  33649. func (m *WxCardMutation) SetPhone(s string) {
  33650. m.phone = &s
  33651. }
  33652. // Phone returns the value of the "phone" field in the mutation.
  33653. func (m *WxCardMutation) Phone() (r string, exists bool) {
  33654. v := m.phone
  33655. if v == nil {
  33656. return
  33657. }
  33658. return *v, true
  33659. }
  33660. // OldPhone returns the old "phone" field's value of the WxCard entity.
  33661. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33663. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  33664. if !m.op.Is(OpUpdateOne) {
  33665. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  33666. }
  33667. if m.id == nil || m.oldValue == nil {
  33668. return v, errors.New("OldPhone requires an ID field in the mutation")
  33669. }
  33670. oldValue, err := m.oldValue(ctx)
  33671. if err != nil {
  33672. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  33673. }
  33674. return oldValue.Phone, nil
  33675. }
  33676. // ResetPhone resets all changes to the "phone" field.
  33677. func (m *WxCardMutation) ResetPhone() {
  33678. m.phone = nil
  33679. }
  33680. // SetOfficialAccount sets the "official_account" field.
  33681. func (m *WxCardMutation) SetOfficialAccount(s string) {
  33682. m.official_account = &s
  33683. }
  33684. // OfficialAccount returns the value of the "official_account" field in the mutation.
  33685. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  33686. v := m.official_account
  33687. if v == nil {
  33688. return
  33689. }
  33690. return *v, true
  33691. }
  33692. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  33693. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33695. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  33696. if !m.op.Is(OpUpdateOne) {
  33697. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  33698. }
  33699. if m.id == nil || m.oldValue == nil {
  33700. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  33701. }
  33702. oldValue, err := m.oldValue(ctx)
  33703. if err != nil {
  33704. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  33705. }
  33706. return oldValue.OfficialAccount, nil
  33707. }
  33708. // ResetOfficialAccount resets all changes to the "official_account" field.
  33709. func (m *WxCardMutation) ResetOfficialAccount() {
  33710. m.official_account = nil
  33711. }
  33712. // SetWechatAccount sets the "wechat_account" field.
  33713. func (m *WxCardMutation) SetWechatAccount(s string) {
  33714. m.wechat_account = &s
  33715. }
  33716. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  33717. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  33718. v := m.wechat_account
  33719. if v == nil {
  33720. return
  33721. }
  33722. return *v, true
  33723. }
  33724. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  33725. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33727. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  33728. if !m.op.Is(OpUpdateOne) {
  33729. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  33730. }
  33731. if m.id == nil || m.oldValue == nil {
  33732. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  33733. }
  33734. oldValue, err := m.oldValue(ctx)
  33735. if err != nil {
  33736. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  33737. }
  33738. return oldValue.WechatAccount, nil
  33739. }
  33740. // ResetWechatAccount resets all changes to the "wechat_account" field.
  33741. func (m *WxCardMutation) ResetWechatAccount() {
  33742. m.wechat_account = nil
  33743. }
  33744. // SetEmail sets the "email" field.
  33745. func (m *WxCardMutation) SetEmail(s string) {
  33746. m.email = &s
  33747. }
  33748. // Email returns the value of the "email" field in the mutation.
  33749. func (m *WxCardMutation) Email() (r string, exists bool) {
  33750. v := m.email
  33751. if v == nil {
  33752. return
  33753. }
  33754. return *v, true
  33755. }
  33756. // OldEmail returns the old "email" field's value of the WxCard entity.
  33757. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33759. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  33760. if !m.op.Is(OpUpdateOne) {
  33761. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  33762. }
  33763. if m.id == nil || m.oldValue == nil {
  33764. return v, errors.New("OldEmail requires an ID field in the mutation")
  33765. }
  33766. oldValue, err := m.oldValue(ctx)
  33767. if err != nil {
  33768. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  33769. }
  33770. return oldValue.Email, nil
  33771. }
  33772. // ClearEmail clears the value of the "email" field.
  33773. func (m *WxCardMutation) ClearEmail() {
  33774. m.email = nil
  33775. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  33776. }
  33777. // EmailCleared returns if the "email" field was cleared in this mutation.
  33778. func (m *WxCardMutation) EmailCleared() bool {
  33779. _, ok := m.clearedFields[wxcard.FieldEmail]
  33780. return ok
  33781. }
  33782. // ResetEmail resets all changes to the "email" field.
  33783. func (m *WxCardMutation) ResetEmail() {
  33784. m.email = nil
  33785. delete(m.clearedFields, wxcard.FieldEmail)
  33786. }
  33787. // SetAPIBase sets the "api_base" field.
  33788. func (m *WxCardMutation) SetAPIBase(s string) {
  33789. m.api_base = &s
  33790. }
  33791. // APIBase returns the value of the "api_base" field in the mutation.
  33792. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  33793. v := m.api_base
  33794. if v == nil {
  33795. return
  33796. }
  33797. return *v, true
  33798. }
  33799. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  33800. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33802. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  33803. if !m.op.Is(OpUpdateOne) {
  33804. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  33805. }
  33806. if m.id == nil || m.oldValue == nil {
  33807. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  33808. }
  33809. oldValue, err := m.oldValue(ctx)
  33810. if err != nil {
  33811. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  33812. }
  33813. return oldValue.APIBase, nil
  33814. }
  33815. // ClearAPIBase clears the value of the "api_base" field.
  33816. func (m *WxCardMutation) ClearAPIBase() {
  33817. m.api_base = nil
  33818. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  33819. }
  33820. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  33821. func (m *WxCardMutation) APIBaseCleared() bool {
  33822. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  33823. return ok
  33824. }
  33825. // ResetAPIBase resets all changes to the "api_base" field.
  33826. func (m *WxCardMutation) ResetAPIBase() {
  33827. m.api_base = nil
  33828. delete(m.clearedFields, wxcard.FieldAPIBase)
  33829. }
  33830. // SetAPIKey sets the "api_key" field.
  33831. func (m *WxCardMutation) SetAPIKey(s string) {
  33832. m.api_key = &s
  33833. }
  33834. // APIKey returns the value of the "api_key" field in the mutation.
  33835. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  33836. v := m.api_key
  33837. if v == nil {
  33838. return
  33839. }
  33840. return *v, true
  33841. }
  33842. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  33843. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33845. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  33846. if !m.op.Is(OpUpdateOne) {
  33847. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  33848. }
  33849. if m.id == nil || m.oldValue == nil {
  33850. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  33851. }
  33852. oldValue, err := m.oldValue(ctx)
  33853. if err != nil {
  33854. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  33855. }
  33856. return oldValue.APIKey, nil
  33857. }
  33858. // ClearAPIKey clears the value of the "api_key" field.
  33859. func (m *WxCardMutation) ClearAPIKey() {
  33860. m.api_key = nil
  33861. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  33862. }
  33863. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  33864. func (m *WxCardMutation) APIKeyCleared() bool {
  33865. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  33866. return ok
  33867. }
  33868. // ResetAPIKey resets all changes to the "api_key" field.
  33869. func (m *WxCardMutation) ResetAPIKey() {
  33870. m.api_key = nil
  33871. delete(m.clearedFields, wxcard.FieldAPIKey)
  33872. }
  33873. // SetAiInfo sets the "ai_info" field.
  33874. func (m *WxCardMutation) SetAiInfo(s string) {
  33875. m.ai_info = &s
  33876. }
  33877. // AiInfo returns the value of the "ai_info" field in the mutation.
  33878. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  33879. v := m.ai_info
  33880. if v == nil {
  33881. return
  33882. }
  33883. return *v, true
  33884. }
  33885. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  33886. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33888. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  33889. if !m.op.Is(OpUpdateOne) {
  33890. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  33891. }
  33892. if m.id == nil || m.oldValue == nil {
  33893. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  33894. }
  33895. oldValue, err := m.oldValue(ctx)
  33896. if err != nil {
  33897. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  33898. }
  33899. return oldValue.AiInfo, nil
  33900. }
  33901. // ClearAiInfo clears the value of the "ai_info" field.
  33902. func (m *WxCardMutation) ClearAiInfo() {
  33903. m.ai_info = nil
  33904. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  33905. }
  33906. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  33907. func (m *WxCardMutation) AiInfoCleared() bool {
  33908. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  33909. return ok
  33910. }
  33911. // ResetAiInfo resets all changes to the "ai_info" field.
  33912. func (m *WxCardMutation) ResetAiInfo() {
  33913. m.ai_info = nil
  33914. delete(m.clearedFields, wxcard.FieldAiInfo)
  33915. }
  33916. // SetIntro sets the "intro" field.
  33917. func (m *WxCardMutation) SetIntro(s string) {
  33918. m.intro = &s
  33919. }
  33920. // Intro returns the value of the "intro" field in the mutation.
  33921. func (m *WxCardMutation) Intro() (r string, exists bool) {
  33922. v := m.intro
  33923. if v == nil {
  33924. return
  33925. }
  33926. return *v, true
  33927. }
  33928. // OldIntro returns the old "intro" field's value of the WxCard entity.
  33929. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  33930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33931. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  33932. if !m.op.Is(OpUpdateOne) {
  33933. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  33934. }
  33935. if m.id == nil || m.oldValue == nil {
  33936. return v, errors.New("OldIntro requires an ID field in the mutation")
  33937. }
  33938. oldValue, err := m.oldValue(ctx)
  33939. if err != nil {
  33940. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  33941. }
  33942. return oldValue.Intro, nil
  33943. }
  33944. // ClearIntro clears the value of the "intro" field.
  33945. func (m *WxCardMutation) ClearIntro() {
  33946. m.intro = nil
  33947. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  33948. }
  33949. // IntroCleared returns if the "intro" field was cleared in this mutation.
  33950. func (m *WxCardMutation) IntroCleared() bool {
  33951. _, ok := m.clearedFields[wxcard.FieldIntro]
  33952. return ok
  33953. }
  33954. // ResetIntro resets all changes to the "intro" field.
  33955. func (m *WxCardMutation) ResetIntro() {
  33956. m.intro = nil
  33957. delete(m.clearedFields, wxcard.FieldIntro)
  33958. }
  33959. // Where appends a list predicates to the WxCardMutation builder.
  33960. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  33961. m.predicates = append(m.predicates, ps...)
  33962. }
  33963. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  33964. // users can use type-assertion to append predicates that do not depend on any generated package.
  33965. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  33966. p := make([]predicate.WxCard, len(ps))
  33967. for i := range ps {
  33968. p[i] = ps[i]
  33969. }
  33970. m.Where(p...)
  33971. }
  33972. // Op returns the operation name.
  33973. func (m *WxCardMutation) Op() Op {
  33974. return m.op
  33975. }
  33976. // SetOp allows setting the mutation operation.
  33977. func (m *WxCardMutation) SetOp(op Op) {
  33978. m.op = op
  33979. }
  33980. // Type returns the node type of this mutation (WxCard).
  33981. func (m *WxCardMutation) Type() string {
  33982. return m.typ
  33983. }
  33984. // Fields returns all fields that were changed during this mutation. Note that in
  33985. // order to get all numeric fields that were incremented/decremented, call
  33986. // AddedFields().
  33987. func (m *WxCardMutation) Fields() []string {
  33988. fields := make([]string, 0, 18)
  33989. if m.created_at != nil {
  33990. fields = append(fields, wxcard.FieldCreatedAt)
  33991. }
  33992. if m.updated_at != nil {
  33993. fields = append(fields, wxcard.FieldUpdatedAt)
  33994. }
  33995. if m.deleted_at != nil {
  33996. fields = append(fields, wxcard.FieldDeletedAt)
  33997. }
  33998. if m.user_id != nil {
  33999. fields = append(fields, wxcard.FieldUserID)
  34000. }
  34001. if m.wx_user_id != nil {
  34002. fields = append(fields, wxcard.FieldWxUserID)
  34003. }
  34004. if m.avatar != nil {
  34005. fields = append(fields, wxcard.FieldAvatar)
  34006. }
  34007. if m.logo != nil {
  34008. fields = append(fields, wxcard.FieldLogo)
  34009. }
  34010. if m.name != nil {
  34011. fields = append(fields, wxcard.FieldName)
  34012. }
  34013. if m.company != nil {
  34014. fields = append(fields, wxcard.FieldCompany)
  34015. }
  34016. if m.address != nil {
  34017. fields = append(fields, wxcard.FieldAddress)
  34018. }
  34019. if m.phone != nil {
  34020. fields = append(fields, wxcard.FieldPhone)
  34021. }
  34022. if m.official_account != nil {
  34023. fields = append(fields, wxcard.FieldOfficialAccount)
  34024. }
  34025. if m.wechat_account != nil {
  34026. fields = append(fields, wxcard.FieldWechatAccount)
  34027. }
  34028. if m.email != nil {
  34029. fields = append(fields, wxcard.FieldEmail)
  34030. }
  34031. if m.api_base != nil {
  34032. fields = append(fields, wxcard.FieldAPIBase)
  34033. }
  34034. if m.api_key != nil {
  34035. fields = append(fields, wxcard.FieldAPIKey)
  34036. }
  34037. if m.ai_info != nil {
  34038. fields = append(fields, wxcard.FieldAiInfo)
  34039. }
  34040. if m.intro != nil {
  34041. fields = append(fields, wxcard.FieldIntro)
  34042. }
  34043. return fields
  34044. }
  34045. // Field returns the value of a field with the given name. The second boolean
  34046. // return value indicates that this field was not set, or was not defined in the
  34047. // schema.
  34048. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  34049. switch name {
  34050. case wxcard.FieldCreatedAt:
  34051. return m.CreatedAt()
  34052. case wxcard.FieldUpdatedAt:
  34053. return m.UpdatedAt()
  34054. case wxcard.FieldDeletedAt:
  34055. return m.DeletedAt()
  34056. case wxcard.FieldUserID:
  34057. return m.UserID()
  34058. case wxcard.FieldWxUserID:
  34059. return m.WxUserID()
  34060. case wxcard.FieldAvatar:
  34061. return m.Avatar()
  34062. case wxcard.FieldLogo:
  34063. return m.Logo()
  34064. case wxcard.FieldName:
  34065. return m.Name()
  34066. case wxcard.FieldCompany:
  34067. return m.Company()
  34068. case wxcard.FieldAddress:
  34069. return m.Address()
  34070. case wxcard.FieldPhone:
  34071. return m.Phone()
  34072. case wxcard.FieldOfficialAccount:
  34073. return m.OfficialAccount()
  34074. case wxcard.FieldWechatAccount:
  34075. return m.WechatAccount()
  34076. case wxcard.FieldEmail:
  34077. return m.Email()
  34078. case wxcard.FieldAPIBase:
  34079. return m.APIBase()
  34080. case wxcard.FieldAPIKey:
  34081. return m.APIKey()
  34082. case wxcard.FieldAiInfo:
  34083. return m.AiInfo()
  34084. case wxcard.FieldIntro:
  34085. return m.Intro()
  34086. }
  34087. return nil, false
  34088. }
  34089. // OldField returns the old value of the field from the database. An error is
  34090. // returned if the mutation operation is not UpdateOne, or the query to the
  34091. // database failed.
  34092. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34093. switch name {
  34094. case wxcard.FieldCreatedAt:
  34095. return m.OldCreatedAt(ctx)
  34096. case wxcard.FieldUpdatedAt:
  34097. return m.OldUpdatedAt(ctx)
  34098. case wxcard.FieldDeletedAt:
  34099. return m.OldDeletedAt(ctx)
  34100. case wxcard.FieldUserID:
  34101. return m.OldUserID(ctx)
  34102. case wxcard.FieldWxUserID:
  34103. return m.OldWxUserID(ctx)
  34104. case wxcard.FieldAvatar:
  34105. return m.OldAvatar(ctx)
  34106. case wxcard.FieldLogo:
  34107. return m.OldLogo(ctx)
  34108. case wxcard.FieldName:
  34109. return m.OldName(ctx)
  34110. case wxcard.FieldCompany:
  34111. return m.OldCompany(ctx)
  34112. case wxcard.FieldAddress:
  34113. return m.OldAddress(ctx)
  34114. case wxcard.FieldPhone:
  34115. return m.OldPhone(ctx)
  34116. case wxcard.FieldOfficialAccount:
  34117. return m.OldOfficialAccount(ctx)
  34118. case wxcard.FieldWechatAccount:
  34119. return m.OldWechatAccount(ctx)
  34120. case wxcard.FieldEmail:
  34121. return m.OldEmail(ctx)
  34122. case wxcard.FieldAPIBase:
  34123. return m.OldAPIBase(ctx)
  34124. case wxcard.FieldAPIKey:
  34125. return m.OldAPIKey(ctx)
  34126. case wxcard.FieldAiInfo:
  34127. return m.OldAiInfo(ctx)
  34128. case wxcard.FieldIntro:
  34129. return m.OldIntro(ctx)
  34130. }
  34131. return nil, fmt.Errorf("unknown WxCard field %s", name)
  34132. }
  34133. // SetField sets the value of a field with the given name. It returns an error if
  34134. // the field is not defined in the schema, or if the type mismatched the field
  34135. // type.
  34136. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  34137. switch name {
  34138. case wxcard.FieldCreatedAt:
  34139. v, ok := value.(time.Time)
  34140. if !ok {
  34141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34142. }
  34143. m.SetCreatedAt(v)
  34144. return nil
  34145. case wxcard.FieldUpdatedAt:
  34146. v, ok := value.(time.Time)
  34147. if !ok {
  34148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34149. }
  34150. m.SetUpdatedAt(v)
  34151. return nil
  34152. case wxcard.FieldDeletedAt:
  34153. v, ok := value.(time.Time)
  34154. if !ok {
  34155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34156. }
  34157. m.SetDeletedAt(v)
  34158. return nil
  34159. case wxcard.FieldUserID:
  34160. v, ok := value.(uint64)
  34161. if !ok {
  34162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34163. }
  34164. m.SetUserID(v)
  34165. return nil
  34166. case wxcard.FieldWxUserID:
  34167. v, ok := value.(uint64)
  34168. if !ok {
  34169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34170. }
  34171. m.SetWxUserID(v)
  34172. return nil
  34173. case wxcard.FieldAvatar:
  34174. v, ok := value.(string)
  34175. if !ok {
  34176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34177. }
  34178. m.SetAvatar(v)
  34179. return nil
  34180. case wxcard.FieldLogo:
  34181. v, ok := value.(string)
  34182. if !ok {
  34183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34184. }
  34185. m.SetLogo(v)
  34186. return nil
  34187. case wxcard.FieldName:
  34188. v, ok := value.(string)
  34189. if !ok {
  34190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34191. }
  34192. m.SetName(v)
  34193. return nil
  34194. case wxcard.FieldCompany:
  34195. v, ok := value.(string)
  34196. if !ok {
  34197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34198. }
  34199. m.SetCompany(v)
  34200. return nil
  34201. case wxcard.FieldAddress:
  34202. v, ok := value.(string)
  34203. if !ok {
  34204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34205. }
  34206. m.SetAddress(v)
  34207. return nil
  34208. case wxcard.FieldPhone:
  34209. v, ok := value.(string)
  34210. if !ok {
  34211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34212. }
  34213. m.SetPhone(v)
  34214. return nil
  34215. case wxcard.FieldOfficialAccount:
  34216. v, ok := value.(string)
  34217. if !ok {
  34218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34219. }
  34220. m.SetOfficialAccount(v)
  34221. return nil
  34222. case wxcard.FieldWechatAccount:
  34223. v, ok := value.(string)
  34224. if !ok {
  34225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34226. }
  34227. m.SetWechatAccount(v)
  34228. return nil
  34229. case wxcard.FieldEmail:
  34230. v, ok := value.(string)
  34231. if !ok {
  34232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34233. }
  34234. m.SetEmail(v)
  34235. return nil
  34236. case wxcard.FieldAPIBase:
  34237. v, ok := value.(string)
  34238. if !ok {
  34239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34240. }
  34241. m.SetAPIBase(v)
  34242. return nil
  34243. case wxcard.FieldAPIKey:
  34244. v, ok := value.(string)
  34245. if !ok {
  34246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34247. }
  34248. m.SetAPIKey(v)
  34249. return nil
  34250. case wxcard.FieldAiInfo:
  34251. v, ok := value.(string)
  34252. if !ok {
  34253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34254. }
  34255. m.SetAiInfo(v)
  34256. return nil
  34257. case wxcard.FieldIntro:
  34258. v, ok := value.(string)
  34259. if !ok {
  34260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34261. }
  34262. m.SetIntro(v)
  34263. return nil
  34264. }
  34265. return fmt.Errorf("unknown WxCard field %s", name)
  34266. }
  34267. // AddedFields returns all numeric fields that were incremented/decremented during
  34268. // this mutation.
  34269. func (m *WxCardMutation) AddedFields() []string {
  34270. var fields []string
  34271. if m.adduser_id != nil {
  34272. fields = append(fields, wxcard.FieldUserID)
  34273. }
  34274. if m.addwx_user_id != nil {
  34275. fields = append(fields, wxcard.FieldWxUserID)
  34276. }
  34277. return fields
  34278. }
  34279. // AddedField returns the numeric value that was incremented/decremented on a field
  34280. // with the given name. The second boolean return value indicates that this field
  34281. // was not set, or was not defined in the schema.
  34282. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  34283. switch name {
  34284. case wxcard.FieldUserID:
  34285. return m.AddedUserID()
  34286. case wxcard.FieldWxUserID:
  34287. return m.AddedWxUserID()
  34288. }
  34289. return nil, false
  34290. }
  34291. // AddField adds the value to the field with the given name. It returns an error if
  34292. // the field is not defined in the schema, or if the type mismatched the field
  34293. // type.
  34294. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  34295. switch name {
  34296. case wxcard.FieldUserID:
  34297. v, ok := value.(int64)
  34298. if !ok {
  34299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34300. }
  34301. m.AddUserID(v)
  34302. return nil
  34303. case wxcard.FieldWxUserID:
  34304. v, ok := value.(int64)
  34305. if !ok {
  34306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34307. }
  34308. m.AddWxUserID(v)
  34309. return nil
  34310. }
  34311. return fmt.Errorf("unknown WxCard numeric field %s", name)
  34312. }
  34313. // ClearedFields returns all nullable fields that were cleared during this
  34314. // mutation.
  34315. func (m *WxCardMutation) ClearedFields() []string {
  34316. var fields []string
  34317. if m.FieldCleared(wxcard.FieldDeletedAt) {
  34318. fields = append(fields, wxcard.FieldDeletedAt)
  34319. }
  34320. if m.FieldCleared(wxcard.FieldUserID) {
  34321. fields = append(fields, wxcard.FieldUserID)
  34322. }
  34323. if m.FieldCleared(wxcard.FieldWxUserID) {
  34324. fields = append(fields, wxcard.FieldWxUserID)
  34325. }
  34326. if m.FieldCleared(wxcard.FieldEmail) {
  34327. fields = append(fields, wxcard.FieldEmail)
  34328. }
  34329. if m.FieldCleared(wxcard.FieldAPIBase) {
  34330. fields = append(fields, wxcard.FieldAPIBase)
  34331. }
  34332. if m.FieldCleared(wxcard.FieldAPIKey) {
  34333. fields = append(fields, wxcard.FieldAPIKey)
  34334. }
  34335. if m.FieldCleared(wxcard.FieldAiInfo) {
  34336. fields = append(fields, wxcard.FieldAiInfo)
  34337. }
  34338. if m.FieldCleared(wxcard.FieldIntro) {
  34339. fields = append(fields, wxcard.FieldIntro)
  34340. }
  34341. return fields
  34342. }
  34343. // FieldCleared returns a boolean indicating if a field with the given name was
  34344. // cleared in this mutation.
  34345. func (m *WxCardMutation) FieldCleared(name string) bool {
  34346. _, ok := m.clearedFields[name]
  34347. return ok
  34348. }
  34349. // ClearField clears the value of the field with the given name. It returns an
  34350. // error if the field is not defined in the schema.
  34351. func (m *WxCardMutation) ClearField(name string) error {
  34352. switch name {
  34353. case wxcard.FieldDeletedAt:
  34354. m.ClearDeletedAt()
  34355. return nil
  34356. case wxcard.FieldUserID:
  34357. m.ClearUserID()
  34358. return nil
  34359. case wxcard.FieldWxUserID:
  34360. m.ClearWxUserID()
  34361. return nil
  34362. case wxcard.FieldEmail:
  34363. m.ClearEmail()
  34364. return nil
  34365. case wxcard.FieldAPIBase:
  34366. m.ClearAPIBase()
  34367. return nil
  34368. case wxcard.FieldAPIKey:
  34369. m.ClearAPIKey()
  34370. return nil
  34371. case wxcard.FieldAiInfo:
  34372. m.ClearAiInfo()
  34373. return nil
  34374. case wxcard.FieldIntro:
  34375. m.ClearIntro()
  34376. return nil
  34377. }
  34378. return fmt.Errorf("unknown WxCard nullable field %s", name)
  34379. }
  34380. // ResetField resets all changes in the mutation for the field with the given name.
  34381. // It returns an error if the field is not defined in the schema.
  34382. func (m *WxCardMutation) ResetField(name string) error {
  34383. switch name {
  34384. case wxcard.FieldCreatedAt:
  34385. m.ResetCreatedAt()
  34386. return nil
  34387. case wxcard.FieldUpdatedAt:
  34388. m.ResetUpdatedAt()
  34389. return nil
  34390. case wxcard.FieldDeletedAt:
  34391. m.ResetDeletedAt()
  34392. return nil
  34393. case wxcard.FieldUserID:
  34394. m.ResetUserID()
  34395. return nil
  34396. case wxcard.FieldWxUserID:
  34397. m.ResetWxUserID()
  34398. return nil
  34399. case wxcard.FieldAvatar:
  34400. m.ResetAvatar()
  34401. return nil
  34402. case wxcard.FieldLogo:
  34403. m.ResetLogo()
  34404. return nil
  34405. case wxcard.FieldName:
  34406. m.ResetName()
  34407. return nil
  34408. case wxcard.FieldCompany:
  34409. m.ResetCompany()
  34410. return nil
  34411. case wxcard.FieldAddress:
  34412. m.ResetAddress()
  34413. return nil
  34414. case wxcard.FieldPhone:
  34415. m.ResetPhone()
  34416. return nil
  34417. case wxcard.FieldOfficialAccount:
  34418. m.ResetOfficialAccount()
  34419. return nil
  34420. case wxcard.FieldWechatAccount:
  34421. m.ResetWechatAccount()
  34422. return nil
  34423. case wxcard.FieldEmail:
  34424. m.ResetEmail()
  34425. return nil
  34426. case wxcard.FieldAPIBase:
  34427. m.ResetAPIBase()
  34428. return nil
  34429. case wxcard.FieldAPIKey:
  34430. m.ResetAPIKey()
  34431. return nil
  34432. case wxcard.FieldAiInfo:
  34433. m.ResetAiInfo()
  34434. return nil
  34435. case wxcard.FieldIntro:
  34436. m.ResetIntro()
  34437. return nil
  34438. }
  34439. return fmt.Errorf("unknown WxCard field %s", name)
  34440. }
  34441. // AddedEdges returns all edge names that were set/added in this mutation.
  34442. func (m *WxCardMutation) AddedEdges() []string {
  34443. edges := make([]string, 0, 0)
  34444. return edges
  34445. }
  34446. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34447. // name in this mutation.
  34448. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  34449. return nil
  34450. }
  34451. // RemovedEdges returns all edge names that were removed in this mutation.
  34452. func (m *WxCardMutation) RemovedEdges() []string {
  34453. edges := make([]string, 0, 0)
  34454. return edges
  34455. }
  34456. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34457. // the given name in this mutation.
  34458. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  34459. return nil
  34460. }
  34461. // ClearedEdges returns all edge names that were cleared in this mutation.
  34462. func (m *WxCardMutation) ClearedEdges() []string {
  34463. edges := make([]string, 0, 0)
  34464. return edges
  34465. }
  34466. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34467. // was cleared in this mutation.
  34468. func (m *WxCardMutation) EdgeCleared(name string) bool {
  34469. return false
  34470. }
  34471. // ClearEdge clears the value of the edge with the given name. It returns an error
  34472. // if that edge is not defined in the schema.
  34473. func (m *WxCardMutation) ClearEdge(name string) error {
  34474. return fmt.Errorf("unknown WxCard unique edge %s", name)
  34475. }
  34476. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34477. // It returns an error if the edge is not defined in the schema.
  34478. func (m *WxCardMutation) ResetEdge(name string) error {
  34479. return fmt.Errorf("unknown WxCard edge %s", name)
  34480. }
  34481. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  34482. type WxCardUserMutation struct {
  34483. config
  34484. op Op
  34485. typ string
  34486. id *uint64
  34487. created_at *time.Time
  34488. updated_at *time.Time
  34489. deleted_at *time.Time
  34490. wxid *string
  34491. account *string
  34492. avatar *string
  34493. nickname *string
  34494. remark *string
  34495. phone *string
  34496. open_id *string
  34497. union_id *string
  34498. session_key *string
  34499. is_vip *int
  34500. addis_vip *int
  34501. clearedFields map[string]struct{}
  34502. done bool
  34503. oldValue func(context.Context) (*WxCardUser, error)
  34504. predicates []predicate.WxCardUser
  34505. }
  34506. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  34507. // wxcarduserOption allows management of the mutation configuration using functional options.
  34508. type wxcarduserOption func(*WxCardUserMutation)
  34509. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  34510. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  34511. m := &WxCardUserMutation{
  34512. config: c,
  34513. op: op,
  34514. typ: TypeWxCardUser,
  34515. clearedFields: make(map[string]struct{}),
  34516. }
  34517. for _, opt := range opts {
  34518. opt(m)
  34519. }
  34520. return m
  34521. }
  34522. // withWxCardUserID sets the ID field of the mutation.
  34523. func withWxCardUserID(id uint64) wxcarduserOption {
  34524. return func(m *WxCardUserMutation) {
  34525. var (
  34526. err error
  34527. once sync.Once
  34528. value *WxCardUser
  34529. )
  34530. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  34531. once.Do(func() {
  34532. if m.done {
  34533. err = errors.New("querying old values post mutation is not allowed")
  34534. } else {
  34535. value, err = m.Client().WxCardUser.Get(ctx, id)
  34536. }
  34537. })
  34538. return value, err
  34539. }
  34540. m.id = &id
  34541. }
  34542. }
  34543. // withWxCardUser sets the old WxCardUser of the mutation.
  34544. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  34545. return func(m *WxCardUserMutation) {
  34546. m.oldValue = func(context.Context) (*WxCardUser, error) {
  34547. return node, nil
  34548. }
  34549. m.id = &node.ID
  34550. }
  34551. }
  34552. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34553. // executed in a transaction (ent.Tx), a transactional client is returned.
  34554. func (m WxCardUserMutation) Client() *Client {
  34555. client := &Client{config: m.config}
  34556. client.init()
  34557. return client
  34558. }
  34559. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34560. // it returns an error otherwise.
  34561. func (m WxCardUserMutation) Tx() (*Tx, error) {
  34562. if _, ok := m.driver.(*txDriver); !ok {
  34563. return nil, errors.New("ent: mutation is not running in a transaction")
  34564. }
  34565. tx := &Tx{config: m.config}
  34566. tx.init()
  34567. return tx, nil
  34568. }
  34569. // SetID sets the value of the id field. Note that this
  34570. // operation is only accepted on creation of WxCardUser entities.
  34571. func (m *WxCardUserMutation) SetID(id uint64) {
  34572. m.id = &id
  34573. }
  34574. // ID returns the ID value in the mutation. Note that the ID is only available
  34575. // if it was provided to the builder or after it was returned from the database.
  34576. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  34577. if m.id == nil {
  34578. return
  34579. }
  34580. return *m.id, true
  34581. }
  34582. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34583. // That means, if the mutation is applied within a transaction with an isolation level such
  34584. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34585. // or updated by the mutation.
  34586. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  34587. switch {
  34588. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34589. id, exists := m.ID()
  34590. if exists {
  34591. return []uint64{id}, nil
  34592. }
  34593. fallthrough
  34594. case m.op.Is(OpUpdate | OpDelete):
  34595. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  34596. default:
  34597. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34598. }
  34599. }
  34600. // SetCreatedAt sets the "created_at" field.
  34601. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  34602. m.created_at = &t
  34603. }
  34604. // CreatedAt returns the value of the "created_at" field in the mutation.
  34605. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  34606. v := m.created_at
  34607. if v == nil {
  34608. return
  34609. }
  34610. return *v, true
  34611. }
  34612. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  34613. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34615. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34616. if !m.op.Is(OpUpdateOne) {
  34617. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34618. }
  34619. if m.id == nil || m.oldValue == nil {
  34620. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34621. }
  34622. oldValue, err := m.oldValue(ctx)
  34623. if err != nil {
  34624. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34625. }
  34626. return oldValue.CreatedAt, nil
  34627. }
  34628. // ResetCreatedAt resets all changes to the "created_at" field.
  34629. func (m *WxCardUserMutation) ResetCreatedAt() {
  34630. m.created_at = nil
  34631. }
  34632. // SetUpdatedAt sets the "updated_at" field.
  34633. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  34634. m.updated_at = &t
  34635. }
  34636. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34637. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  34638. v := m.updated_at
  34639. if v == nil {
  34640. return
  34641. }
  34642. return *v, true
  34643. }
  34644. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  34645. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34647. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34648. if !m.op.Is(OpUpdateOne) {
  34649. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34650. }
  34651. if m.id == nil || m.oldValue == nil {
  34652. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34653. }
  34654. oldValue, err := m.oldValue(ctx)
  34655. if err != nil {
  34656. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34657. }
  34658. return oldValue.UpdatedAt, nil
  34659. }
  34660. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34661. func (m *WxCardUserMutation) ResetUpdatedAt() {
  34662. m.updated_at = nil
  34663. }
  34664. // SetDeletedAt sets the "deleted_at" field.
  34665. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  34666. m.deleted_at = &t
  34667. }
  34668. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34669. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  34670. v := m.deleted_at
  34671. if v == nil {
  34672. return
  34673. }
  34674. return *v, true
  34675. }
  34676. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  34677. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34679. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34680. if !m.op.Is(OpUpdateOne) {
  34681. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34682. }
  34683. if m.id == nil || m.oldValue == nil {
  34684. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34685. }
  34686. oldValue, err := m.oldValue(ctx)
  34687. if err != nil {
  34688. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34689. }
  34690. return oldValue.DeletedAt, nil
  34691. }
  34692. // ClearDeletedAt clears the value of the "deleted_at" field.
  34693. func (m *WxCardUserMutation) ClearDeletedAt() {
  34694. m.deleted_at = nil
  34695. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  34696. }
  34697. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34698. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  34699. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  34700. return ok
  34701. }
  34702. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34703. func (m *WxCardUserMutation) ResetDeletedAt() {
  34704. m.deleted_at = nil
  34705. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  34706. }
  34707. // SetWxid sets the "wxid" field.
  34708. func (m *WxCardUserMutation) SetWxid(s string) {
  34709. m.wxid = &s
  34710. }
  34711. // Wxid returns the value of the "wxid" field in the mutation.
  34712. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  34713. v := m.wxid
  34714. if v == nil {
  34715. return
  34716. }
  34717. return *v, true
  34718. }
  34719. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  34720. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34722. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  34723. if !m.op.Is(OpUpdateOne) {
  34724. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  34725. }
  34726. if m.id == nil || m.oldValue == nil {
  34727. return v, errors.New("OldWxid requires an ID field in the mutation")
  34728. }
  34729. oldValue, err := m.oldValue(ctx)
  34730. if err != nil {
  34731. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  34732. }
  34733. return oldValue.Wxid, nil
  34734. }
  34735. // ResetWxid resets all changes to the "wxid" field.
  34736. func (m *WxCardUserMutation) ResetWxid() {
  34737. m.wxid = nil
  34738. }
  34739. // SetAccount sets the "account" field.
  34740. func (m *WxCardUserMutation) SetAccount(s string) {
  34741. m.account = &s
  34742. }
  34743. // Account returns the value of the "account" field in the mutation.
  34744. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  34745. v := m.account
  34746. if v == nil {
  34747. return
  34748. }
  34749. return *v, true
  34750. }
  34751. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  34752. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34754. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  34755. if !m.op.Is(OpUpdateOne) {
  34756. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34757. }
  34758. if m.id == nil || m.oldValue == nil {
  34759. return v, errors.New("OldAccount requires an ID field in the mutation")
  34760. }
  34761. oldValue, err := m.oldValue(ctx)
  34762. if err != nil {
  34763. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34764. }
  34765. return oldValue.Account, nil
  34766. }
  34767. // ResetAccount resets all changes to the "account" field.
  34768. func (m *WxCardUserMutation) ResetAccount() {
  34769. m.account = nil
  34770. }
  34771. // SetAvatar sets the "avatar" field.
  34772. func (m *WxCardUserMutation) SetAvatar(s string) {
  34773. m.avatar = &s
  34774. }
  34775. // Avatar returns the value of the "avatar" field in the mutation.
  34776. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  34777. v := m.avatar
  34778. if v == nil {
  34779. return
  34780. }
  34781. return *v, true
  34782. }
  34783. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  34784. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34786. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  34787. if !m.op.Is(OpUpdateOne) {
  34788. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  34789. }
  34790. if m.id == nil || m.oldValue == nil {
  34791. return v, errors.New("OldAvatar requires an ID field in the mutation")
  34792. }
  34793. oldValue, err := m.oldValue(ctx)
  34794. if err != nil {
  34795. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  34796. }
  34797. return oldValue.Avatar, nil
  34798. }
  34799. // ResetAvatar resets all changes to the "avatar" field.
  34800. func (m *WxCardUserMutation) ResetAvatar() {
  34801. m.avatar = nil
  34802. }
  34803. // SetNickname sets the "nickname" field.
  34804. func (m *WxCardUserMutation) SetNickname(s string) {
  34805. m.nickname = &s
  34806. }
  34807. // Nickname returns the value of the "nickname" field in the mutation.
  34808. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  34809. v := m.nickname
  34810. if v == nil {
  34811. return
  34812. }
  34813. return *v, true
  34814. }
  34815. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  34816. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34818. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  34819. if !m.op.Is(OpUpdateOne) {
  34820. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34821. }
  34822. if m.id == nil || m.oldValue == nil {
  34823. return v, errors.New("OldNickname requires an ID field in the mutation")
  34824. }
  34825. oldValue, err := m.oldValue(ctx)
  34826. if err != nil {
  34827. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34828. }
  34829. return oldValue.Nickname, nil
  34830. }
  34831. // ResetNickname resets all changes to the "nickname" field.
  34832. func (m *WxCardUserMutation) ResetNickname() {
  34833. m.nickname = nil
  34834. }
  34835. // SetRemark sets the "remark" field.
  34836. func (m *WxCardUserMutation) SetRemark(s string) {
  34837. m.remark = &s
  34838. }
  34839. // Remark returns the value of the "remark" field in the mutation.
  34840. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  34841. v := m.remark
  34842. if v == nil {
  34843. return
  34844. }
  34845. return *v, true
  34846. }
  34847. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  34848. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34850. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  34851. if !m.op.Is(OpUpdateOne) {
  34852. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  34853. }
  34854. if m.id == nil || m.oldValue == nil {
  34855. return v, errors.New("OldRemark requires an ID field in the mutation")
  34856. }
  34857. oldValue, err := m.oldValue(ctx)
  34858. if err != nil {
  34859. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  34860. }
  34861. return oldValue.Remark, nil
  34862. }
  34863. // ResetRemark resets all changes to the "remark" field.
  34864. func (m *WxCardUserMutation) ResetRemark() {
  34865. m.remark = nil
  34866. }
  34867. // SetPhone sets the "phone" field.
  34868. func (m *WxCardUserMutation) SetPhone(s string) {
  34869. m.phone = &s
  34870. }
  34871. // Phone returns the value of the "phone" field in the mutation.
  34872. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  34873. v := m.phone
  34874. if v == nil {
  34875. return
  34876. }
  34877. return *v, true
  34878. }
  34879. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  34880. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34882. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  34883. if !m.op.Is(OpUpdateOne) {
  34884. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34885. }
  34886. if m.id == nil || m.oldValue == nil {
  34887. return v, errors.New("OldPhone requires an ID field in the mutation")
  34888. }
  34889. oldValue, err := m.oldValue(ctx)
  34890. if err != nil {
  34891. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34892. }
  34893. return oldValue.Phone, nil
  34894. }
  34895. // ResetPhone resets all changes to the "phone" field.
  34896. func (m *WxCardUserMutation) ResetPhone() {
  34897. m.phone = nil
  34898. }
  34899. // SetOpenID sets the "open_id" field.
  34900. func (m *WxCardUserMutation) SetOpenID(s string) {
  34901. m.open_id = &s
  34902. }
  34903. // OpenID returns the value of the "open_id" field in the mutation.
  34904. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  34905. v := m.open_id
  34906. if v == nil {
  34907. return
  34908. }
  34909. return *v, true
  34910. }
  34911. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  34912. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34914. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  34915. if !m.op.Is(OpUpdateOne) {
  34916. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  34917. }
  34918. if m.id == nil || m.oldValue == nil {
  34919. return v, errors.New("OldOpenID requires an ID field in the mutation")
  34920. }
  34921. oldValue, err := m.oldValue(ctx)
  34922. if err != nil {
  34923. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  34924. }
  34925. return oldValue.OpenID, nil
  34926. }
  34927. // ResetOpenID resets all changes to the "open_id" field.
  34928. func (m *WxCardUserMutation) ResetOpenID() {
  34929. m.open_id = nil
  34930. }
  34931. // SetUnionID sets the "union_id" field.
  34932. func (m *WxCardUserMutation) SetUnionID(s string) {
  34933. m.union_id = &s
  34934. }
  34935. // UnionID returns the value of the "union_id" field in the mutation.
  34936. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  34937. v := m.union_id
  34938. if v == nil {
  34939. return
  34940. }
  34941. return *v, true
  34942. }
  34943. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  34944. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34946. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  34947. if !m.op.Is(OpUpdateOne) {
  34948. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  34949. }
  34950. if m.id == nil || m.oldValue == nil {
  34951. return v, errors.New("OldUnionID requires an ID field in the mutation")
  34952. }
  34953. oldValue, err := m.oldValue(ctx)
  34954. if err != nil {
  34955. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  34956. }
  34957. return oldValue.UnionID, nil
  34958. }
  34959. // ResetUnionID resets all changes to the "union_id" field.
  34960. func (m *WxCardUserMutation) ResetUnionID() {
  34961. m.union_id = nil
  34962. }
  34963. // SetSessionKey sets the "session_key" field.
  34964. func (m *WxCardUserMutation) SetSessionKey(s string) {
  34965. m.session_key = &s
  34966. }
  34967. // SessionKey returns the value of the "session_key" field in the mutation.
  34968. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  34969. v := m.session_key
  34970. if v == nil {
  34971. return
  34972. }
  34973. return *v, true
  34974. }
  34975. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  34976. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  34977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34978. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  34979. if !m.op.Is(OpUpdateOne) {
  34980. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  34981. }
  34982. if m.id == nil || m.oldValue == nil {
  34983. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  34984. }
  34985. oldValue, err := m.oldValue(ctx)
  34986. if err != nil {
  34987. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  34988. }
  34989. return oldValue.SessionKey, nil
  34990. }
  34991. // ResetSessionKey resets all changes to the "session_key" field.
  34992. func (m *WxCardUserMutation) ResetSessionKey() {
  34993. m.session_key = nil
  34994. }
  34995. // SetIsVip sets the "is_vip" field.
  34996. func (m *WxCardUserMutation) SetIsVip(i int) {
  34997. m.is_vip = &i
  34998. m.addis_vip = nil
  34999. }
  35000. // IsVip returns the value of the "is_vip" field in the mutation.
  35001. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  35002. v := m.is_vip
  35003. if v == nil {
  35004. return
  35005. }
  35006. return *v, true
  35007. }
  35008. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  35009. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35011. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  35012. if !m.op.Is(OpUpdateOne) {
  35013. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  35014. }
  35015. if m.id == nil || m.oldValue == nil {
  35016. return v, errors.New("OldIsVip requires an ID field in the mutation")
  35017. }
  35018. oldValue, err := m.oldValue(ctx)
  35019. if err != nil {
  35020. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  35021. }
  35022. return oldValue.IsVip, nil
  35023. }
  35024. // AddIsVip adds i to the "is_vip" field.
  35025. func (m *WxCardUserMutation) AddIsVip(i int) {
  35026. if m.addis_vip != nil {
  35027. *m.addis_vip += i
  35028. } else {
  35029. m.addis_vip = &i
  35030. }
  35031. }
  35032. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  35033. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  35034. v := m.addis_vip
  35035. if v == nil {
  35036. return
  35037. }
  35038. return *v, true
  35039. }
  35040. // ResetIsVip resets all changes to the "is_vip" field.
  35041. func (m *WxCardUserMutation) ResetIsVip() {
  35042. m.is_vip = nil
  35043. m.addis_vip = nil
  35044. }
  35045. // Where appends a list predicates to the WxCardUserMutation builder.
  35046. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  35047. m.predicates = append(m.predicates, ps...)
  35048. }
  35049. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  35050. // users can use type-assertion to append predicates that do not depend on any generated package.
  35051. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  35052. p := make([]predicate.WxCardUser, len(ps))
  35053. for i := range ps {
  35054. p[i] = ps[i]
  35055. }
  35056. m.Where(p...)
  35057. }
  35058. // Op returns the operation name.
  35059. func (m *WxCardUserMutation) Op() Op {
  35060. return m.op
  35061. }
  35062. // SetOp allows setting the mutation operation.
  35063. func (m *WxCardUserMutation) SetOp(op Op) {
  35064. m.op = op
  35065. }
  35066. // Type returns the node type of this mutation (WxCardUser).
  35067. func (m *WxCardUserMutation) Type() string {
  35068. return m.typ
  35069. }
  35070. // Fields returns all fields that were changed during this mutation. Note that in
  35071. // order to get all numeric fields that were incremented/decremented, call
  35072. // AddedFields().
  35073. func (m *WxCardUserMutation) Fields() []string {
  35074. fields := make([]string, 0, 13)
  35075. if m.created_at != nil {
  35076. fields = append(fields, wxcarduser.FieldCreatedAt)
  35077. }
  35078. if m.updated_at != nil {
  35079. fields = append(fields, wxcarduser.FieldUpdatedAt)
  35080. }
  35081. if m.deleted_at != nil {
  35082. fields = append(fields, wxcarduser.FieldDeletedAt)
  35083. }
  35084. if m.wxid != nil {
  35085. fields = append(fields, wxcarduser.FieldWxid)
  35086. }
  35087. if m.account != nil {
  35088. fields = append(fields, wxcarduser.FieldAccount)
  35089. }
  35090. if m.avatar != nil {
  35091. fields = append(fields, wxcarduser.FieldAvatar)
  35092. }
  35093. if m.nickname != nil {
  35094. fields = append(fields, wxcarduser.FieldNickname)
  35095. }
  35096. if m.remark != nil {
  35097. fields = append(fields, wxcarduser.FieldRemark)
  35098. }
  35099. if m.phone != nil {
  35100. fields = append(fields, wxcarduser.FieldPhone)
  35101. }
  35102. if m.open_id != nil {
  35103. fields = append(fields, wxcarduser.FieldOpenID)
  35104. }
  35105. if m.union_id != nil {
  35106. fields = append(fields, wxcarduser.FieldUnionID)
  35107. }
  35108. if m.session_key != nil {
  35109. fields = append(fields, wxcarduser.FieldSessionKey)
  35110. }
  35111. if m.is_vip != nil {
  35112. fields = append(fields, wxcarduser.FieldIsVip)
  35113. }
  35114. return fields
  35115. }
  35116. // Field returns the value of a field with the given name. The second boolean
  35117. // return value indicates that this field was not set, or was not defined in the
  35118. // schema.
  35119. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  35120. switch name {
  35121. case wxcarduser.FieldCreatedAt:
  35122. return m.CreatedAt()
  35123. case wxcarduser.FieldUpdatedAt:
  35124. return m.UpdatedAt()
  35125. case wxcarduser.FieldDeletedAt:
  35126. return m.DeletedAt()
  35127. case wxcarduser.FieldWxid:
  35128. return m.Wxid()
  35129. case wxcarduser.FieldAccount:
  35130. return m.Account()
  35131. case wxcarduser.FieldAvatar:
  35132. return m.Avatar()
  35133. case wxcarduser.FieldNickname:
  35134. return m.Nickname()
  35135. case wxcarduser.FieldRemark:
  35136. return m.Remark()
  35137. case wxcarduser.FieldPhone:
  35138. return m.Phone()
  35139. case wxcarduser.FieldOpenID:
  35140. return m.OpenID()
  35141. case wxcarduser.FieldUnionID:
  35142. return m.UnionID()
  35143. case wxcarduser.FieldSessionKey:
  35144. return m.SessionKey()
  35145. case wxcarduser.FieldIsVip:
  35146. return m.IsVip()
  35147. }
  35148. return nil, false
  35149. }
  35150. // OldField returns the old value of the field from the database. An error is
  35151. // returned if the mutation operation is not UpdateOne, or the query to the
  35152. // database failed.
  35153. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35154. switch name {
  35155. case wxcarduser.FieldCreatedAt:
  35156. return m.OldCreatedAt(ctx)
  35157. case wxcarduser.FieldUpdatedAt:
  35158. return m.OldUpdatedAt(ctx)
  35159. case wxcarduser.FieldDeletedAt:
  35160. return m.OldDeletedAt(ctx)
  35161. case wxcarduser.FieldWxid:
  35162. return m.OldWxid(ctx)
  35163. case wxcarduser.FieldAccount:
  35164. return m.OldAccount(ctx)
  35165. case wxcarduser.FieldAvatar:
  35166. return m.OldAvatar(ctx)
  35167. case wxcarduser.FieldNickname:
  35168. return m.OldNickname(ctx)
  35169. case wxcarduser.FieldRemark:
  35170. return m.OldRemark(ctx)
  35171. case wxcarduser.FieldPhone:
  35172. return m.OldPhone(ctx)
  35173. case wxcarduser.FieldOpenID:
  35174. return m.OldOpenID(ctx)
  35175. case wxcarduser.FieldUnionID:
  35176. return m.OldUnionID(ctx)
  35177. case wxcarduser.FieldSessionKey:
  35178. return m.OldSessionKey(ctx)
  35179. case wxcarduser.FieldIsVip:
  35180. return m.OldIsVip(ctx)
  35181. }
  35182. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  35183. }
  35184. // SetField sets the value of a field with the given name. It returns an error if
  35185. // the field is not defined in the schema, or if the type mismatched the field
  35186. // type.
  35187. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  35188. switch name {
  35189. case wxcarduser.FieldCreatedAt:
  35190. v, ok := value.(time.Time)
  35191. if !ok {
  35192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35193. }
  35194. m.SetCreatedAt(v)
  35195. return nil
  35196. case wxcarduser.FieldUpdatedAt:
  35197. v, ok := value.(time.Time)
  35198. if !ok {
  35199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35200. }
  35201. m.SetUpdatedAt(v)
  35202. return nil
  35203. case wxcarduser.FieldDeletedAt:
  35204. v, ok := value.(time.Time)
  35205. if !ok {
  35206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35207. }
  35208. m.SetDeletedAt(v)
  35209. return nil
  35210. case wxcarduser.FieldWxid:
  35211. v, ok := value.(string)
  35212. if !ok {
  35213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35214. }
  35215. m.SetWxid(v)
  35216. return nil
  35217. case wxcarduser.FieldAccount:
  35218. v, ok := value.(string)
  35219. if !ok {
  35220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35221. }
  35222. m.SetAccount(v)
  35223. return nil
  35224. case wxcarduser.FieldAvatar:
  35225. v, ok := value.(string)
  35226. if !ok {
  35227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35228. }
  35229. m.SetAvatar(v)
  35230. return nil
  35231. case wxcarduser.FieldNickname:
  35232. v, ok := value.(string)
  35233. if !ok {
  35234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35235. }
  35236. m.SetNickname(v)
  35237. return nil
  35238. case wxcarduser.FieldRemark:
  35239. v, ok := value.(string)
  35240. if !ok {
  35241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35242. }
  35243. m.SetRemark(v)
  35244. return nil
  35245. case wxcarduser.FieldPhone:
  35246. v, ok := value.(string)
  35247. if !ok {
  35248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35249. }
  35250. m.SetPhone(v)
  35251. return nil
  35252. case wxcarduser.FieldOpenID:
  35253. v, ok := value.(string)
  35254. if !ok {
  35255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35256. }
  35257. m.SetOpenID(v)
  35258. return nil
  35259. case wxcarduser.FieldUnionID:
  35260. v, ok := value.(string)
  35261. if !ok {
  35262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35263. }
  35264. m.SetUnionID(v)
  35265. return nil
  35266. case wxcarduser.FieldSessionKey:
  35267. v, ok := value.(string)
  35268. if !ok {
  35269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35270. }
  35271. m.SetSessionKey(v)
  35272. return nil
  35273. case wxcarduser.FieldIsVip:
  35274. v, ok := value.(int)
  35275. if !ok {
  35276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35277. }
  35278. m.SetIsVip(v)
  35279. return nil
  35280. }
  35281. return fmt.Errorf("unknown WxCardUser field %s", name)
  35282. }
  35283. // AddedFields returns all numeric fields that were incremented/decremented during
  35284. // this mutation.
  35285. func (m *WxCardUserMutation) AddedFields() []string {
  35286. var fields []string
  35287. if m.addis_vip != nil {
  35288. fields = append(fields, wxcarduser.FieldIsVip)
  35289. }
  35290. return fields
  35291. }
  35292. // AddedField returns the numeric value that was incremented/decremented on a field
  35293. // with the given name. The second boolean return value indicates that this field
  35294. // was not set, or was not defined in the schema.
  35295. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  35296. switch name {
  35297. case wxcarduser.FieldIsVip:
  35298. return m.AddedIsVip()
  35299. }
  35300. return nil, false
  35301. }
  35302. // AddField adds the value to the field with the given name. It returns an error if
  35303. // the field is not defined in the schema, or if the type mismatched the field
  35304. // type.
  35305. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  35306. switch name {
  35307. case wxcarduser.FieldIsVip:
  35308. v, ok := value.(int)
  35309. if !ok {
  35310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35311. }
  35312. m.AddIsVip(v)
  35313. return nil
  35314. }
  35315. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  35316. }
  35317. // ClearedFields returns all nullable fields that were cleared during this
  35318. // mutation.
  35319. func (m *WxCardUserMutation) ClearedFields() []string {
  35320. var fields []string
  35321. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  35322. fields = append(fields, wxcarduser.FieldDeletedAt)
  35323. }
  35324. return fields
  35325. }
  35326. // FieldCleared returns a boolean indicating if a field with the given name was
  35327. // cleared in this mutation.
  35328. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  35329. _, ok := m.clearedFields[name]
  35330. return ok
  35331. }
  35332. // ClearField clears the value of the field with the given name. It returns an
  35333. // error if the field is not defined in the schema.
  35334. func (m *WxCardUserMutation) ClearField(name string) error {
  35335. switch name {
  35336. case wxcarduser.FieldDeletedAt:
  35337. m.ClearDeletedAt()
  35338. return nil
  35339. }
  35340. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  35341. }
  35342. // ResetField resets all changes in the mutation for the field with the given name.
  35343. // It returns an error if the field is not defined in the schema.
  35344. func (m *WxCardUserMutation) ResetField(name string) error {
  35345. switch name {
  35346. case wxcarduser.FieldCreatedAt:
  35347. m.ResetCreatedAt()
  35348. return nil
  35349. case wxcarduser.FieldUpdatedAt:
  35350. m.ResetUpdatedAt()
  35351. return nil
  35352. case wxcarduser.FieldDeletedAt:
  35353. m.ResetDeletedAt()
  35354. return nil
  35355. case wxcarduser.FieldWxid:
  35356. m.ResetWxid()
  35357. return nil
  35358. case wxcarduser.FieldAccount:
  35359. m.ResetAccount()
  35360. return nil
  35361. case wxcarduser.FieldAvatar:
  35362. m.ResetAvatar()
  35363. return nil
  35364. case wxcarduser.FieldNickname:
  35365. m.ResetNickname()
  35366. return nil
  35367. case wxcarduser.FieldRemark:
  35368. m.ResetRemark()
  35369. return nil
  35370. case wxcarduser.FieldPhone:
  35371. m.ResetPhone()
  35372. return nil
  35373. case wxcarduser.FieldOpenID:
  35374. m.ResetOpenID()
  35375. return nil
  35376. case wxcarduser.FieldUnionID:
  35377. m.ResetUnionID()
  35378. return nil
  35379. case wxcarduser.FieldSessionKey:
  35380. m.ResetSessionKey()
  35381. return nil
  35382. case wxcarduser.FieldIsVip:
  35383. m.ResetIsVip()
  35384. return nil
  35385. }
  35386. return fmt.Errorf("unknown WxCardUser field %s", name)
  35387. }
  35388. // AddedEdges returns all edge names that were set/added in this mutation.
  35389. func (m *WxCardUserMutation) AddedEdges() []string {
  35390. edges := make([]string, 0, 0)
  35391. return edges
  35392. }
  35393. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35394. // name in this mutation.
  35395. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  35396. return nil
  35397. }
  35398. // RemovedEdges returns all edge names that were removed in this mutation.
  35399. func (m *WxCardUserMutation) RemovedEdges() []string {
  35400. edges := make([]string, 0, 0)
  35401. return edges
  35402. }
  35403. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35404. // the given name in this mutation.
  35405. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  35406. return nil
  35407. }
  35408. // ClearedEdges returns all edge names that were cleared in this mutation.
  35409. func (m *WxCardUserMutation) ClearedEdges() []string {
  35410. edges := make([]string, 0, 0)
  35411. return edges
  35412. }
  35413. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35414. // was cleared in this mutation.
  35415. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  35416. return false
  35417. }
  35418. // ClearEdge clears the value of the edge with the given name. It returns an error
  35419. // if that edge is not defined in the schema.
  35420. func (m *WxCardUserMutation) ClearEdge(name string) error {
  35421. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  35422. }
  35423. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35424. // It returns an error if the edge is not defined in the schema.
  35425. func (m *WxCardUserMutation) ResetEdge(name string) error {
  35426. return fmt.Errorf("unknown WxCardUser edge %s", name)
  35427. }
  35428. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  35429. type WxCardVisitMutation struct {
  35430. config
  35431. op Op
  35432. typ string
  35433. id *uint64
  35434. created_at *time.Time
  35435. updated_at *time.Time
  35436. deleted_at *time.Time
  35437. user_id *uint64
  35438. adduser_id *int64
  35439. bot_id *uint64
  35440. addbot_id *int64
  35441. bot_type *uint8
  35442. addbot_type *int8
  35443. clearedFields map[string]struct{}
  35444. done bool
  35445. oldValue func(context.Context) (*WxCardVisit, error)
  35446. predicates []predicate.WxCardVisit
  35447. }
  35448. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  35449. // wxcardvisitOption allows management of the mutation configuration using functional options.
  35450. type wxcardvisitOption func(*WxCardVisitMutation)
  35451. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  35452. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  35453. m := &WxCardVisitMutation{
  35454. config: c,
  35455. op: op,
  35456. typ: TypeWxCardVisit,
  35457. clearedFields: make(map[string]struct{}),
  35458. }
  35459. for _, opt := range opts {
  35460. opt(m)
  35461. }
  35462. return m
  35463. }
  35464. // withWxCardVisitID sets the ID field of the mutation.
  35465. func withWxCardVisitID(id uint64) wxcardvisitOption {
  35466. return func(m *WxCardVisitMutation) {
  35467. var (
  35468. err error
  35469. once sync.Once
  35470. value *WxCardVisit
  35471. )
  35472. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  35473. once.Do(func() {
  35474. if m.done {
  35475. err = errors.New("querying old values post mutation is not allowed")
  35476. } else {
  35477. value, err = m.Client().WxCardVisit.Get(ctx, id)
  35478. }
  35479. })
  35480. return value, err
  35481. }
  35482. m.id = &id
  35483. }
  35484. }
  35485. // withWxCardVisit sets the old WxCardVisit of the mutation.
  35486. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  35487. return func(m *WxCardVisitMutation) {
  35488. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  35489. return node, nil
  35490. }
  35491. m.id = &node.ID
  35492. }
  35493. }
  35494. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35495. // executed in a transaction (ent.Tx), a transactional client is returned.
  35496. func (m WxCardVisitMutation) Client() *Client {
  35497. client := &Client{config: m.config}
  35498. client.init()
  35499. return client
  35500. }
  35501. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35502. // it returns an error otherwise.
  35503. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  35504. if _, ok := m.driver.(*txDriver); !ok {
  35505. return nil, errors.New("ent: mutation is not running in a transaction")
  35506. }
  35507. tx := &Tx{config: m.config}
  35508. tx.init()
  35509. return tx, nil
  35510. }
  35511. // SetID sets the value of the id field. Note that this
  35512. // operation is only accepted on creation of WxCardVisit entities.
  35513. func (m *WxCardVisitMutation) SetID(id uint64) {
  35514. m.id = &id
  35515. }
  35516. // ID returns the ID value in the mutation. Note that the ID is only available
  35517. // if it was provided to the builder or after it was returned from the database.
  35518. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  35519. if m.id == nil {
  35520. return
  35521. }
  35522. return *m.id, true
  35523. }
  35524. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35525. // That means, if the mutation is applied within a transaction with an isolation level such
  35526. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35527. // or updated by the mutation.
  35528. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  35529. switch {
  35530. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35531. id, exists := m.ID()
  35532. if exists {
  35533. return []uint64{id}, nil
  35534. }
  35535. fallthrough
  35536. case m.op.Is(OpUpdate | OpDelete):
  35537. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  35538. default:
  35539. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35540. }
  35541. }
  35542. // SetCreatedAt sets the "created_at" field.
  35543. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  35544. m.created_at = &t
  35545. }
  35546. // CreatedAt returns the value of the "created_at" field in the mutation.
  35547. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  35548. v := m.created_at
  35549. if v == nil {
  35550. return
  35551. }
  35552. return *v, true
  35553. }
  35554. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  35555. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35557. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35558. if !m.op.Is(OpUpdateOne) {
  35559. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35560. }
  35561. if m.id == nil || m.oldValue == nil {
  35562. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35563. }
  35564. oldValue, err := m.oldValue(ctx)
  35565. if err != nil {
  35566. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35567. }
  35568. return oldValue.CreatedAt, nil
  35569. }
  35570. // ResetCreatedAt resets all changes to the "created_at" field.
  35571. func (m *WxCardVisitMutation) ResetCreatedAt() {
  35572. m.created_at = nil
  35573. }
  35574. // SetUpdatedAt sets the "updated_at" field.
  35575. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  35576. m.updated_at = &t
  35577. }
  35578. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35579. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  35580. v := m.updated_at
  35581. if v == nil {
  35582. return
  35583. }
  35584. return *v, true
  35585. }
  35586. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  35587. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35589. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35590. if !m.op.Is(OpUpdateOne) {
  35591. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35592. }
  35593. if m.id == nil || m.oldValue == nil {
  35594. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35595. }
  35596. oldValue, err := m.oldValue(ctx)
  35597. if err != nil {
  35598. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35599. }
  35600. return oldValue.UpdatedAt, nil
  35601. }
  35602. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35603. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  35604. m.updated_at = nil
  35605. }
  35606. // SetDeletedAt sets the "deleted_at" field.
  35607. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  35608. m.deleted_at = &t
  35609. }
  35610. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35611. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  35612. v := m.deleted_at
  35613. if v == nil {
  35614. return
  35615. }
  35616. return *v, true
  35617. }
  35618. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  35619. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35621. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35622. if !m.op.Is(OpUpdateOne) {
  35623. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35624. }
  35625. if m.id == nil || m.oldValue == nil {
  35626. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35627. }
  35628. oldValue, err := m.oldValue(ctx)
  35629. if err != nil {
  35630. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35631. }
  35632. return oldValue.DeletedAt, nil
  35633. }
  35634. // ClearDeletedAt clears the value of the "deleted_at" field.
  35635. func (m *WxCardVisitMutation) ClearDeletedAt() {
  35636. m.deleted_at = nil
  35637. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  35638. }
  35639. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35640. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  35641. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  35642. return ok
  35643. }
  35644. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35645. func (m *WxCardVisitMutation) ResetDeletedAt() {
  35646. m.deleted_at = nil
  35647. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  35648. }
  35649. // SetUserID sets the "user_id" field.
  35650. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  35651. m.user_id = &u
  35652. m.adduser_id = nil
  35653. }
  35654. // UserID returns the value of the "user_id" field in the mutation.
  35655. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  35656. v := m.user_id
  35657. if v == nil {
  35658. return
  35659. }
  35660. return *v, true
  35661. }
  35662. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  35663. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35665. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  35666. if !m.op.Is(OpUpdateOne) {
  35667. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  35668. }
  35669. if m.id == nil || m.oldValue == nil {
  35670. return v, errors.New("OldUserID requires an ID field in the mutation")
  35671. }
  35672. oldValue, err := m.oldValue(ctx)
  35673. if err != nil {
  35674. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  35675. }
  35676. return oldValue.UserID, nil
  35677. }
  35678. // AddUserID adds u to the "user_id" field.
  35679. func (m *WxCardVisitMutation) AddUserID(u int64) {
  35680. if m.adduser_id != nil {
  35681. *m.adduser_id += u
  35682. } else {
  35683. m.adduser_id = &u
  35684. }
  35685. }
  35686. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  35687. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  35688. v := m.adduser_id
  35689. if v == nil {
  35690. return
  35691. }
  35692. return *v, true
  35693. }
  35694. // ClearUserID clears the value of the "user_id" field.
  35695. func (m *WxCardVisitMutation) ClearUserID() {
  35696. m.user_id = nil
  35697. m.adduser_id = nil
  35698. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  35699. }
  35700. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  35701. func (m *WxCardVisitMutation) UserIDCleared() bool {
  35702. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  35703. return ok
  35704. }
  35705. // ResetUserID resets all changes to the "user_id" field.
  35706. func (m *WxCardVisitMutation) ResetUserID() {
  35707. m.user_id = nil
  35708. m.adduser_id = nil
  35709. delete(m.clearedFields, wxcardvisit.FieldUserID)
  35710. }
  35711. // SetBotID sets the "bot_id" field.
  35712. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  35713. m.bot_id = &u
  35714. m.addbot_id = nil
  35715. }
  35716. // BotID returns the value of the "bot_id" field in the mutation.
  35717. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  35718. v := m.bot_id
  35719. if v == nil {
  35720. return
  35721. }
  35722. return *v, true
  35723. }
  35724. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  35725. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35727. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  35728. if !m.op.Is(OpUpdateOne) {
  35729. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35730. }
  35731. if m.id == nil || m.oldValue == nil {
  35732. return v, errors.New("OldBotID requires an ID field in the mutation")
  35733. }
  35734. oldValue, err := m.oldValue(ctx)
  35735. if err != nil {
  35736. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35737. }
  35738. return oldValue.BotID, nil
  35739. }
  35740. // AddBotID adds u to the "bot_id" field.
  35741. func (m *WxCardVisitMutation) AddBotID(u int64) {
  35742. if m.addbot_id != nil {
  35743. *m.addbot_id += u
  35744. } else {
  35745. m.addbot_id = &u
  35746. }
  35747. }
  35748. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  35749. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  35750. v := m.addbot_id
  35751. if v == nil {
  35752. return
  35753. }
  35754. return *v, true
  35755. }
  35756. // ResetBotID resets all changes to the "bot_id" field.
  35757. func (m *WxCardVisitMutation) ResetBotID() {
  35758. m.bot_id = nil
  35759. m.addbot_id = nil
  35760. }
  35761. // SetBotType sets the "bot_type" field.
  35762. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  35763. m.bot_type = &u
  35764. m.addbot_type = nil
  35765. }
  35766. // BotType returns the value of the "bot_type" field in the mutation.
  35767. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  35768. v := m.bot_type
  35769. if v == nil {
  35770. return
  35771. }
  35772. return *v, true
  35773. }
  35774. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  35775. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  35776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35777. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  35778. if !m.op.Is(OpUpdateOne) {
  35779. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  35780. }
  35781. if m.id == nil || m.oldValue == nil {
  35782. return v, errors.New("OldBotType requires an ID field in the mutation")
  35783. }
  35784. oldValue, err := m.oldValue(ctx)
  35785. if err != nil {
  35786. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  35787. }
  35788. return oldValue.BotType, nil
  35789. }
  35790. // AddBotType adds u to the "bot_type" field.
  35791. func (m *WxCardVisitMutation) AddBotType(u int8) {
  35792. if m.addbot_type != nil {
  35793. *m.addbot_type += u
  35794. } else {
  35795. m.addbot_type = &u
  35796. }
  35797. }
  35798. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  35799. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  35800. v := m.addbot_type
  35801. if v == nil {
  35802. return
  35803. }
  35804. return *v, true
  35805. }
  35806. // ResetBotType resets all changes to the "bot_type" field.
  35807. func (m *WxCardVisitMutation) ResetBotType() {
  35808. m.bot_type = nil
  35809. m.addbot_type = nil
  35810. }
  35811. // Where appends a list predicates to the WxCardVisitMutation builder.
  35812. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  35813. m.predicates = append(m.predicates, ps...)
  35814. }
  35815. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  35816. // users can use type-assertion to append predicates that do not depend on any generated package.
  35817. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  35818. p := make([]predicate.WxCardVisit, len(ps))
  35819. for i := range ps {
  35820. p[i] = ps[i]
  35821. }
  35822. m.Where(p...)
  35823. }
  35824. // Op returns the operation name.
  35825. func (m *WxCardVisitMutation) Op() Op {
  35826. return m.op
  35827. }
  35828. // SetOp allows setting the mutation operation.
  35829. func (m *WxCardVisitMutation) SetOp(op Op) {
  35830. m.op = op
  35831. }
  35832. // Type returns the node type of this mutation (WxCardVisit).
  35833. func (m *WxCardVisitMutation) Type() string {
  35834. return m.typ
  35835. }
  35836. // Fields returns all fields that were changed during this mutation. Note that in
  35837. // order to get all numeric fields that were incremented/decremented, call
  35838. // AddedFields().
  35839. func (m *WxCardVisitMutation) Fields() []string {
  35840. fields := make([]string, 0, 6)
  35841. if m.created_at != nil {
  35842. fields = append(fields, wxcardvisit.FieldCreatedAt)
  35843. }
  35844. if m.updated_at != nil {
  35845. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  35846. }
  35847. if m.deleted_at != nil {
  35848. fields = append(fields, wxcardvisit.FieldDeletedAt)
  35849. }
  35850. if m.user_id != nil {
  35851. fields = append(fields, wxcardvisit.FieldUserID)
  35852. }
  35853. if m.bot_id != nil {
  35854. fields = append(fields, wxcardvisit.FieldBotID)
  35855. }
  35856. if m.bot_type != nil {
  35857. fields = append(fields, wxcardvisit.FieldBotType)
  35858. }
  35859. return fields
  35860. }
  35861. // Field returns the value of a field with the given name. The second boolean
  35862. // return value indicates that this field was not set, or was not defined in the
  35863. // schema.
  35864. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  35865. switch name {
  35866. case wxcardvisit.FieldCreatedAt:
  35867. return m.CreatedAt()
  35868. case wxcardvisit.FieldUpdatedAt:
  35869. return m.UpdatedAt()
  35870. case wxcardvisit.FieldDeletedAt:
  35871. return m.DeletedAt()
  35872. case wxcardvisit.FieldUserID:
  35873. return m.UserID()
  35874. case wxcardvisit.FieldBotID:
  35875. return m.BotID()
  35876. case wxcardvisit.FieldBotType:
  35877. return m.BotType()
  35878. }
  35879. return nil, false
  35880. }
  35881. // OldField returns the old value of the field from the database. An error is
  35882. // returned if the mutation operation is not UpdateOne, or the query to the
  35883. // database failed.
  35884. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35885. switch name {
  35886. case wxcardvisit.FieldCreatedAt:
  35887. return m.OldCreatedAt(ctx)
  35888. case wxcardvisit.FieldUpdatedAt:
  35889. return m.OldUpdatedAt(ctx)
  35890. case wxcardvisit.FieldDeletedAt:
  35891. return m.OldDeletedAt(ctx)
  35892. case wxcardvisit.FieldUserID:
  35893. return m.OldUserID(ctx)
  35894. case wxcardvisit.FieldBotID:
  35895. return m.OldBotID(ctx)
  35896. case wxcardvisit.FieldBotType:
  35897. return m.OldBotType(ctx)
  35898. }
  35899. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  35900. }
  35901. // SetField sets the value of a field with the given name. It returns an error if
  35902. // the field is not defined in the schema, or if the type mismatched the field
  35903. // type.
  35904. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  35905. switch name {
  35906. case wxcardvisit.FieldCreatedAt:
  35907. v, ok := value.(time.Time)
  35908. if !ok {
  35909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35910. }
  35911. m.SetCreatedAt(v)
  35912. return nil
  35913. case wxcardvisit.FieldUpdatedAt:
  35914. v, ok := value.(time.Time)
  35915. if !ok {
  35916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35917. }
  35918. m.SetUpdatedAt(v)
  35919. return nil
  35920. case wxcardvisit.FieldDeletedAt:
  35921. v, ok := value.(time.Time)
  35922. if !ok {
  35923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35924. }
  35925. m.SetDeletedAt(v)
  35926. return nil
  35927. case wxcardvisit.FieldUserID:
  35928. v, ok := value.(uint64)
  35929. if !ok {
  35930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35931. }
  35932. m.SetUserID(v)
  35933. return nil
  35934. case wxcardvisit.FieldBotID:
  35935. v, ok := value.(uint64)
  35936. if !ok {
  35937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35938. }
  35939. m.SetBotID(v)
  35940. return nil
  35941. case wxcardvisit.FieldBotType:
  35942. v, ok := value.(uint8)
  35943. if !ok {
  35944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35945. }
  35946. m.SetBotType(v)
  35947. return nil
  35948. }
  35949. return fmt.Errorf("unknown WxCardVisit field %s", name)
  35950. }
  35951. // AddedFields returns all numeric fields that were incremented/decremented during
  35952. // this mutation.
  35953. func (m *WxCardVisitMutation) AddedFields() []string {
  35954. var fields []string
  35955. if m.adduser_id != nil {
  35956. fields = append(fields, wxcardvisit.FieldUserID)
  35957. }
  35958. if m.addbot_id != nil {
  35959. fields = append(fields, wxcardvisit.FieldBotID)
  35960. }
  35961. if m.addbot_type != nil {
  35962. fields = append(fields, wxcardvisit.FieldBotType)
  35963. }
  35964. return fields
  35965. }
  35966. // AddedField returns the numeric value that was incremented/decremented on a field
  35967. // with the given name. The second boolean return value indicates that this field
  35968. // was not set, or was not defined in the schema.
  35969. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  35970. switch name {
  35971. case wxcardvisit.FieldUserID:
  35972. return m.AddedUserID()
  35973. case wxcardvisit.FieldBotID:
  35974. return m.AddedBotID()
  35975. case wxcardvisit.FieldBotType:
  35976. return m.AddedBotType()
  35977. }
  35978. return nil, false
  35979. }
  35980. // AddField adds the value to the field with the given name. It returns an error if
  35981. // the field is not defined in the schema, or if the type mismatched the field
  35982. // type.
  35983. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  35984. switch name {
  35985. case wxcardvisit.FieldUserID:
  35986. v, ok := value.(int64)
  35987. if !ok {
  35988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35989. }
  35990. m.AddUserID(v)
  35991. return nil
  35992. case wxcardvisit.FieldBotID:
  35993. v, ok := value.(int64)
  35994. if !ok {
  35995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35996. }
  35997. m.AddBotID(v)
  35998. return nil
  35999. case wxcardvisit.FieldBotType:
  36000. v, ok := value.(int8)
  36001. if !ok {
  36002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36003. }
  36004. m.AddBotType(v)
  36005. return nil
  36006. }
  36007. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  36008. }
  36009. // ClearedFields returns all nullable fields that were cleared during this
  36010. // mutation.
  36011. func (m *WxCardVisitMutation) ClearedFields() []string {
  36012. var fields []string
  36013. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  36014. fields = append(fields, wxcardvisit.FieldDeletedAt)
  36015. }
  36016. if m.FieldCleared(wxcardvisit.FieldUserID) {
  36017. fields = append(fields, wxcardvisit.FieldUserID)
  36018. }
  36019. return fields
  36020. }
  36021. // FieldCleared returns a boolean indicating if a field with the given name was
  36022. // cleared in this mutation.
  36023. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  36024. _, ok := m.clearedFields[name]
  36025. return ok
  36026. }
  36027. // ClearField clears the value of the field with the given name. It returns an
  36028. // error if the field is not defined in the schema.
  36029. func (m *WxCardVisitMutation) ClearField(name string) error {
  36030. switch name {
  36031. case wxcardvisit.FieldDeletedAt:
  36032. m.ClearDeletedAt()
  36033. return nil
  36034. case wxcardvisit.FieldUserID:
  36035. m.ClearUserID()
  36036. return nil
  36037. }
  36038. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  36039. }
  36040. // ResetField resets all changes in the mutation for the field with the given name.
  36041. // It returns an error if the field is not defined in the schema.
  36042. func (m *WxCardVisitMutation) ResetField(name string) error {
  36043. switch name {
  36044. case wxcardvisit.FieldCreatedAt:
  36045. m.ResetCreatedAt()
  36046. return nil
  36047. case wxcardvisit.FieldUpdatedAt:
  36048. m.ResetUpdatedAt()
  36049. return nil
  36050. case wxcardvisit.FieldDeletedAt:
  36051. m.ResetDeletedAt()
  36052. return nil
  36053. case wxcardvisit.FieldUserID:
  36054. m.ResetUserID()
  36055. return nil
  36056. case wxcardvisit.FieldBotID:
  36057. m.ResetBotID()
  36058. return nil
  36059. case wxcardvisit.FieldBotType:
  36060. m.ResetBotType()
  36061. return nil
  36062. }
  36063. return fmt.Errorf("unknown WxCardVisit field %s", name)
  36064. }
  36065. // AddedEdges returns all edge names that were set/added in this mutation.
  36066. func (m *WxCardVisitMutation) AddedEdges() []string {
  36067. edges := make([]string, 0, 0)
  36068. return edges
  36069. }
  36070. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36071. // name in this mutation.
  36072. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  36073. return nil
  36074. }
  36075. // RemovedEdges returns all edge names that were removed in this mutation.
  36076. func (m *WxCardVisitMutation) RemovedEdges() []string {
  36077. edges := make([]string, 0, 0)
  36078. return edges
  36079. }
  36080. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36081. // the given name in this mutation.
  36082. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  36083. return nil
  36084. }
  36085. // ClearedEdges returns all edge names that were cleared in this mutation.
  36086. func (m *WxCardVisitMutation) ClearedEdges() []string {
  36087. edges := make([]string, 0, 0)
  36088. return edges
  36089. }
  36090. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36091. // was cleared in this mutation.
  36092. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  36093. return false
  36094. }
  36095. // ClearEdge clears the value of the edge with the given name. It returns an error
  36096. // if that edge is not defined in the schema.
  36097. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  36098. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  36099. }
  36100. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36101. // It returns an error if the edge is not defined in the schema.
  36102. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  36103. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  36104. }