mutation.go 1.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/custom_types"
  19. "wechat-api/ent/employee"
  20. "wechat-api/ent/employeeconfig"
  21. "wechat-api/ent/label"
  22. "wechat-api/ent/labelrelationship"
  23. "wechat-api/ent/message"
  24. "wechat-api/ent/messagerecords"
  25. "wechat-api/ent/msg"
  26. "wechat-api/ent/predicate"
  27. "wechat-api/ent/server"
  28. "wechat-api/ent/sopnode"
  29. "wechat-api/ent/sopstage"
  30. "wechat-api/ent/soptask"
  31. "wechat-api/ent/token"
  32. "wechat-api/ent/tutorial"
  33. "wechat-api/ent/usagedetail"
  34. "wechat-api/ent/usagestatisticday"
  35. "wechat-api/ent/usagestatistichour"
  36. "wechat-api/ent/usagestatisticmonth"
  37. "wechat-api/ent/usagetotal"
  38. "wechat-api/ent/workexperience"
  39. "wechat-api/ent/wpchatroom"
  40. "wechat-api/ent/wpchatroommember"
  41. "wechat-api/ent/wx"
  42. "wechat-api/ent/wxcard"
  43. "wechat-api/ent/wxcarduser"
  44. "wechat-api/ent/wxcardvisit"
  45. "entgo.io/ent"
  46. "entgo.io/ent/dialect/sql"
  47. )
  48. const (
  49. // Operation types.
  50. OpCreate = ent.OpCreate
  51. OpDelete = ent.OpDelete
  52. OpDeleteOne = ent.OpDeleteOne
  53. OpUpdate = ent.OpUpdate
  54. OpUpdateOne = ent.OpUpdateOne
  55. // Node types.
  56. TypeAgent = "Agent"
  57. TypeAgentBase = "AgentBase"
  58. TypeAliyunAvatar = "AliyunAvatar"
  59. TypeAllocAgent = "AllocAgent"
  60. TypeBatchMsg = "BatchMsg"
  61. TypeCategory = "Category"
  62. TypeChatRecords = "ChatRecords"
  63. TypeChatSession = "ChatSession"
  64. TypeContact = "Contact"
  65. TypeEmployee = "Employee"
  66. TypeEmployeeConfig = "EmployeeConfig"
  67. TypeLabel = "Label"
  68. TypeLabelRelationship = "LabelRelationship"
  69. TypeMessage = "Message"
  70. TypeMessageRecords = "MessageRecords"
  71. TypeMsg = "Msg"
  72. TypeServer = "Server"
  73. TypeSopNode = "SopNode"
  74. TypeSopStage = "SopStage"
  75. TypeSopTask = "SopTask"
  76. TypeToken = "Token"
  77. TypeTutorial = "Tutorial"
  78. TypeUsageDetail = "UsageDetail"
  79. TypeUsageStatisticDay = "UsageStatisticDay"
  80. TypeUsageStatisticHour = "UsageStatisticHour"
  81. TypeUsageStatisticMonth = "UsageStatisticMonth"
  82. TypeUsageTotal = "UsageTotal"
  83. TypeWorkExperience = "WorkExperience"
  84. TypeWpChatroom = "WpChatroom"
  85. TypeWpChatroomMember = "WpChatroomMember"
  86. TypeWx = "Wx"
  87. TypeWxCard = "WxCard"
  88. TypeWxCardUser = "WxCardUser"
  89. TypeWxCardVisit = "WxCardVisit"
  90. )
  91. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  92. type AgentMutation struct {
  93. config
  94. op Op
  95. typ string
  96. id *uint64
  97. created_at *time.Time
  98. updated_at *time.Time
  99. deleted_at *time.Time
  100. name *string
  101. role *string
  102. status *int
  103. addstatus *int
  104. background *string
  105. examples *string
  106. organization_id *uint64
  107. addorganization_id *int64
  108. dataset_id *string
  109. collection_id *string
  110. clearedFields map[string]struct{}
  111. wx_agent map[uint64]struct{}
  112. removedwx_agent map[uint64]struct{}
  113. clearedwx_agent bool
  114. token_agent map[uint64]struct{}
  115. removedtoken_agent map[uint64]struct{}
  116. clearedtoken_agent bool
  117. done bool
  118. oldValue func(context.Context) (*Agent, error)
  119. predicates []predicate.Agent
  120. }
  121. var _ ent.Mutation = (*AgentMutation)(nil)
  122. // agentOption allows management of the mutation configuration using functional options.
  123. type agentOption func(*AgentMutation)
  124. // newAgentMutation creates new mutation for the Agent entity.
  125. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  126. m := &AgentMutation{
  127. config: c,
  128. op: op,
  129. typ: TypeAgent,
  130. clearedFields: make(map[string]struct{}),
  131. }
  132. for _, opt := range opts {
  133. opt(m)
  134. }
  135. return m
  136. }
  137. // withAgentID sets the ID field of the mutation.
  138. func withAgentID(id uint64) agentOption {
  139. return func(m *AgentMutation) {
  140. var (
  141. err error
  142. once sync.Once
  143. value *Agent
  144. )
  145. m.oldValue = func(ctx context.Context) (*Agent, error) {
  146. once.Do(func() {
  147. if m.done {
  148. err = errors.New("querying old values post mutation is not allowed")
  149. } else {
  150. value, err = m.Client().Agent.Get(ctx, id)
  151. }
  152. })
  153. return value, err
  154. }
  155. m.id = &id
  156. }
  157. }
  158. // withAgent sets the old Agent of the mutation.
  159. func withAgent(node *Agent) agentOption {
  160. return func(m *AgentMutation) {
  161. m.oldValue = func(context.Context) (*Agent, error) {
  162. return node, nil
  163. }
  164. m.id = &node.ID
  165. }
  166. }
  167. // Client returns a new `ent.Client` from the mutation. If the mutation was
  168. // executed in a transaction (ent.Tx), a transactional client is returned.
  169. func (m AgentMutation) Client() *Client {
  170. client := &Client{config: m.config}
  171. client.init()
  172. return client
  173. }
  174. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  175. // it returns an error otherwise.
  176. func (m AgentMutation) Tx() (*Tx, error) {
  177. if _, ok := m.driver.(*txDriver); !ok {
  178. return nil, errors.New("ent: mutation is not running in a transaction")
  179. }
  180. tx := &Tx{config: m.config}
  181. tx.init()
  182. return tx, nil
  183. }
  184. // SetID sets the value of the id field. Note that this
  185. // operation is only accepted on creation of Agent entities.
  186. func (m *AgentMutation) SetID(id uint64) {
  187. m.id = &id
  188. }
  189. // ID returns the ID value in the mutation. Note that the ID is only available
  190. // if it was provided to the builder or after it was returned from the database.
  191. func (m *AgentMutation) ID() (id uint64, exists bool) {
  192. if m.id == nil {
  193. return
  194. }
  195. return *m.id, true
  196. }
  197. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  198. // That means, if the mutation is applied within a transaction with an isolation level such
  199. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  200. // or updated by the mutation.
  201. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  202. switch {
  203. case m.op.Is(OpUpdateOne | OpDeleteOne):
  204. id, exists := m.ID()
  205. if exists {
  206. return []uint64{id}, nil
  207. }
  208. fallthrough
  209. case m.op.Is(OpUpdate | OpDelete):
  210. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  211. default:
  212. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  213. }
  214. }
  215. // SetCreatedAt sets the "created_at" field.
  216. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  217. m.created_at = &t
  218. }
  219. // CreatedAt returns the value of the "created_at" field in the mutation.
  220. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  221. v := m.created_at
  222. if v == nil {
  223. return
  224. }
  225. return *v, true
  226. }
  227. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  228. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  230. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  231. if !m.op.Is(OpUpdateOne) {
  232. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  233. }
  234. if m.id == nil || m.oldValue == nil {
  235. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  236. }
  237. oldValue, err := m.oldValue(ctx)
  238. if err != nil {
  239. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  240. }
  241. return oldValue.CreatedAt, nil
  242. }
  243. // ResetCreatedAt resets all changes to the "created_at" field.
  244. func (m *AgentMutation) ResetCreatedAt() {
  245. m.created_at = nil
  246. }
  247. // SetUpdatedAt sets the "updated_at" field.
  248. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  249. m.updated_at = &t
  250. }
  251. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  252. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  253. v := m.updated_at
  254. if v == nil {
  255. return
  256. }
  257. return *v, true
  258. }
  259. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  260. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  262. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  263. if !m.op.Is(OpUpdateOne) {
  264. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  265. }
  266. if m.id == nil || m.oldValue == nil {
  267. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  268. }
  269. oldValue, err := m.oldValue(ctx)
  270. if err != nil {
  271. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  272. }
  273. return oldValue.UpdatedAt, nil
  274. }
  275. // ResetUpdatedAt resets all changes to the "updated_at" field.
  276. func (m *AgentMutation) ResetUpdatedAt() {
  277. m.updated_at = nil
  278. }
  279. // SetDeletedAt sets the "deleted_at" field.
  280. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  281. m.deleted_at = &t
  282. }
  283. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  284. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  285. v := m.deleted_at
  286. if v == nil {
  287. return
  288. }
  289. return *v, true
  290. }
  291. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  292. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  294. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  295. if !m.op.Is(OpUpdateOne) {
  296. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  297. }
  298. if m.id == nil || m.oldValue == nil {
  299. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  300. }
  301. oldValue, err := m.oldValue(ctx)
  302. if err != nil {
  303. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  304. }
  305. return oldValue.DeletedAt, nil
  306. }
  307. // ClearDeletedAt clears the value of the "deleted_at" field.
  308. func (m *AgentMutation) ClearDeletedAt() {
  309. m.deleted_at = nil
  310. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  311. }
  312. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  313. func (m *AgentMutation) DeletedAtCleared() bool {
  314. _, ok := m.clearedFields[agent.FieldDeletedAt]
  315. return ok
  316. }
  317. // ResetDeletedAt resets all changes to the "deleted_at" field.
  318. func (m *AgentMutation) ResetDeletedAt() {
  319. m.deleted_at = nil
  320. delete(m.clearedFields, agent.FieldDeletedAt)
  321. }
  322. // SetName sets the "name" field.
  323. func (m *AgentMutation) SetName(s string) {
  324. m.name = &s
  325. }
  326. // Name returns the value of the "name" field in the mutation.
  327. func (m *AgentMutation) Name() (r string, exists bool) {
  328. v := m.name
  329. if v == nil {
  330. return
  331. }
  332. return *v, true
  333. }
  334. // OldName returns the old "name" field's value of the Agent entity.
  335. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  337. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  338. if !m.op.Is(OpUpdateOne) {
  339. return v, errors.New("OldName is only allowed on UpdateOne operations")
  340. }
  341. if m.id == nil || m.oldValue == nil {
  342. return v, errors.New("OldName requires an ID field in the mutation")
  343. }
  344. oldValue, err := m.oldValue(ctx)
  345. if err != nil {
  346. return v, fmt.Errorf("querying old value for OldName: %w", err)
  347. }
  348. return oldValue.Name, nil
  349. }
  350. // ResetName resets all changes to the "name" field.
  351. func (m *AgentMutation) ResetName() {
  352. m.name = nil
  353. }
  354. // SetRole sets the "role" field.
  355. func (m *AgentMutation) SetRole(s string) {
  356. m.role = &s
  357. }
  358. // Role returns the value of the "role" field in the mutation.
  359. func (m *AgentMutation) Role() (r string, exists bool) {
  360. v := m.role
  361. if v == nil {
  362. return
  363. }
  364. return *v, true
  365. }
  366. // OldRole returns the old "role" field's value of the Agent entity.
  367. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  369. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  370. if !m.op.Is(OpUpdateOne) {
  371. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  372. }
  373. if m.id == nil || m.oldValue == nil {
  374. return v, errors.New("OldRole requires an ID field in the mutation")
  375. }
  376. oldValue, err := m.oldValue(ctx)
  377. if err != nil {
  378. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  379. }
  380. return oldValue.Role, nil
  381. }
  382. // ResetRole resets all changes to the "role" field.
  383. func (m *AgentMutation) ResetRole() {
  384. m.role = nil
  385. }
  386. // SetStatus sets the "status" field.
  387. func (m *AgentMutation) SetStatus(i int) {
  388. m.status = &i
  389. m.addstatus = nil
  390. }
  391. // Status returns the value of the "status" field in the mutation.
  392. func (m *AgentMutation) Status() (r int, exists bool) {
  393. v := m.status
  394. if v == nil {
  395. return
  396. }
  397. return *v, true
  398. }
  399. // OldStatus returns the old "status" field's value of the Agent entity.
  400. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  402. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  403. if !m.op.Is(OpUpdateOne) {
  404. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  405. }
  406. if m.id == nil || m.oldValue == nil {
  407. return v, errors.New("OldStatus requires an ID field in the mutation")
  408. }
  409. oldValue, err := m.oldValue(ctx)
  410. if err != nil {
  411. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  412. }
  413. return oldValue.Status, nil
  414. }
  415. // AddStatus adds i to the "status" field.
  416. func (m *AgentMutation) AddStatus(i int) {
  417. if m.addstatus != nil {
  418. *m.addstatus += i
  419. } else {
  420. m.addstatus = &i
  421. }
  422. }
  423. // AddedStatus returns the value that was added to the "status" field in this mutation.
  424. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  425. v := m.addstatus
  426. if v == nil {
  427. return
  428. }
  429. return *v, true
  430. }
  431. // ClearStatus clears the value of the "status" field.
  432. func (m *AgentMutation) ClearStatus() {
  433. m.status = nil
  434. m.addstatus = nil
  435. m.clearedFields[agent.FieldStatus] = struct{}{}
  436. }
  437. // StatusCleared returns if the "status" field was cleared in this mutation.
  438. func (m *AgentMutation) StatusCleared() bool {
  439. _, ok := m.clearedFields[agent.FieldStatus]
  440. return ok
  441. }
  442. // ResetStatus resets all changes to the "status" field.
  443. func (m *AgentMutation) ResetStatus() {
  444. m.status = nil
  445. m.addstatus = nil
  446. delete(m.clearedFields, agent.FieldStatus)
  447. }
  448. // SetBackground sets the "background" field.
  449. func (m *AgentMutation) SetBackground(s string) {
  450. m.background = &s
  451. }
  452. // Background returns the value of the "background" field in the mutation.
  453. func (m *AgentMutation) Background() (r string, exists bool) {
  454. v := m.background
  455. if v == nil {
  456. return
  457. }
  458. return *v, true
  459. }
  460. // OldBackground returns the old "background" field's value of the Agent entity.
  461. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  463. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  464. if !m.op.Is(OpUpdateOne) {
  465. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  466. }
  467. if m.id == nil || m.oldValue == nil {
  468. return v, errors.New("OldBackground requires an ID field in the mutation")
  469. }
  470. oldValue, err := m.oldValue(ctx)
  471. if err != nil {
  472. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  473. }
  474. return oldValue.Background, nil
  475. }
  476. // ClearBackground clears the value of the "background" field.
  477. func (m *AgentMutation) ClearBackground() {
  478. m.background = nil
  479. m.clearedFields[agent.FieldBackground] = struct{}{}
  480. }
  481. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  482. func (m *AgentMutation) BackgroundCleared() bool {
  483. _, ok := m.clearedFields[agent.FieldBackground]
  484. return ok
  485. }
  486. // ResetBackground resets all changes to the "background" field.
  487. func (m *AgentMutation) ResetBackground() {
  488. m.background = nil
  489. delete(m.clearedFields, agent.FieldBackground)
  490. }
  491. // SetExamples sets the "examples" field.
  492. func (m *AgentMutation) SetExamples(s string) {
  493. m.examples = &s
  494. }
  495. // Examples returns the value of the "examples" field in the mutation.
  496. func (m *AgentMutation) Examples() (r string, exists bool) {
  497. v := m.examples
  498. if v == nil {
  499. return
  500. }
  501. return *v, true
  502. }
  503. // OldExamples returns the old "examples" field's value of the Agent entity.
  504. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  506. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  507. if !m.op.Is(OpUpdateOne) {
  508. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  509. }
  510. if m.id == nil || m.oldValue == nil {
  511. return v, errors.New("OldExamples requires an ID field in the mutation")
  512. }
  513. oldValue, err := m.oldValue(ctx)
  514. if err != nil {
  515. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  516. }
  517. return oldValue.Examples, nil
  518. }
  519. // ClearExamples clears the value of the "examples" field.
  520. func (m *AgentMutation) ClearExamples() {
  521. m.examples = nil
  522. m.clearedFields[agent.FieldExamples] = struct{}{}
  523. }
  524. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  525. func (m *AgentMutation) ExamplesCleared() bool {
  526. _, ok := m.clearedFields[agent.FieldExamples]
  527. return ok
  528. }
  529. // ResetExamples resets all changes to the "examples" field.
  530. func (m *AgentMutation) ResetExamples() {
  531. m.examples = nil
  532. delete(m.clearedFields, agent.FieldExamples)
  533. }
  534. // SetOrganizationID sets the "organization_id" field.
  535. func (m *AgentMutation) SetOrganizationID(u uint64) {
  536. m.organization_id = &u
  537. m.addorganization_id = nil
  538. }
  539. // OrganizationID returns the value of the "organization_id" field in the mutation.
  540. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  541. v := m.organization_id
  542. if v == nil {
  543. return
  544. }
  545. return *v, true
  546. }
  547. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  548. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  550. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  551. if !m.op.Is(OpUpdateOne) {
  552. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  553. }
  554. if m.id == nil || m.oldValue == nil {
  555. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  556. }
  557. oldValue, err := m.oldValue(ctx)
  558. if err != nil {
  559. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  560. }
  561. return oldValue.OrganizationID, nil
  562. }
  563. // AddOrganizationID adds u to the "organization_id" field.
  564. func (m *AgentMutation) AddOrganizationID(u int64) {
  565. if m.addorganization_id != nil {
  566. *m.addorganization_id += u
  567. } else {
  568. m.addorganization_id = &u
  569. }
  570. }
  571. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  572. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  573. v := m.addorganization_id
  574. if v == nil {
  575. return
  576. }
  577. return *v, true
  578. }
  579. // ResetOrganizationID resets all changes to the "organization_id" field.
  580. func (m *AgentMutation) ResetOrganizationID() {
  581. m.organization_id = nil
  582. m.addorganization_id = nil
  583. }
  584. // SetDatasetID sets the "dataset_id" field.
  585. func (m *AgentMutation) SetDatasetID(s string) {
  586. m.dataset_id = &s
  587. }
  588. // DatasetID returns the value of the "dataset_id" field in the mutation.
  589. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  590. v := m.dataset_id
  591. if v == nil {
  592. return
  593. }
  594. return *v, true
  595. }
  596. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  597. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  599. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  600. if !m.op.Is(OpUpdateOne) {
  601. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  602. }
  603. if m.id == nil || m.oldValue == nil {
  604. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  605. }
  606. oldValue, err := m.oldValue(ctx)
  607. if err != nil {
  608. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  609. }
  610. return oldValue.DatasetID, nil
  611. }
  612. // ResetDatasetID resets all changes to the "dataset_id" field.
  613. func (m *AgentMutation) ResetDatasetID() {
  614. m.dataset_id = nil
  615. }
  616. // SetCollectionID sets the "collection_id" field.
  617. func (m *AgentMutation) SetCollectionID(s string) {
  618. m.collection_id = &s
  619. }
  620. // CollectionID returns the value of the "collection_id" field in the mutation.
  621. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  622. v := m.collection_id
  623. if v == nil {
  624. return
  625. }
  626. return *v, true
  627. }
  628. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  629. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  631. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  632. if !m.op.Is(OpUpdateOne) {
  633. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  634. }
  635. if m.id == nil || m.oldValue == nil {
  636. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  637. }
  638. oldValue, err := m.oldValue(ctx)
  639. if err != nil {
  640. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  641. }
  642. return oldValue.CollectionID, nil
  643. }
  644. // ResetCollectionID resets all changes to the "collection_id" field.
  645. func (m *AgentMutation) ResetCollectionID() {
  646. m.collection_id = nil
  647. }
  648. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  649. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  650. if m.wx_agent == nil {
  651. m.wx_agent = make(map[uint64]struct{})
  652. }
  653. for i := range ids {
  654. m.wx_agent[ids[i]] = struct{}{}
  655. }
  656. }
  657. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  658. func (m *AgentMutation) ClearWxAgent() {
  659. m.clearedwx_agent = true
  660. }
  661. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  662. func (m *AgentMutation) WxAgentCleared() bool {
  663. return m.clearedwx_agent
  664. }
  665. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  666. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  667. if m.removedwx_agent == nil {
  668. m.removedwx_agent = make(map[uint64]struct{})
  669. }
  670. for i := range ids {
  671. delete(m.wx_agent, ids[i])
  672. m.removedwx_agent[ids[i]] = struct{}{}
  673. }
  674. }
  675. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  676. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  677. for id := range m.removedwx_agent {
  678. ids = append(ids, id)
  679. }
  680. return
  681. }
  682. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  683. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  684. for id := range m.wx_agent {
  685. ids = append(ids, id)
  686. }
  687. return
  688. }
  689. // ResetWxAgent resets all changes to the "wx_agent" edge.
  690. func (m *AgentMutation) ResetWxAgent() {
  691. m.wx_agent = nil
  692. m.clearedwx_agent = false
  693. m.removedwx_agent = nil
  694. }
  695. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  696. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  697. if m.token_agent == nil {
  698. m.token_agent = make(map[uint64]struct{})
  699. }
  700. for i := range ids {
  701. m.token_agent[ids[i]] = struct{}{}
  702. }
  703. }
  704. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  705. func (m *AgentMutation) ClearTokenAgent() {
  706. m.clearedtoken_agent = true
  707. }
  708. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  709. func (m *AgentMutation) TokenAgentCleared() bool {
  710. return m.clearedtoken_agent
  711. }
  712. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  713. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  714. if m.removedtoken_agent == nil {
  715. m.removedtoken_agent = make(map[uint64]struct{})
  716. }
  717. for i := range ids {
  718. delete(m.token_agent, ids[i])
  719. m.removedtoken_agent[ids[i]] = struct{}{}
  720. }
  721. }
  722. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  723. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  724. for id := range m.removedtoken_agent {
  725. ids = append(ids, id)
  726. }
  727. return
  728. }
  729. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  730. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  731. for id := range m.token_agent {
  732. ids = append(ids, id)
  733. }
  734. return
  735. }
  736. // ResetTokenAgent resets all changes to the "token_agent" edge.
  737. func (m *AgentMutation) ResetTokenAgent() {
  738. m.token_agent = nil
  739. m.clearedtoken_agent = false
  740. m.removedtoken_agent = nil
  741. }
  742. // Where appends a list predicates to the AgentMutation builder.
  743. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  744. m.predicates = append(m.predicates, ps...)
  745. }
  746. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  747. // users can use type-assertion to append predicates that do not depend on any generated package.
  748. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  749. p := make([]predicate.Agent, len(ps))
  750. for i := range ps {
  751. p[i] = ps[i]
  752. }
  753. m.Where(p...)
  754. }
  755. // Op returns the operation name.
  756. func (m *AgentMutation) Op() Op {
  757. return m.op
  758. }
  759. // SetOp allows setting the mutation operation.
  760. func (m *AgentMutation) SetOp(op Op) {
  761. m.op = op
  762. }
  763. // Type returns the node type of this mutation (Agent).
  764. func (m *AgentMutation) Type() string {
  765. return m.typ
  766. }
  767. // Fields returns all fields that were changed during this mutation. Note that in
  768. // order to get all numeric fields that were incremented/decremented, call
  769. // AddedFields().
  770. func (m *AgentMutation) Fields() []string {
  771. fields := make([]string, 0, 11)
  772. if m.created_at != nil {
  773. fields = append(fields, agent.FieldCreatedAt)
  774. }
  775. if m.updated_at != nil {
  776. fields = append(fields, agent.FieldUpdatedAt)
  777. }
  778. if m.deleted_at != nil {
  779. fields = append(fields, agent.FieldDeletedAt)
  780. }
  781. if m.name != nil {
  782. fields = append(fields, agent.FieldName)
  783. }
  784. if m.role != nil {
  785. fields = append(fields, agent.FieldRole)
  786. }
  787. if m.status != nil {
  788. fields = append(fields, agent.FieldStatus)
  789. }
  790. if m.background != nil {
  791. fields = append(fields, agent.FieldBackground)
  792. }
  793. if m.examples != nil {
  794. fields = append(fields, agent.FieldExamples)
  795. }
  796. if m.organization_id != nil {
  797. fields = append(fields, agent.FieldOrganizationID)
  798. }
  799. if m.dataset_id != nil {
  800. fields = append(fields, agent.FieldDatasetID)
  801. }
  802. if m.collection_id != nil {
  803. fields = append(fields, agent.FieldCollectionID)
  804. }
  805. return fields
  806. }
  807. // Field returns the value of a field with the given name. The second boolean
  808. // return value indicates that this field was not set, or was not defined in the
  809. // schema.
  810. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  811. switch name {
  812. case agent.FieldCreatedAt:
  813. return m.CreatedAt()
  814. case agent.FieldUpdatedAt:
  815. return m.UpdatedAt()
  816. case agent.FieldDeletedAt:
  817. return m.DeletedAt()
  818. case agent.FieldName:
  819. return m.Name()
  820. case agent.FieldRole:
  821. return m.Role()
  822. case agent.FieldStatus:
  823. return m.Status()
  824. case agent.FieldBackground:
  825. return m.Background()
  826. case agent.FieldExamples:
  827. return m.Examples()
  828. case agent.FieldOrganizationID:
  829. return m.OrganizationID()
  830. case agent.FieldDatasetID:
  831. return m.DatasetID()
  832. case agent.FieldCollectionID:
  833. return m.CollectionID()
  834. }
  835. return nil, false
  836. }
  837. // OldField returns the old value of the field from the database. An error is
  838. // returned if the mutation operation is not UpdateOne, or the query to the
  839. // database failed.
  840. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  841. switch name {
  842. case agent.FieldCreatedAt:
  843. return m.OldCreatedAt(ctx)
  844. case agent.FieldUpdatedAt:
  845. return m.OldUpdatedAt(ctx)
  846. case agent.FieldDeletedAt:
  847. return m.OldDeletedAt(ctx)
  848. case agent.FieldName:
  849. return m.OldName(ctx)
  850. case agent.FieldRole:
  851. return m.OldRole(ctx)
  852. case agent.FieldStatus:
  853. return m.OldStatus(ctx)
  854. case agent.FieldBackground:
  855. return m.OldBackground(ctx)
  856. case agent.FieldExamples:
  857. return m.OldExamples(ctx)
  858. case agent.FieldOrganizationID:
  859. return m.OldOrganizationID(ctx)
  860. case agent.FieldDatasetID:
  861. return m.OldDatasetID(ctx)
  862. case agent.FieldCollectionID:
  863. return m.OldCollectionID(ctx)
  864. }
  865. return nil, fmt.Errorf("unknown Agent field %s", name)
  866. }
  867. // SetField sets the value of a field with the given name. It returns an error if
  868. // the field is not defined in the schema, or if the type mismatched the field
  869. // type.
  870. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  871. switch name {
  872. case agent.FieldCreatedAt:
  873. v, ok := value.(time.Time)
  874. if !ok {
  875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  876. }
  877. m.SetCreatedAt(v)
  878. return nil
  879. case agent.FieldUpdatedAt:
  880. v, ok := value.(time.Time)
  881. if !ok {
  882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  883. }
  884. m.SetUpdatedAt(v)
  885. return nil
  886. case agent.FieldDeletedAt:
  887. v, ok := value.(time.Time)
  888. if !ok {
  889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  890. }
  891. m.SetDeletedAt(v)
  892. return nil
  893. case agent.FieldName:
  894. v, ok := value.(string)
  895. if !ok {
  896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  897. }
  898. m.SetName(v)
  899. return nil
  900. case agent.FieldRole:
  901. v, ok := value.(string)
  902. if !ok {
  903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  904. }
  905. m.SetRole(v)
  906. return nil
  907. case agent.FieldStatus:
  908. v, ok := value.(int)
  909. if !ok {
  910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  911. }
  912. m.SetStatus(v)
  913. return nil
  914. case agent.FieldBackground:
  915. v, ok := value.(string)
  916. if !ok {
  917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  918. }
  919. m.SetBackground(v)
  920. return nil
  921. case agent.FieldExamples:
  922. v, ok := value.(string)
  923. if !ok {
  924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  925. }
  926. m.SetExamples(v)
  927. return nil
  928. case agent.FieldOrganizationID:
  929. v, ok := value.(uint64)
  930. if !ok {
  931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  932. }
  933. m.SetOrganizationID(v)
  934. return nil
  935. case agent.FieldDatasetID:
  936. v, ok := value.(string)
  937. if !ok {
  938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  939. }
  940. m.SetDatasetID(v)
  941. return nil
  942. case agent.FieldCollectionID:
  943. v, ok := value.(string)
  944. if !ok {
  945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  946. }
  947. m.SetCollectionID(v)
  948. return nil
  949. }
  950. return fmt.Errorf("unknown Agent field %s", name)
  951. }
  952. // AddedFields returns all numeric fields that were incremented/decremented during
  953. // this mutation.
  954. func (m *AgentMutation) AddedFields() []string {
  955. var fields []string
  956. if m.addstatus != nil {
  957. fields = append(fields, agent.FieldStatus)
  958. }
  959. if m.addorganization_id != nil {
  960. fields = append(fields, agent.FieldOrganizationID)
  961. }
  962. return fields
  963. }
  964. // AddedField returns the numeric value that was incremented/decremented on a field
  965. // with the given name. The second boolean return value indicates that this field
  966. // was not set, or was not defined in the schema.
  967. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  968. switch name {
  969. case agent.FieldStatus:
  970. return m.AddedStatus()
  971. case agent.FieldOrganizationID:
  972. return m.AddedOrganizationID()
  973. }
  974. return nil, false
  975. }
  976. // AddField adds the value to the field with the given name. It returns an error if
  977. // the field is not defined in the schema, or if the type mismatched the field
  978. // type.
  979. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  980. switch name {
  981. case agent.FieldStatus:
  982. v, ok := value.(int)
  983. if !ok {
  984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  985. }
  986. m.AddStatus(v)
  987. return nil
  988. case agent.FieldOrganizationID:
  989. v, ok := value.(int64)
  990. if !ok {
  991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  992. }
  993. m.AddOrganizationID(v)
  994. return nil
  995. }
  996. return fmt.Errorf("unknown Agent numeric field %s", name)
  997. }
  998. // ClearedFields returns all nullable fields that were cleared during this
  999. // mutation.
  1000. func (m *AgentMutation) ClearedFields() []string {
  1001. var fields []string
  1002. if m.FieldCleared(agent.FieldDeletedAt) {
  1003. fields = append(fields, agent.FieldDeletedAt)
  1004. }
  1005. if m.FieldCleared(agent.FieldStatus) {
  1006. fields = append(fields, agent.FieldStatus)
  1007. }
  1008. if m.FieldCleared(agent.FieldBackground) {
  1009. fields = append(fields, agent.FieldBackground)
  1010. }
  1011. if m.FieldCleared(agent.FieldExamples) {
  1012. fields = append(fields, agent.FieldExamples)
  1013. }
  1014. return fields
  1015. }
  1016. // FieldCleared returns a boolean indicating if a field with the given name was
  1017. // cleared in this mutation.
  1018. func (m *AgentMutation) FieldCleared(name string) bool {
  1019. _, ok := m.clearedFields[name]
  1020. return ok
  1021. }
  1022. // ClearField clears the value of the field with the given name. It returns an
  1023. // error if the field is not defined in the schema.
  1024. func (m *AgentMutation) ClearField(name string) error {
  1025. switch name {
  1026. case agent.FieldDeletedAt:
  1027. m.ClearDeletedAt()
  1028. return nil
  1029. case agent.FieldStatus:
  1030. m.ClearStatus()
  1031. return nil
  1032. case agent.FieldBackground:
  1033. m.ClearBackground()
  1034. return nil
  1035. case agent.FieldExamples:
  1036. m.ClearExamples()
  1037. return nil
  1038. }
  1039. return fmt.Errorf("unknown Agent nullable field %s", name)
  1040. }
  1041. // ResetField resets all changes in the mutation for the field with the given name.
  1042. // It returns an error if the field is not defined in the schema.
  1043. func (m *AgentMutation) ResetField(name string) error {
  1044. switch name {
  1045. case agent.FieldCreatedAt:
  1046. m.ResetCreatedAt()
  1047. return nil
  1048. case agent.FieldUpdatedAt:
  1049. m.ResetUpdatedAt()
  1050. return nil
  1051. case agent.FieldDeletedAt:
  1052. m.ResetDeletedAt()
  1053. return nil
  1054. case agent.FieldName:
  1055. m.ResetName()
  1056. return nil
  1057. case agent.FieldRole:
  1058. m.ResetRole()
  1059. return nil
  1060. case agent.FieldStatus:
  1061. m.ResetStatus()
  1062. return nil
  1063. case agent.FieldBackground:
  1064. m.ResetBackground()
  1065. return nil
  1066. case agent.FieldExamples:
  1067. m.ResetExamples()
  1068. return nil
  1069. case agent.FieldOrganizationID:
  1070. m.ResetOrganizationID()
  1071. return nil
  1072. case agent.FieldDatasetID:
  1073. m.ResetDatasetID()
  1074. return nil
  1075. case agent.FieldCollectionID:
  1076. m.ResetCollectionID()
  1077. return nil
  1078. }
  1079. return fmt.Errorf("unknown Agent field %s", name)
  1080. }
  1081. // AddedEdges returns all edge names that were set/added in this mutation.
  1082. func (m *AgentMutation) AddedEdges() []string {
  1083. edges := make([]string, 0, 2)
  1084. if m.wx_agent != nil {
  1085. edges = append(edges, agent.EdgeWxAgent)
  1086. }
  1087. if m.token_agent != nil {
  1088. edges = append(edges, agent.EdgeTokenAgent)
  1089. }
  1090. return edges
  1091. }
  1092. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1093. // name in this mutation.
  1094. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1095. switch name {
  1096. case agent.EdgeWxAgent:
  1097. ids := make([]ent.Value, 0, len(m.wx_agent))
  1098. for id := range m.wx_agent {
  1099. ids = append(ids, id)
  1100. }
  1101. return ids
  1102. case agent.EdgeTokenAgent:
  1103. ids := make([]ent.Value, 0, len(m.token_agent))
  1104. for id := range m.token_agent {
  1105. ids = append(ids, id)
  1106. }
  1107. return ids
  1108. }
  1109. return nil
  1110. }
  1111. // RemovedEdges returns all edge names that were removed in this mutation.
  1112. func (m *AgentMutation) RemovedEdges() []string {
  1113. edges := make([]string, 0, 2)
  1114. if m.removedwx_agent != nil {
  1115. edges = append(edges, agent.EdgeWxAgent)
  1116. }
  1117. if m.removedtoken_agent != nil {
  1118. edges = append(edges, agent.EdgeTokenAgent)
  1119. }
  1120. return edges
  1121. }
  1122. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1123. // the given name in this mutation.
  1124. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1125. switch name {
  1126. case agent.EdgeWxAgent:
  1127. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1128. for id := range m.removedwx_agent {
  1129. ids = append(ids, id)
  1130. }
  1131. return ids
  1132. case agent.EdgeTokenAgent:
  1133. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1134. for id := range m.removedtoken_agent {
  1135. ids = append(ids, id)
  1136. }
  1137. return ids
  1138. }
  1139. return nil
  1140. }
  1141. // ClearedEdges returns all edge names that were cleared in this mutation.
  1142. func (m *AgentMutation) ClearedEdges() []string {
  1143. edges := make([]string, 0, 2)
  1144. if m.clearedwx_agent {
  1145. edges = append(edges, agent.EdgeWxAgent)
  1146. }
  1147. if m.clearedtoken_agent {
  1148. edges = append(edges, agent.EdgeTokenAgent)
  1149. }
  1150. return edges
  1151. }
  1152. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1153. // was cleared in this mutation.
  1154. func (m *AgentMutation) EdgeCleared(name string) bool {
  1155. switch name {
  1156. case agent.EdgeWxAgent:
  1157. return m.clearedwx_agent
  1158. case agent.EdgeTokenAgent:
  1159. return m.clearedtoken_agent
  1160. }
  1161. return false
  1162. }
  1163. // ClearEdge clears the value of the edge with the given name. It returns an error
  1164. // if that edge is not defined in the schema.
  1165. func (m *AgentMutation) ClearEdge(name string) error {
  1166. switch name {
  1167. }
  1168. return fmt.Errorf("unknown Agent unique edge %s", name)
  1169. }
  1170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1171. // It returns an error if the edge is not defined in the schema.
  1172. func (m *AgentMutation) ResetEdge(name string) error {
  1173. switch name {
  1174. case agent.EdgeWxAgent:
  1175. m.ResetWxAgent()
  1176. return nil
  1177. case agent.EdgeTokenAgent:
  1178. m.ResetTokenAgent()
  1179. return nil
  1180. }
  1181. return fmt.Errorf("unknown Agent edge %s", name)
  1182. }
  1183. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1184. type AgentBaseMutation struct {
  1185. config
  1186. op Op
  1187. typ string
  1188. id *string
  1189. q *string
  1190. a *string
  1191. chunk_index *uint64
  1192. addchunk_index *int64
  1193. indexes *[]string
  1194. appendindexes []string
  1195. dataset_id *string
  1196. collection_id *string
  1197. source_name *string
  1198. can_write *[]bool
  1199. appendcan_write []bool
  1200. is_owner *[]bool
  1201. appendis_owner []bool
  1202. clearedFields map[string]struct{}
  1203. wx_agent map[uint64]struct{}
  1204. removedwx_agent map[uint64]struct{}
  1205. clearedwx_agent bool
  1206. done bool
  1207. oldValue func(context.Context) (*AgentBase, error)
  1208. predicates []predicate.AgentBase
  1209. }
  1210. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1211. // agentbaseOption allows management of the mutation configuration using functional options.
  1212. type agentbaseOption func(*AgentBaseMutation)
  1213. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1214. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1215. m := &AgentBaseMutation{
  1216. config: c,
  1217. op: op,
  1218. typ: TypeAgentBase,
  1219. clearedFields: make(map[string]struct{}),
  1220. }
  1221. for _, opt := range opts {
  1222. opt(m)
  1223. }
  1224. return m
  1225. }
  1226. // withAgentBaseID sets the ID field of the mutation.
  1227. func withAgentBaseID(id string) agentbaseOption {
  1228. return func(m *AgentBaseMutation) {
  1229. var (
  1230. err error
  1231. once sync.Once
  1232. value *AgentBase
  1233. )
  1234. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1235. once.Do(func() {
  1236. if m.done {
  1237. err = errors.New("querying old values post mutation is not allowed")
  1238. } else {
  1239. value, err = m.Client().AgentBase.Get(ctx, id)
  1240. }
  1241. })
  1242. return value, err
  1243. }
  1244. m.id = &id
  1245. }
  1246. }
  1247. // withAgentBase sets the old AgentBase of the mutation.
  1248. func withAgentBase(node *AgentBase) agentbaseOption {
  1249. return func(m *AgentBaseMutation) {
  1250. m.oldValue = func(context.Context) (*AgentBase, error) {
  1251. return node, nil
  1252. }
  1253. m.id = &node.ID
  1254. }
  1255. }
  1256. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1257. // executed in a transaction (ent.Tx), a transactional client is returned.
  1258. func (m AgentBaseMutation) Client() *Client {
  1259. client := &Client{config: m.config}
  1260. client.init()
  1261. return client
  1262. }
  1263. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1264. // it returns an error otherwise.
  1265. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1266. if _, ok := m.driver.(*txDriver); !ok {
  1267. return nil, errors.New("ent: mutation is not running in a transaction")
  1268. }
  1269. tx := &Tx{config: m.config}
  1270. tx.init()
  1271. return tx, nil
  1272. }
  1273. // SetID sets the value of the id field. Note that this
  1274. // operation is only accepted on creation of AgentBase entities.
  1275. func (m *AgentBaseMutation) SetID(id string) {
  1276. m.id = &id
  1277. }
  1278. // ID returns the ID value in the mutation. Note that the ID is only available
  1279. // if it was provided to the builder or after it was returned from the database.
  1280. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1281. if m.id == nil {
  1282. return
  1283. }
  1284. return *m.id, true
  1285. }
  1286. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1287. // That means, if the mutation is applied within a transaction with an isolation level such
  1288. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1289. // or updated by the mutation.
  1290. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1291. switch {
  1292. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1293. id, exists := m.ID()
  1294. if exists {
  1295. return []string{id}, nil
  1296. }
  1297. fallthrough
  1298. case m.op.Is(OpUpdate | OpDelete):
  1299. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1300. default:
  1301. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1302. }
  1303. }
  1304. // SetQ sets the "q" field.
  1305. func (m *AgentBaseMutation) SetQ(s string) {
  1306. m.q = &s
  1307. }
  1308. // Q returns the value of the "q" field in the mutation.
  1309. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1310. v := m.q
  1311. if v == nil {
  1312. return
  1313. }
  1314. return *v, true
  1315. }
  1316. // OldQ returns the old "q" field's value of the AgentBase entity.
  1317. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1319. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1320. if !m.op.Is(OpUpdateOne) {
  1321. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1322. }
  1323. if m.id == nil || m.oldValue == nil {
  1324. return v, errors.New("OldQ requires an ID field in the mutation")
  1325. }
  1326. oldValue, err := m.oldValue(ctx)
  1327. if err != nil {
  1328. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1329. }
  1330. return oldValue.Q, nil
  1331. }
  1332. // ClearQ clears the value of the "q" field.
  1333. func (m *AgentBaseMutation) ClearQ() {
  1334. m.q = nil
  1335. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1336. }
  1337. // QCleared returns if the "q" field was cleared in this mutation.
  1338. func (m *AgentBaseMutation) QCleared() bool {
  1339. _, ok := m.clearedFields[agentbase.FieldQ]
  1340. return ok
  1341. }
  1342. // ResetQ resets all changes to the "q" field.
  1343. func (m *AgentBaseMutation) ResetQ() {
  1344. m.q = nil
  1345. delete(m.clearedFields, agentbase.FieldQ)
  1346. }
  1347. // SetA sets the "a" field.
  1348. func (m *AgentBaseMutation) SetA(s string) {
  1349. m.a = &s
  1350. }
  1351. // A returns the value of the "a" field in the mutation.
  1352. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1353. v := m.a
  1354. if v == nil {
  1355. return
  1356. }
  1357. return *v, true
  1358. }
  1359. // OldA returns the old "a" field's value of the AgentBase entity.
  1360. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1362. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1363. if !m.op.Is(OpUpdateOne) {
  1364. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1365. }
  1366. if m.id == nil || m.oldValue == nil {
  1367. return v, errors.New("OldA requires an ID field in the mutation")
  1368. }
  1369. oldValue, err := m.oldValue(ctx)
  1370. if err != nil {
  1371. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1372. }
  1373. return oldValue.A, nil
  1374. }
  1375. // ClearA clears the value of the "a" field.
  1376. func (m *AgentBaseMutation) ClearA() {
  1377. m.a = nil
  1378. m.clearedFields[agentbase.FieldA] = struct{}{}
  1379. }
  1380. // ACleared returns if the "a" field was cleared in this mutation.
  1381. func (m *AgentBaseMutation) ACleared() bool {
  1382. _, ok := m.clearedFields[agentbase.FieldA]
  1383. return ok
  1384. }
  1385. // ResetA resets all changes to the "a" field.
  1386. func (m *AgentBaseMutation) ResetA() {
  1387. m.a = nil
  1388. delete(m.clearedFields, agentbase.FieldA)
  1389. }
  1390. // SetChunkIndex sets the "chunk_index" field.
  1391. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1392. m.chunk_index = &u
  1393. m.addchunk_index = nil
  1394. }
  1395. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1396. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1397. v := m.chunk_index
  1398. if v == nil {
  1399. return
  1400. }
  1401. return *v, true
  1402. }
  1403. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1404. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1406. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1407. if !m.op.Is(OpUpdateOne) {
  1408. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1409. }
  1410. if m.id == nil || m.oldValue == nil {
  1411. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1412. }
  1413. oldValue, err := m.oldValue(ctx)
  1414. if err != nil {
  1415. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1416. }
  1417. return oldValue.ChunkIndex, nil
  1418. }
  1419. // AddChunkIndex adds u to the "chunk_index" field.
  1420. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1421. if m.addchunk_index != nil {
  1422. *m.addchunk_index += u
  1423. } else {
  1424. m.addchunk_index = &u
  1425. }
  1426. }
  1427. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1428. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1429. v := m.addchunk_index
  1430. if v == nil {
  1431. return
  1432. }
  1433. return *v, true
  1434. }
  1435. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1436. func (m *AgentBaseMutation) ResetChunkIndex() {
  1437. m.chunk_index = nil
  1438. m.addchunk_index = nil
  1439. }
  1440. // SetIndexes sets the "indexes" field.
  1441. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1442. m.indexes = &s
  1443. m.appendindexes = nil
  1444. }
  1445. // Indexes returns the value of the "indexes" field in the mutation.
  1446. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1447. v := m.indexes
  1448. if v == nil {
  1449. return
  1450. }
  1451. return *v, true
  1452. }
  1453. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1454. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1456. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1457. if !m.op.Is(OpUpdateOne) {
  1458. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1459. }
  1460. if m.id == nil || m.oldValue == nil {
  1461. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1462. }
  1463. oldValue, err := m.oldValue(ctx)
  1464. if err != nil {
  1465. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1466. }
  1467. return oldValue.Indexes, nil
  1468. }
  1469. // AppendIndexes adds s to the "indexes" field.
  1470. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1471. m.appendindexes = append(m.appendindexes, s...)
  1472. }
  1473. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1474. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1475. if len(m.appendindexes) == 0 {
  1476. return nil, false
  1477. }
  1478. return m.appendindexes, true
  1479. }
  1480. // ClearIndexes clears the value of the "indexes" field.
  1481. func (m *AgentBaseMutation) ClearIndexes() {
  1482. m.indexes = nil
  1483. m.appendindexes = nil
  1484. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1485. }
  1486. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1487. func (m *AgentBaseMutation) IndexesCleared() bool {
  1488. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1489. return ok
  1490. }
  1491. // ResetIndexes resets all changes to the "indexes" field.
  1492. func (m *AgentBaseMutation) ResetIndexes() {
  1493. m.indexes = nil
  1494. m.appendindexes = nil
  1495. delete(m.clearedFields, agentbase.FieldIndexes)
  1496. }
  1497. // SetDatasetID sets the "dataset_id" field.
  1498. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1499. m.dataset_id = &s
  1500. }
  1501. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1502. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1503. v := m.dataset_id
  1504. if v == nil {
  1505. return
  1506. }
  1507. return *v, true
  1508. }
  1509. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1510. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1512. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1513. if !m.op.Is(OpUpdateOne) {
  1514. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1515. }
  1516. if m.id == nil || m.oldValue == nil {
  1517. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1518. }
  1519. oldValue, err := m.oldValue(ctx)
  1520. if err != nil {
  1521. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1522. }
  1523. return oldValue.DatasetID, nil
  1524. }
  1525. // ClearDatasetID clears the value of the "dataset_id" field.
  1526. func (m *AgentBaseMutation) ClearDatasetID() {
  1527. m.dataset_id = nil
  1528. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1529. }
  1530. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1531. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1532. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1533. return ok
  1534. }
  1535. // ResetDatasetID resets all changes to the "dataset_id" field.
  1536. func (m *AgentBaseMutation) ResetDatasetID() {
  1537. m.dataset_id = nil
  1538. delete(m.clearedFields, agentbase.FieldDatasetID)
  1539. }
  1540. // SetCollectionID sets the "collection_id" field.
  1541. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1542. m.collection_id = &s
  1543. }
  1544. // CollectionID returns the value of the "collection_id" field in the mutation.
  1545. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1546. v := m.collection_id
  1547. if v == nil {
  1548. return
  1549. }
  1550. return *v, true
  1551. }
  1552. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1553. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1555. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1556. if !m.op.Is(OpUpdateOne) {
  1557. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1558. }
  1559. if m.id == nil || m.oldValue == nil {
  1560. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1561. }
  1562. oldValue, err := m.oldValue(ctx)
  1563. if err != nil {
  1564. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1565. }
  1566. return oldValue.CollectionID, nil
  1567. }
  1568. // ClearCollectionID clears the value of the "collection_id" field.
  1569. func (m *AgentBaseMutation) ClearCollectionID() {
  1570. m.collection_id = nil
  1571. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1572. }
  1573. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1574. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1575. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1576. return ok
  1577. }
  1578. // ResetCollectionID resets all changes to the "collection_id" field.
  1579. func (m *AgentBaseMutation) ResetCollectionID() {
  1580. m.collection_id = nil
  1581. delete(m.clearedFields, agentbase.FieldCollectionID)
  1582. }
  1583. // SetSourceName sets the "source_name" field.
  1584. func (m *AgentBaseMutation) SetSourceName(s string) {
  1585. m.source_name = &s
  1586. }
  1587. // SourceName returns the value of the "source_name" field in the mutation.
  1588. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1589. v := m.source_name
  1590. if v == nil {
  1591. return
  1592. }
  1593. return *v, true
  1594. }
  1595. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1596. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1598. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1599. if !m.op.Is(OpUpdateOne) {
  1600. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1601. }
  1602. if m.id == nil || m.oldValue == nil {
  1603. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1604. }
  1605. oldValue, err := m.oldValue(ctx)
  1606. if err != nil {
  1607. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1608. }
  1609. return oldValue.SourceName, nil
  1610. }
  1611. // ClearSourceName clears the value of the "source_name" field.
  1612. func (m *AgentBaseMutation) ClearSourceName() {
  1613. m.source_name = nil
  1614. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1615. }
  1616. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1617. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1618. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1619. return ok
  1620. }
  1621. // ResetSourceName resets all changes to the "source_name" field.
  1622. func (m *AgentBaseMutation) ResetSourceName() {
  1623. m.source_name = nil
  1624. delete(m.clearedFields, agentbase.FieldSourceName)
  1625. }
  1626. // SetCanWrite sets the "can_write" field.
  1627. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1628. m.can_write = &b
  1629. m.appendcan_write = nil
  1630. }
  1631. // CanWrite returns the value of the "can_write" field in the mutation.
  1632. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1633. v := m.can_write
  1634. if v == nil {
  1635. return
  1636. }
  1637. return *v, true
  1638. }
  1639. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1640. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1642. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1643. if !m.op.Is(OpUpdateOne) {
  1644. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1645. }
  1646. if m.id == nil || m.oldValue == nil {
  1647. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1648. }
  1649. oldValue, err := m.oldValue(ctx)
  1650. if err != nil {
  1651. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1652. }
  1653. return oldValue.CanWrite, nil
  1654. }
  1655. // AppendCanWrite adds b to the "can_write" field.
  1656. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1657. m.appendcan_write = append(m.appendcan_write, b...)
  1658. }
  1659. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1660. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1661. if len(m.appendcan_write) == 0 {
  1662. return nil, false
  1663. }
  1664. return m.appendcan_write, true
  1665. }
  1666. // ClearCanWrite clears the value of the "can_write" field.
  1667. func (m *AgentBaseMutation) ClearCanWrite() {
  1668. m.can_write = nil
  1669. m.appendcan_write = nil
  1670. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1671. }
  1672. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1673. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1674. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1675. return ok
  1676. }
  1677. // ResetCanWrite resets all changes to the "can_write" field.
  1678. func (m *AgentBaseMutation) ResetCanWrite() {
  1679. m.can_write = nil
  1680. m.appendcan_write = nil
  1681. delete(m.clearedFields, agentbase.FieldCanWrite)
  1682. }
  1683. // SetIsOwner sets the "is_owner" field.
  1684. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1685. m.is_owner = &b
  1686. m.appendis_owner = nil
  1687. }
  1688. // IsOwner returns the value of the "is_owner" field in the mutation.
  1689. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1690. v := m.is_owner
  1691. if v == nil {
  1692. return
  1693. }
  1694. return *v, true
  1695. }
  1696. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1697. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1699. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1700. if !m.op.Is(OpUpdateOne) {
  1701. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1702. }
  1703. if m.id == nil || m.oldValue == nil {
  1704. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1705. }
  1706. oldValue, err := m.oldValue(ctx)
  1707. if err != nil {
  1708. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1709. }
  1710. return oldValue.IsOwner, nil
  1711. }
  1712. // AppendIsOwner adds b to the "is_owner" field.
  1713. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1714. m.appendis_owner = append(m.appendis_owner, b...)
  1715. }
  1716. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1717. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1718. if len(m.appendis_owner) == 0 {
  1719. return nil, false
  1720. }
  1721. return m.appendis_owner, true
  1722. }
  1723. // ClearIsOwner clears the value of the "is_owner" field.
  1724. func (m *AgentBaseMutation) ClearIsOwner() {
  1725. m.is_owner = nil
  1726. m.appendis_owner = nil
  1727. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1728. }
  1729. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1730. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1731. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1732. return ok
  1733. }
  1734. // ResetIsOwner resets all changes to the "is_owner" field.
  1735. func (m *AgentBaseMutation) ResetIsOwner() {
  1736. m.is_owner = nil
  1737. m.appendis_owner = nil
  1738. delete(m.clearedFields, agentbase.FieldIsOwner)
  1739. }
  1740. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1741. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1742. if m.wx_agent == nil {
  1743. m.wx_agent = make(map[uint64]struct{})
  1744. }
  1745. for i := range ids {
  1746. m.wx_agent[ids[i]] = struct{}{}
  1747. }
  1748. }
  1749. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1750. func (m *AgentBaseMutation) ClearWxAgent() {
  1751. m.clearedwx_agent = true
  1752. }
  1753. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1754. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1755. return m.clearedwx_agent
  1756. }
  1757. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1758. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1759. if m.removedwx_agent == nil {
  1760. m.removedwx_agent = make(map[uint64]struct{})
  1761. }
  1762. for i := range ids {
  1763. delete(m.wx_agent, ids[i])
  1764. m.removedwx_agent[ids[i]] = struct{}{}
  1765. }
  1766. }
  1767. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1768. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1769. for id := range m.removedwx_agent {
  1770. ids = append(ids, id)
  1771. }
  1772. return
  1773. }
  1774. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1775. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1776. for id := range m.wx_agent {
  1777. ids = append(ids, id)
  1778. }
  1779. return
  1780. }
  1781. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1782. func (m *AgentBaseMutation) ResetWxAgent() {
  1783. m.wx_agent = nil
  1784. m.clearedwx_agent = false
  1785. m.removedwx_agent = nil
  1786. }
  1787. // Where appends a list predicates to the AgentBaseMutation builder.
  1788. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1789. m.predicates = append(m.predicates, ps...)
  1790. }
  1791. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1792. // users can use type-assertion to append predicates that do not depend on any generated package.
  1793. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1794. p := make([]predicate.AgentBase, len(ps))
  1795. for i := range ps {
  1796. p[i] = ps[i]
  1797. }
  1798. m.Where(p...)
  1799. }
  1800. // Op returns the operation name.
  1801. func (m *AgentBaseMutation) Op() Op {
  1802. return m.op
  1803. }
  1804. // SetOp allows setting the mutation operation.
  1805. func (m *AgentBaseMutation) SetOp(op Op) {
  1806. m.op = op
  1807. }
  1808. // Type returns the node type of this mutation (AgentBase).
  1809. func (m *AgentBaseMutation) Type() string {
  1810. return m.typ
  1811. }
  1812. // Fields returns all fields that were changed during this mutation. Note that in
  1813. // order to get all numeric fields that were incremented/decremented, call
  1814. // AddedFields().
  1815. func (m *AgentBaseMutation) Fields() []string {
  1816. fields := make([]string, 0, 9)
  1817. if m.q != nil {
  1818. fields = append(fields, agentbase.FieldQ)
  1819. }
  1820. if m.a != nil {
  1821. fields = append(fields, agentbase.FieldA)
  1822. }
  1823. if m.chunk_index != nil {
  1824. fields = append(fields, agentbase.FieldChunkIndex)
  1825. }
  1826. if m.indexes != nil {
  1827. fields = append(fields, agentbase.FieldIndexes)
  1828. }
  1829. if m.dataset_id != nil {
  1830. fields = append(fields, agentbase.FieldDatasetID)
  1831. }
  1832. if m.collection_id != nil {
  1833. fields = append(fields, agentbase.FieldCollectionID)
  1834. }
  1835. if m.source_name != nil {
  1836. fields = append(fields, agentbase.FieldSourceName)
  1837. }
  1838. if m.can_write != nil {
  1839. fields = append(fields, agentbase.FieldCanWrite)
  1840. }
  1841. if m.is_owner != nil {
  1842. fields = append(fields, agentbase.FieldIsOwner)
  1843. }
  1844. return fields
  1845. }
  1846. // Field returns the value of a field with the given name. The second boolean
  1847. // return value indicates that this field was not set, or was not defined in the
  1848. // schema.
  1849. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1850. switch name {
  1851. case agentbase.FieldQ:
  1852. return m.Q()
  1853. case agentbase.FieldA:
  1854. return m.A()
  1855. case agentbase.FieldChunkIndex:
  1856. return m.ChunkIndex()
  1857. case agentbase.FieldIndexes:
  1858. return m.Indexes()
  1859. case agentbase.FieldDatasetID:
  1860. return m.DatasetID()
  1861. case agentbase.FieldCollectionID:
  1862. return m.CollectionID()
  1863. case agentbase.FieldSourceName:
  1864. return m.SourceName()
  1865. case agentbase.FieldCanWrite:
  1866. return m.CanWrite()
  1867. case agentbase.FieldIsOwner:
  1868. return m.IsOwner()
  1869. }
  1870. return nil, false
  1871. }
  1872. // OldField returns the old value of the field from the database. An error is
  1873. // returned if the mutation operation is not UpdateOne, or the query to the
  1874. // database failed.
  1875. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1876. switch name {
  1877. case agentbase.FieldQ:
  1878. return m.OldQ(ctx)
  1879. case agentbase.FieldA:
  1880. return m.OldA(ctx)
  1881. case agentbase.FieldChunkIndex:
  1882. return m.OldChunkIndex(ctx)
  1883. case agentbase.FieldIndexes:
  1884. return m.OldIndexes(ctx)
  1885. case agentbase.FieldDatasetID:
  1886. return m.OldDatasetID(ctx)
  1887. case agentbase.FieldCollectionID:
  1888. return m.OldCollectionID(ctx)
  1889. case agentbase.FieldSourceName:
  1890. return m.OldSourceName(ctx)
  1891. case agentbase.FieldCanWrite:
  1892. return m.OldCanWrite(ctx)
  1893. case agentbase.FieldIsOwner:
  1894. return m.OldIsOwner(ctx)
  1895. }
  1896. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1897. }
  1898. // SetField sets the value of a field with the given name. It returns an error if
  1899. // the field is not defined in the schema, or if the type mismatched the field
  1900. // type.
  1901. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1902. switch name {
  1903. case agentbase.FieldQ:
  1904. v, ok := value.(string)
  1905. if !ok {
  1906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1907. }
  1908. m.SetQ(v)
  1909. return nil
  1910. case agentbase.FieldA:
  1911. v, ok := value.(string)
  1912. if !ok {
  1913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1914. }
  1915. m.SetA(v)
  1916. return nil
  1917. case agentbase.FieldChunkIndex:
  1918. v, ok := value.(uint64)
  1919. if !ok {
  1920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1921. }
  1922. m.SetChunkIndex(v)
  1923. return nil
  1924. case agentbase.FieldIndexes:
  1925. v, ok := value.([]string)
  1926. if !ok {
  1927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1928. }
  1929. m.SetIndexes(v)
  1930. return nil
  1931. case agentbase.FieldDatasetID:
  1932. v, ok := value.(string)
  1933. if !ok {
  1934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1935. }
  1936. m.SetDatasetID(v)
  1937. return nil
  1938. case agentbase.FieldCollectionID:
  1939. v, ok := value.(string)
  1940. if !ok {
  1941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1942. }
  1943. m.SetCollectionID(v)
  1944. return nil
  1945. case agentbase.FieldSourceName:
  1946. v, ok := value.(string)
  1947. if !ok {
  1948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1949. }
  1950. m.SetSourceName(v)
  1951. return nil
  1952. case agentbase.FieldCanWrite:
  1953. v, ok := value.([]bool)
  1954. if !ok {
  1955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1956. }
  1957. m.SetCanWrite(v)
  1958. return nil
  1959. case agentbase.FieldIsOwner:
  1960. v, ok := value.([]bool)
  1961. if !ok {
  1962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1963. }
  1964. m.SetIsOwner(v)
  1965. return nil
  1966. }
  1967. return fmt.Errorf("unknown AgentBase field %s", name)
  1968. }
  1969. // AddedFields returns all numeric fields that were incremented/decremented during
  1970. // this mutation.
  1971. func (m *AgentBaseMutation) AddedFields() []string {
  1972. var fields []string
  1973. if m.addchunk_index != nil {
  1974. fields = append(fields, agentbase.FieldChunkIndex)
  1975. }
  1976. return fields
  1977. }
  1978. // AddedField returns the numeric value that was incremented/decremented on a field
  1979. // with the given name. The second boolean return value indicates that this field
  1980. // was not set, or was not defined in the schema.
  1981. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1982. switch name {
  1983. case agentbase.FieldChunkIndex:
  1984. return m.AddedChunkIndex()
  1985. }
  1986. return nil, false
  1987. }
  1988. // AddField adds the value to the field with the given name. It returns an error if
  1989. // the field is not defined in the schema, or if the type mismatched the field
  1990. // type.
  1991. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1992. switch name {
  1993. case agentbase.FieldChunkIndex:
  1994. v, ok := value.(int64)
  1995. if !ok {
  1996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1997. }
  1998. m.AddChunkIndex(v)
  1999. return nil
  2000. }
  2001. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2002. }
  2003. // ClearedFields returns all nullable fields that were cleared during this
  2004. // mutation.
  2005. func (m *AgentBaseMutation) ClearedFields() []string {
  2006. var fields []string
  2007. if m.FieldCleared(agentbase.FieldQ) {
  2008. fields = append(fields, agentbase.FieldQ)
  2009. }
  2010. if m.FieldCleared(agentbase.FieldA) {
  2011. fields = append(fields, agentbase.FieldA)
  2012. }
  2013. if m.FieldCleared(agentbase.FieldIndexes) {
  2014. fields = append(fields, agentbase.FieldIndexes)
  2015. }
  2016. if m.FieldCleared(agentbase.FieldDatasetID) {
  2017. fields = append(fields, agentbase.FieldDatasetID)
  2018. }
  2019. if m.FieldCleared(agentbase.FieldCollectionID) {
  2020. fields = append(fields, agentbase.FieldCollectionID)
  2021. }
  2022. if m.FieldCleared(agentbase.FieldSourceName) {
  2023. fields = append(fields, agentbase.FieldSourceName)
  2024. }
  2025. if m.FieldCleared(agentbase.FieldCanWrite) {
  2026. fields = append(fields, agentbase.FieldCanWrite)
  2027. }
  2028. if m.FieldCleared(agentbase.FieldIsOwner) {
  2029. fields = append(fields, agentbase.FieldIsOwner)
  2030. }
  2031. return fields
  2032. }
  2033. // FieldCleared returns a boolean indicating if a field with the given name was
  2034. // cleared in this mutation.
  2035. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2036. _, ok := m.clearedFields[name]
  2037. return ok
  2038. }
  2039. // ClearField clears the value of the field with the given name. It returns an
  2040. // error if the field is not defined in the schema.
  2041. func (m *AgentBaseMutation) ClearField(name string) error {
  2042. switch name {
  2043. case agentbase.FieldQ:
  2044. m.ClearQ()
  2045. return nil
  2046. case agentbase.FieldA:
  2047. m.ClearA()
  2048. return nil
  2049. case agentbase.FieldIndexes:
  2050. m.ClearIndexes()
  2051. return nil
  2052. case agentbase.FieldDatasetID:
  2053. m.ClearDatasetID()
  2054. return nil
  2055. case agentbase.FieldCollectionID:
  2056. m.ClearCollectionID()
  2057. return nil
  2058. case agentbase.FieldSourceName:
  2059. m.ClearSourceName()
  2060. return nil
  2061. case agentbase.FieldCanWrite:
  2062. m.ClearCanWrite()
  2063. return nil
  2064. case agentbase.FieldIsOwner:
  2065. m.ClearIsOwner()
  2066. return nil
  2067. }
  2068. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2069. }
  2070. // ResetField resets all changes in the mutation for the field with the given name.
  2071. // It returns an error if the field is not defined in the schema.
  2072. func (m *AgentBaseMutation) ResetField(name string) error {
  2073. switch name {
  2074. case agentbase.FieldQ:
  2075. m.ResetQ()
  2076. return nil
  2077. case agentbase.FieldA:
  2078. m.ResetA()
  2079. return nil
  2080. case agentbase.FieldChunkIndex:
  2081. m.ResetChunkIndex()
  2082. return nil
  2083. case agentbase.FieldIndexes:
  2084. m.ResetIndexes()
  2085. return nil
  2086. case agentbase.FieldDatasetID:
  2087. m.ResetDatasetID()
  2088. return nil
  2089. case agentbase.FieldCollectionID:
  2090. m.ResetCollectionID()
  2091. return nil
  2092. case agentbase.FieldSourceName:
  2093. m.ResetSourceName()
  2094. return nil
  2095. case agentbase.FieldCanWrite:
  2096. m.ResetCanWrite()
  2097. return nil
  2098. case agentbase.FieldIsOwner:
  2099. m.ResetIsOwner()
  2100. return nil
  2101. }
  2102. return fmt.Errorf("unknown AgentBase field %s", name)
  2103. }
  2104. // AddedEdges returns all edge names that were set/added in this mutation.
  2105. func (m *AgentBaseMutation) AddedEdges() []string {
  2106. edges := make([]string, 0, 1)
  2107. if m.wx_agent != nil {
  2108. edges = append(edges, agentbase.EdgeWxAgent)
  2109. }
  2110. return edges
  2111. }
  2112. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2113. // name in this mutation.
  2114. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2115. switch name {
  2116. case agentbase.EdgeWxAgent:
  2117. ids := make([]ent.Value, 0, len(m.wx_agent))
  2118. for id := range m.wx_agent {
  2119. ids = append(ids, id)
  2120. }
  2121. return ids
  2122. }
  2123. return nil
  2124. }
  2125. // RemovedEdges returns all edge names that were removed in this mutation.
  2126. func (m *AgentBaseMutation) RemovedEdges() []string {
  2127. edges := make([]string, 0, 1)
  2128. if m.removedwx_agent != nil {
  2129. edges = append(edges, agentbase.EdgeWxAgent)
  2130. }
  2131. return edges
  2132. }
  2133. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2134. // the given name in this mutation.
  2135. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2136. switch name {
  2137. case agentbase.EdgeWxAgent:
  2138. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2139. for id := range m.removedwx_agent {
  2140. ids = append(ids, id)
  2141. }
  2142. return ids
  2143. }
  2144. return nil
  2145. }
  2146. // ClearedEdges returns all edge names that were cleared in this mutation.
  2147. func (m *AgentBaseMutation) ClearedEdges() []string {
  2148. edges := make([]string, 0, 1)
  2149. if m.clearedwx_agent {
  2150. edges = append(edges, agentbase.EdgeWxAgent)
  2151. }
  2152. return edges
  2153. }
  2154. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2155. // was cleared in this mutation.
  2156. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2157. switch name {
  2158. case agentbase.EdgeWxAgent:
  2159. return m.clearedwx_agent
  2160. }
  2161. return false
  2162. }
  2163. // ClearEdge clears the value of the edge with the given name. It returns an error
  2164. // if that edge is not defined in the schema.
  2165. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2166. switch name {
  2167. }
  2168. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2169. }
  2170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2171. // It returns an error if the edge is not defined in the schema.
  2172. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2173. switch name {
  2174. case agentbase.EdgeWxAgent:
  2175. m.ResetWxAgent()
  2176. return nil
  2177. }
  2178. return fmt.Errorf("unknown AgentBase edge %s", name)
  2179. }
  2180. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2181. type AliyunAvatarMutation struct {
  2182. config
  2183. op Op
  2184. typ string
  2185. id *uint64
  2186. created_at *time.Time
  2187. updated_at *time.Time
  2188. deleted_at *time.Time
  2189. user_id *uint64
  2190. adduser_id *int64
  2191. biz_id *string
  2192. access_key_id *string
  2193. access_key_secret *string
  2194. app_id *string
  2195. tenant_id *uint64
  2196. addtenant_id *int64
  2197. response *string
  2198. token *string
  2199. session_id *string
  2200. clearedFields map[string]struct{}
  2201. done bool
  2202. oldValue func(context.Context) (*AliyunAvatar, error)
  2203. predicates []predicate.AliyunAvatar
  2204. }
  2205. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2206. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2207. type aliyunavatarOption func(*AliyunAvatarMutation)
  2208. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2209. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2210. m := &AliyunAvatarMutation{
  2211. config: c,
  2212. op: op,
  2213. typ: TypeAliyunAvatar,
  2214. clearedFields: make(map[string]struct{}),
  2215. }
  2216. for _, opt := range opts {
  2217. opt(m)
  2218. }
  2219. return m
  2220. }
  2221. // withAliyunAvatarID sets the ID field of the mutation.
  2222. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2223. return func(m *AliyunAvatarMutation) {
  2224. var (
  2225. err error
  2226. once sync.Once
  2227. value *AliyunAvatar
  2228. )
  2229. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2230. once.Do(func() {
  2231. if m.done {
  2232. err = errors.New("querying old values post mutation is not allowed")
  2233. } else {
  2234. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2235. }
  2236. })
  2237. return value, err
  2238. }
  2239. m.id = &id
  2240. }
  2241. }
  2242. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2243. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2244. return func(m *AliyunAvatarMutation) {
  2245. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2246. return node, nil
  2247. }
  2248. m.id = &node.ID
  2249. }
  2250. }
  2251. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2252. // executed in a transaction (ent.Tx), a transactional client is returned.
  2253. func (m AliyunAvatarMutation) Client() *Client {
  2254. client := &Client{config: m.config}
  2255. client.init()
  2256. return client
  2257. }
  2258. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2259. // it returns an error otherwise.
  2260. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2261. if _, ok := m.driver.(*txDriver); !ok {
  2262. return nil, errors.New("ent: mutation is not running in a transaction")
  2263. }
  2264. tx := &Tx{config: m.config}
  2265. tx.init()
  2266. return tx, nil
  2267. }
  2268. // SetID sets the value of the id field. Note that this
  2269. // operation is only accepted on creation of AliyunAvatar entities.
  2270. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2271. m.id = &id
  2272. }
  2273. // ID returns the ID value in the mutation. Note that the ID is only available
  2274. // if it was provided to the builder or after it was returned from the database.
  2275. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2276. if m.id == nil {
  2277. return
  2278. }
  2279. return *m.id, true
  2280. }
  2281. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2282. // That means, if the mutation is applied within a transaction with an isolation level such
  2283. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2284. // or updated by the mutation.
  2285. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2286. switch {
  2287. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2288. id, exists := m.ID()
  2289. if exists {
  2290. return []uint64{id}, nil
  2291. }
  2292. fallthrough
  2293. case m.op.Is(OpUpdate | OpDelete):
  2294. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2295. default:
  2296. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2297. }
  2298. }
  2299. // SetCreatedAt sets the "created_at" field.
  2300. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2301. m.created_at = &t
  2302. }
  2303. // CreatedAt returns the value of the "created_at" field in the mutation.
  2304. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2305. v := m.created_at
  2306. if v == nil {
  2307. return
  2308. }
  2309. return *v, true
  2310. }
  2311. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2312. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2314. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2315. if !m.op.Is(OpUpdateOne) {
  2316. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2317. }
  2318. if m.id == nil || m.oldValue == nil {
  2319. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2320. }
  2321. oldValue, err := m.oldValue(ctx)
  2322. if err != nil {
  2323. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2324. }
  2325. return oldValue.CreatedAt, nil
  2326. }
  2327. // ResetCreatedAt resets all changes to the "created_at" field.
  2328. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2329. m.created_at = nil
  2330. }
  2331. // SetUpdatedAt sets the "updated_at" field.
  2332. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2333. m.updated_at = &t
  2334. }
  2335. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2336. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2337. v := m.updated_at
  2338. if v == nil {
  2339. return
  2340. }
  2341. return *v, true
  2342. }
  2343. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2344. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2346. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2347. if !m.op.Is(OpUpdateOne) {
  2348. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2349. }
  2350. if m.id == nil || m.oldValue == nil {
  2351. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2352. }
  2353. oldValue, err := m.oldValue(ctx)
  2354. if err != nil {
  2355. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2356. }
  2357. return oldValue.UpdatedAt, nil
  2358. }
  2359. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2360. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2361. m.updated_at = nil
  2362. }
  2363. // SetDeletedAt sets the "deleted_at" field.
  2364. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2365. m.deleted_at = &t
  2366. }
  2367. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2368. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2369. v := m.deleted_at
  2370. if v == nil {
  2371. return
  2372. }
  2373. return *v, true
  2374. }
  2375. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2376. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2378. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2379. if !m.op.Is(OpUpdateOne) {
  2380. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2381. }
  2382. if m.id == nil || m.oldValue == nil {
  2383. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2384. }
  2385. oldValue, err := m.oldValue(ctx)
  2386. if err != nil {
  2387. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2388. }
  2389. return oldValue.DeletedAt, nil
  2390. }
  2391. // ClearDeletedAt clears the value of the "deleted_at" field.
  2392. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2393. m.deleted_at = nil
  2394. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2395. }
  2396. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2397. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2398. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2399. return ok
  2400. }
  2401. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2402. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2403. m.deleted_at = nil
  2404. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2405. }
  2406. // SetUserID sets the "user_id" field.
  2407. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2408. m.user_id = &u
  2409. m.adduser_id = nil
  2410. }
  2411. // UserID returns the value of the "user_id" field in the mutation.
  2412. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2413. v := m.user_id
  2414. if v == nil {
  2415. return
  2416. }
  2417. return *v, true
  2418. }
  2419. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2420. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2422. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2423. if !m.op.Is(OpUpdateOne) {
  2424. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2425. }
  2426. if m.id == nil || m.oldValue == nil {
  2427. return v, errors.New("OldUserID requires an ID field in the mutation")
  2428. }
  2429. oldValue, err := m.oldValue(ctx)
  2430. if err != nil {
  2431. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2432. }
  2433. return oldValue.UserID, nil
  2434. }
  2435. // AddUserID adds u to the "user_id" field.
  2436. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2437. if m.adduser_id != nil {
  2438. *m.adduser_id += u
  2439. } else {
  2440. m.adduser_id = &u
  2441. }
  2442. }
  2443. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2444. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2445. v := m.adduser_id
  2446. if v == nil {
  2447. return
  2448. }
  2449. return *v, true
  2450. }
  2451. // ResetUserID resets all changes to the "user_id" field.
  2452. func (m *AliyunAvatarMutation) ResetUserID() {
  2453. m.user_id = nil
  2454. m.adduser_id = nil
  2455. }
  2456. // SetBizID sets the "biz_id" field.
  2457. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2458. m.biz_id = &s
  2459. }
  2460. // BizID returns the value of the "biz_id" field in the mutation.
  2461. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2462. v := m.biz_id
  2463. if v == nil {
  2464. return
  2465. }
  2466. return *v, true
  2467. }
  2468. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2469. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2471. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2472. if !m.op.Is(OpUpdateOne) {
  2473. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2474. }
  2475. if m.id == nil || m.oldValue == nil {
  2476. return v, errors.New("OldBizID requires an ID field in the mutation")
  2477. }
  2478. oldValue, err := m.oldValue(ctx)
  2479. if err != nil {
  2480. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2481. }
  2482. return oldValue.BizID, nil
  2483. }
  2484. // ResetBizID resets all changes to the "biz_id" field.
  2485. func (m *AliyunAvatarMutation) ResetBizID() {
  2486. m.biz_id = nil
  2487. }
  2488. // SetAccessKeyID sets the "access_key_id" field.
  2489. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2490. m.access_key_id = &s
  2491. }
  2492. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2493. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2494. v := m.access_key_id
  2495. if v == nil {
  2496. return
  2497. }
  2498. return *v, true
  2499. }
  2500. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2501. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2503. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2504. if !m.op.Is(OpUpdateOne) {
  2505. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2506. }
  2507. if m.id == nil || m.oldValue == nil {
  2508. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2509. }
  2510. oldValue, err := m.oldValue(ctx)
  2511. if err != nil {
  2512. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2513. }
  2514. return oldValue.AccessKeyID, nil
  2515. }
  2516. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2517. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2518. m.access_key_id = nil
  2519. }
  2520. // SetAccessKeySecret sets the "access_key_secret" field.
  2521. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2522. m.access_key_secret = &s
  2523. }
  2524. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2525. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2526. v := m.access_key_secret
  2527. if v == nil {
  2528. return
  2529. }
  2530. return *v, true
  2531. }
  2532. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2533. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2535. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2536. if !m.op.Is(OpUpdateOne) {
  2537. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2538. }
  2539. if m.id == nil || m.oldValue == nil {
  2540. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2541. }
  2542. oldValue, err := m.oldValue(ctx)
  2543. if err != nil {
  2544. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2545. }
  2546. return oldValue.AccessKeySecret, nil
  2547. }
  2548. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2549. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2550. m.access_key_secret = nil
  2551. }
  2552. // SetAppID sets the "app_id" field.
  2553. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2554. m.app_id = &s
  2555. }
  2556. // AppID returns the value of the "app_id" field in the mutation.
  2557. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2558. v := m.app_id
  2559. if v == nil {
  2560. return
  2561. }
  2562. return *v, true
  2563. }
  2564. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2565. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2567. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2568. if !m.op.Is(OpUpdateOne) {
  2569. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2570. }
  2571. if m.id == nil || m.oldValue == nil {
  2572. return v, errors.New("OldAppID requires an ID field in the mutation")
  2573. }
  2574. oldValue, err := m.oldValue(ctx)
  2575. if err != nil {
  2576. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2577. }
  2578. return oldValue.AppID, nil
  2579. }
  2580. // ClearAppID clears the value of the "app_id" field.
  2581. func (m *AliyunAvatarMutation) ClearAppID() {
  2582. m.app_id = nil
  2583. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2584. }
  2585. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2586. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2587. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2588. return ok
  2589. }
  2590. // ResetAppID resets all changes to the "app_id" field.
  2591. func (m *AliyunAvatarMutation) ResetAppID() {
  2592. m.app_id = nil
  2593. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2594. }
  2595. // SetTenantID sets the "tenant_id" field.
  2596. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2597. m.tenant_id = &u
  2598. m.addtenant_id = nil
  2599. }
  2600. // TenantID returns the value of the "tenant_id" field in the mutation.
  2601. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2602. v := m.tenant_id
  2603. if v == nil {
  2604. return
  2605. }
  2606. return *v, true
  2607. }
  2608. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2609. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2611. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2612. if !m.op.Is(OpUpdateOne) {
  2613. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2614. }
  2615. if m.id == nil || m.oldValue == nil {
  2616. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2617. }
  2618. oldValue, err := m.oldValue(ctx)
  2619. if err != nil {
  2620. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2621. }
  2622. return oldValue.TenantID, nil
  2623. }
  2624. // AddTenantID adds u to the "tenant_id" field.
  2625. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2626. if m.addtenant_id != nil {
  2627. *m.addtenant_id += u
  2628. } else {
  2629. m.addtenant_id = &u
  2630. }
  2631. }
  2632. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2633. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2634. v := m.addtenant_id
  2635. if v == nil {
  2636. return
  2637. }
  2638. return *v, true
  2639. }
  2640. // ResetTenantID resets all changes to the "tenant_id" field.
  2641. func (m *AliyunAvatarMutation) ResetTenantID() {
  2642. m.tenant_id = nil
  2643. m.addtenant_id = nil
  2644. }
  2645. // SetResponse sets the "response" field.
  2646. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2647. m.response = &s
  2648. }
  2649. // Response returns the value of the "response" field in the mutation.
  2650. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2651. v := m.response
  2652. if v == nil {
  2653. return
  2654. }
  2655. return *v, true
  2656. }
  2657. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2658. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2660. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2661. if !m.op.Is(OpUpdateOne) {
  2662. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2663. }
  2664. if m.id == nil || m.oldValue == nil {
  2665. return v, errors.New("OldResponse requires an ID field in the mutation")
  2666. }
  2667. oldValue, err := m.oldValue(ctx)
  2668. if err != nil {
  2669. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2670. }
  2671. return oldValue.Response, nil
  2672. }
  2673. // ResetResponse resets all changes to the "response" field.
  2674. func (m *AliyunAvatarMutation) ResetResponse() {
  2675. m.response = nil
  2676. }
  2677. // SetToken sets the "token" field.
  2678. func (m *AliyunAvatarMutation) SetToken(s string) {
  2679. m.token = &s
  2680. }
  2681. // Token returns the value of the "token" field in the mutation.
  2682. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2683. v := m.token
  2684. if v == nil {
  2685. return
  2686. }
  2687. return *v, true
  2688. }
  2689. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2690. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2692. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2693. if !m.op.Is(OpUpdateOne) {
  2694. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2695. }
  2696. if m.id == nil || m.oldValue == nil {
  2697. return v, errors.New("OldToken requires an ID field in the mutation")
  2698. }
  2699. oldValue, err := m.oldValue(ctx)
  2700. if err != nil {
  2701. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2702. }
  2703. return oldValue.Token, nil
  2704. }
  2705. // ResetToken resets all changes to the "token" field.
  2706. func (m *AliyunAvatarMutation) ResetToken() {
  2707. m.token = nil
  2708. }
  2709. // SetSessionID sets the "session_id" field.
  2710. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2711. m.session_id = &s
  2712. }
  2713. // SessionID returns the value of the "session_id" field in the mutation.
  2714. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2715. v := m.session_id
  2716. if v == nil {
  2717. return
  2718. }
  2719. return *v, true
  2720. }
  2721. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2722. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2724. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2725. if !m.op.Is(OpUpdateOne) {
  2726. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2727. }
  2728. if m.id == nil || m.oldValue == nil {
  2729. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2730. }
  2731. oldValue, err := m.oldValue(ctx)
  2732. if err != nil {
  2733. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2734. }
  2735. return oldValue.SessionID, nil
  2736. }
  2737. // ResetSessionID resets all changes to the "session_id" field.
  2738. func (m *AliyunAvatarMutation) ResetSessionID() {
  2739. m.session_id = nil
  2740. }
  2741. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2742. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2743. m.predicates = append(m.predicates, ps...)
  2744. }
  2745. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2746. // users can use type-assertion to append predicates that do not depend on any generated package.
  2747. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2748. p := make([]predicate.AliyunAvatar, len(ps))
  2749. for i := range ps {
  2750. p[i] = ps[i]
  2751. }
  2752. m.Where(p...)
  2753. }
  2754. // Op returns the operation name.
  2755. func (m *AliyunAvatarMutation) Op() Op {
  2756. return m.op
  2757. }
  2758. // SetOp allows setting the mutation operation.
  2759. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2760. m.op = op
  2761. }
  2762. // Type returns the node type of this mutation (AliyunAvatar).
  2763. func (m *AliyunAvatarMutation) Type() string {
  2764. return m.typ
  2765. }
  2766. // Fields returns all fields that were changed during this mutation. Note that in
  2767. // order to get all numeric fields that were incremented/decremented, call
  2768. // AddedFields().
  2769. func (m *AliyunAvatarMutation) Fields() []string {
  2770. fields := make([]string, 0, 12)
  2771. if m.created_at != nil {
  2772. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2773. }
  2774. if m.updated_at != nil {
  2775. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2776. }
  2777. if m.deleted_at != nil {
  2778. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2779. }
  2780. if m.user_id != nil {
  2781. fields = append(fields, aliyunavatar.FieldUserID)
  2782. }
  2783. if m.biz_id != nil {
  2784. fields = append(fields, aliyunavatar.FieldBizID)
  2785. }
  2786. if m.access_key_id != nil {
  2787. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2788. }
  2789. if m.access_key_secret != nil {
  2790. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2791. }
  2792. if m.app_id != nil {
  2793. fields = append(fields, aliyunavatar.FieldAppID)
  2794. }
  2795. if m.tenant_id != nil {
  2796. fields = append(fields, aliyunavatar.FieldTenantID)
  2797. }
  2798. if m.response != nil {
  2799. fields = append(fields, aliyunavatar.FieldResponse)
  2800. }
  2801. if m.token != nil {
  2802. fields = append(fields, aliyunavatar.FieldToken)
  2803. }
  2804. if m.session_id != nil {
  2805. fields = append(fields, aliyunavatar.FieldSessionID)
  2806. }
  2807. return fields
  2808. }
  2809. // Field returns the value of a field with the given name. The second boolean
  2810. // return value indicates that this field was not set, or was not defined in the
  2811. // schema.
  2812. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2813. switch name {
  2814. case aliyunavatar.FieldCreatedAt:
  2815. return m.CreatedAt()
  2816. case aliyunavatar.FieldUpdatedAt:
  2817. return m.UpdatedAt()
  2818. case aliyunavatar.FieldDeletedAt:
  2819. return m.DeletedAt()
  2820. case aliyunavatar.FieldUserID:
  2821. return m.UserID()
  2822. case aliyunavatar.FieldBizID:
  2823. return m.BizID()
  2824. case aliyunavatar.FieldAccessKeyID:
  2825. return m.AccessKeyID()
  2826. case aliyunavatar.FieldAccessKeySecret:
  2827. return m.AccessKeySecret()
  2828. case aliyunavatar.FieldAppID:
  2829. return m.AppID()
  2830. case aliyunavatar.FieldTenantID:
  2831. return m.TenantID()
  2832. case aliyunavatar.FieldResponse:
  2833. return m.Response()
  2834. case aliyunavatar.FieldToken:
  2835. return m.Token()
  2836. case aliyunavatar.FieldSessionID:
  2837. return m.SessionID()
  2838. }
  2839. return nil, false
  2840. }
  2841. // OldField returns the old value of the field from the database. An error is
  2842. // returned if the mutation operation is not UpdateOne, or the query to the
  2843. // database failed.
  2844. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2845. switch name {
  2846. case aliyunavatar.FieldCreatedAt:
  2847. return m.OldCreatedAt(ctx)
  2848. case aliyunavatar.FieldUpdatedAt:
  2849. return m.OldUpdatedAt(ctx)
  2850. case aliyunavatar.FieldDeletedAt:
  2851. return m.OldDeletedAt(ctx)
  2852. case aliyunavatar.FieldUserID:
  2853. return m.OldUserID(ctx)
  2854. case aliyunavatar.FieldBizID:
  2855. return m.OldBizID(ctx)
  2856. case aliyunavatar.FieldAccessKeyID:
  2857. return m.OldAccessKeyID(ctx)
  2858. case aliyunavatar.FieldAccessKeySecret:
  2859. return m.OldAccessKeySecret(ctx)
  2860. case aliyunavatar.FieldAppID:
  2861. return m.OldAppID(ctx)
  2862. case aliyunavatar.FieldTenantID:
  2863. return m.OldTenantID(ctx)
  2864. case aliyunavatar.FieldResponse:
  2865. return m.OldResponse(ctx)
  2866. case aliyunavatar.FieldToken:
  2867. return m.OldToken(ctx)
  2868. case aliyunavatar.FieldSessionID:
  2869. return m.OldSessionID(ctx)
  2870. }
  2871. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2872. }
  2873. // SetField sets the value of a field with the given name. It returns an error if
  2874. // the field is not defined in the schema, or if the type mismatched the field
  2875. // type.
  2876. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2877. switch name {
  2878. case aliyunavatar.FieldCreatedAt:
  2879. v, ok := value.(time.Time)
  2880. if !ok {
  2881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2882. }
  2883. m.SetCreatedAt(v)
  2884. return nil
  2885. case aliyunavatar.FieldUpdatedAt:
  2886. v, ok := value.(time.Time)
  2887. if !ok {
  2888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2889. }
  2890. m.SetUpdatedAt(v)
  2891. return nil
  2892. case aliyunavatar.FieldDeletedAt:
  2893. v, ok := value.(time.Time)
  2894. if !ok {
  2895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2896. }
  2897. m.SetDeletedAt(v)
  2898. return nil
  2899. case aliyunavatar.FieldUserID:
  2900. v, ok := value.(uint64)
  2901. if !ok {
  2902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2903. }
  2904. m.SetUserID(v)
  2905. return nil
  2906. case aliyunavatar.FieldBizID:
  2907. v, ok := value.(string)
  2908. if !ok {
  2909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2910. }
  2911. m.SetBizID(v)
  2912. return nil
  2913. case aliyunavatar.FieldAccessKeyID:
  2914. v, ok := value.(string)
  2915. if !ok {
  2916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2917. }
  2918. m.SetAccessKeyID(v)
  2919. return nil
  2920. case aliyunavatar.FieldAccessKeySecret:
  2921. v, ok := value.(string)
  2922. if !ok {
  2923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2924. }
  2925. m.SetAccessKeySecret(v)
  2926. return nil
  2927. case aliyunavatar.FieldAppID:
  2928. v, ok := value.(string)
  2929. if !ok {
  2930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2931. }
  2932. m.SetAppID(v)
  2933. return nil
  2934. case aliyunavatar.FieldTenantID:
  2935. v, ok := value.(uint64)
  2936. if !ok {
  2937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2938. }
  2939. m.SetTenantID(v)
  2940. return nil
  2941. case aliyunavatar.FieldResponse:
  2942. v, ok := value.(string)
  2943. if !ok {
  2944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2945. }
  2946. m.SetResponse(v)
  2947. return nil
  2948. case aliyunavatar.FieldToken:
  2949. v, ok := value.(string)
  2950. if !ok {
  2951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2952. }
  2953. m.SetToken(v)
  2954. return nil
  2955. case aliyunavatar.FieldSessionID:
  2956. v, ok := value.(string)
  2957. if !ok {
  2958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2959. }
  2960. m.SetSessionID(v)
  2961. return nil
  2962. }
  2963. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2964. }
  2965. // AddedFields returns all numeric fields that were incremented/decremented during
  2966. // this mutation.
  2967. func (m *AliyunAvatarMutation) AddedFields() []string {
  2968. var fields []string
  2969. if m.adduser_id != nil {
  2970. fields = append(fields, aliyunavatar.FieldUserID)
  2971. }
  2972. if m.addtenant_id != nil {
  2973. fields = append(fields, aliyunavatar.FieldTenantID)
  2974. }
  2975. return fields
  2976. }
  2977. // AddedField returns the numeric value that was incremented/decremented on a field
  2978. // with the given name. The second boolean return value indicates that this field
  2979. // was not set, or was not defined in the schema.
  2980. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2981. switch name {
  2982. case aliyunavatar.FieldUserID:
  2983. return m.AddedUserID()
  2984. case aliyunavatar.FieldTenantID:
  2985. return m.AddedTenantID()
  2986. }
  2987. return nil, false
  2988. }
  2989. // AddField adds the value to the field with the given name. It returns an error if
  2990. // the field is not defined in the schema, or if the type mismatched the field
  2991. // type.
  2992. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2993. switch name {
  2994. case aliyunavatar.FieldUserID:
  2995. v, ok := value.(int64)
  2996. if !ok {
  2997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2998. }
  2999. m.AddUserID(v)
  3000. return nil
  3001. case aliyunavatar.FieldTenantID:
  3002. v, ok := value.(int64)
  3003. if !ok {
  3004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3005. }
  3006. m.AddTenantID(v)
  3007. return nil
  3008. }
  3009. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3010. }
  3011. // ClearedFields returns all nullable fields that were cleared during this
  3012. // mutation.
  3013. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3014. var fields []string
  3015. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3016. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3017. }
  3018. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3019. fields = append(fields, aliyunavatar.FieldAppID)
  3020. }
  3021. return fields
  3022. }
  3023. // FieldCleared returns a boolean indicating if a field with the given name was
  3024. // cleared in this mutation.
  3025. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3026. _, ok := m.clearedFields[name]
  3027. return ok
  3028. }
  3029. // ClearField clears the value of the field with the given name. It returns an
  3030. // error if the field is not defined in the schema.
  3031. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3032. switch name {
  3033. case aliyunavatar.FieldDeletedAt:
  3034. m.ClearDeletedAt()
  3035. return nil
  3036. case aliyunavatar.FieldAppID:
  3037. m.ClearAppID()
  3038. return nil
  3039. }
  3040. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3041. }
  3042. // ResetField resets all changes in the mutation for the field with the given name.
  3043. // It returns an error if the field is not defined in the schema.
  3044. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3045. switch name {
  3046. case aliyunavatar.FieldCreatedAt:
  3047. m.ResetCreatedAt()
  3048. return nil
  3049. case aliyunavatar.FieldUpdatedAt:
  3050. m.ResetUpdatedAt()
  3051. return nil
  3052. case aliyunavatar.FieldDeletedAt:
  3053. m.ResetDeletedAt()
  3054. return nil
  3055. case aliyunavatar.FieldUserID:
  3056. m.ResetUserID()
  3057. return nil
  3058. case aliyunavatar.FieldBizID:
  3059. m.ResetBizID()
  3060. return nil
  3061. case aliyunavatar.FieldAccessKeyID:
  3062. m.ResetAccessKeyID()
  3063. return nil
  3064. case aliyunavatar.FieldAccessKeySecret:
  3065. m.ResetAccessKeySecret()
  3066. return nil
  3067. case aliyunavatar.FieldAppID:
  3068. m.ResetAppID()
  3069. return nil
  3070. case aliyunavatar.FieldTenantID:
  3071. m.ResetTenantID()
  3072. return nil
  3073. case aliyunavatar.FieldResponse:
  3074. m.ResetResponse()
  3075. return nil
  3076. case aliyunavatar.FieldToken:
  3077. m.ResetToken()
  3078. return nil
  3079. case aliyunavatar.FieldSessionID:
  3080. m.ResetSessionID()
  3081. return nil
  3082. }
  3083. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3084. }
  3085. // AddedEdges returns all edge names that were set/added in this mutation.
  3086. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3087. edges := make([]string, 0, 0)
  3088. return edges
  3089. }
  3090. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3091. // name in this mutation.
  3092. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3093. return nil
  3094. }
  3095. // RemovedEdges returns all edge names that were removed in this mutation.
  3096. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3097. edges := make([]string, 0, 0)
  3098. return edges
  3099. }
  3100. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3101. // the given name in this mutation.
  3102. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3103. return nil
  3104. }
  3105. // ClearedEdges returns all edge names that were cleared in this mutation.
  3106. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3107. edges := make([]string, 0, 0)
  3108. return edges
  3109. }
  3110. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3111. // was cleared in this mutation.
  3112. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3113. return false
  3114. }
  3115. // ClearEdge clears the value of the edge with the given name. It returns an error
  3116. // if that edge is not defined in the schema.
  3117. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3118. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3119. }
  3120. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3121. // It returns an error if the edge is not defined in the schema.
  3122. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3123. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3124. }
  3125. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3126. type AllocAgentMutation struct {
  3127. config
  3128. op Op
  3129. typ string
  3130. id *uint64
  3131. created_at *time.Time
  3132. updated_at *time.Time
  3133. deleted_at *time.Time
  3134. user_id *string
  3135. organization_id *uint64
  3136. addorganization_id *int64
  3137. agents *[]uint64
  3138. appendagents []uint64
  3139. status *int
  3140. addstatus *int
  3141. clearedFields map[string]struct{}
  3142. done bool
  3143. oldValue func(context.Context) (*AllocAgent, error)
  3144. predicates []predicate.AllocAgent
  3145. }
  3146. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3147. // allocagentOption allows management of the mutation configuration using functional options.
  3148. type allocagentOption func(*AllocAgentMutation)
  3149. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3150. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3151. m := &AllocAgentMutation{
  3152. config: c,
  3153. op: op,
  3154. typ: TypeAllocAgent,
  3155. clearedFields: make(map[string]struct{}),
  3156. }
  3157. for _, opt := range opts {
  3158. opt(m)
  3159. }
  3160. return m
  3161. }
  3162. // withAllocAgentID sets the ID field of the mutation.
  3163. func withAllocAgentID(id uint64) allocagentOption {
  3164. return func(m *AllocAgentMutation) {
  3165. var (
  3166. err error
  3167. once sync.Once
  3168. value *AllocAgent
  3169. )
  3170. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3171. once.Do(func() {
  3172. if m.done {
  3173. err = errors.New("querying old values post mutation is not allowed")
  3174. } else {
  3175. value, err = m.Client().AllocAgent.Get(ctx, id)
  3176. }
  3177. })
  3178. return value, err
  3179. }
  3180. m.id = &id
  3181. }
  3182. }
  3183. // withAllocAgent sets the old AllocAgent of the mutation.
  3184. func withAllocAgent(node *AllocAgent) allocagentOption {
  3185. return func(m *AllocAgentMutation) {
  3186. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3187. return node, nil
  3188. }
  3189. m.id = &node.ID
  3190. }
  3191. }
  3192. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3193. // executed in a transaction (ent.Tx), a transactional client is returned.
  3194. func (m AllocAgentMutation) Client() *Client {
  3195. client := &Client{config: m.config}
  3196. client.init()
  3197. return client
  3198. }
  3199. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3200. // it returns an error otherwise.
  3201. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3202. if _, ok := m.driver.(*txDriver); !ok {
  3203. return nil, errors.New("ent: mutation is not running in a transaction")
  3204. }
  3205. tx := &Tx{config: m.config}
  3206. tx.init()
  3207. return tx, nil
  3208. }
  3209. // SetID sets the value of the id field. Note that this
  3210. // operation is only accepted on creation of AllocAgent entities.
  3211. func (m *AllocAgentMutation) SetID(id uint64) {
  3212. m.id = &id
  3213. }
  3214. // ID returns the ID value in the mutation. Note that the ID is only available
  3215. // if it was provided to the builder or after it was returned from the database.
  3216. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3217. if m.id == nil {
  3218. return
  3219. }
  3220. return *m.id, true
  3221. }
  3222. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3223. // That means, if the mutation is applied within a transaction with an isolation level such
  3224. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3225. // or updated by the mutation.
  3226. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3227. switch {
  3228. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3229. id, exists := m.ID()
  3230. if exists {
  3231. return []uint64{id}, nil
  3232. }
  3233. fallthrough
  3234. case m.op.Is(OpUpdate | OpDelete):
  3235. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3236. default:
  3237. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3238. }
  3239. }
  3240. // SetCreatedAt sets the "created_at" field.
  3241. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3242. m.created_at = &t
  3243. }
  3244. // CreatedAt returns the value of the "created_at" field in the mutation.
  3245. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3246. v := m.created_at
  3247. if v == nil {
  3248. return
  3249. }
  3250. return *v, true
  3251. }
  3252. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3253. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3255. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3256. if !m.op.Is(OpUpdateOne) {
  3257. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3258. }
  3259. if m.id == nil || m.oldValue == nil {
  3260. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3261. }
  3262. oldValue, err := m.oldValue(ctx)
  3263. if err != nil {
  3264. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3265. }
  3266. return oldValue.CreatedAt, nil
  3267. }
  3268. // ResetCreatedAt resets all changes to the "created_at" field.
  3269. func (m *AllocAgentMutation) ResetCreatedAt() {
  3270. m.created_at = nil
  3271. }
  3272. // SetUpdatedAt sets the "updated_at" field.
  3273. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3274. m.updated_at = &t
  3275. }
  3276. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3277. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3278. v := m.updated_at
  3279. if v == nil {
  3280. return
  3281. }
  3282. return *v, true
  3283. }
  3284. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3285. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3287. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3288. if !m.op.Is(OpUpdateOne) {
  3289. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3290. }
  3291. if m.id == nil || m.oldValue == nil {
  3292. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3293. }
  3294. oldValue, err := m.oldValue(ctx)
  3295. if err != nil {
  3296. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3297. }
  3298. return oldValue.UpdatedAt, nil
  3299. }
  3300. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3301. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3302. m.updated_at = nil
  3303. }
  3304. // SetDeletedAt sets the "deleted_at" field.
  3305. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3306. m.deleted_at = &t
  3307. }
  3308. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3309. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3310. v := m.deleted_at
  3311. if v == nil {
  3312. return
  3313. }
  3314. return *v, true
  3315. }
  3316. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3317. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3319. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3320. if !m.op.Is(OpUpdateOne) {
  3321. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3322. }
  3323. if m.id == nil || m.oldValue == nil {
  3324. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3325. }
  3326. oldValue, err := m.oldValue(ctx)
  3327. if err != nil {
  3328. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3329. }
  3330. return oldValue.DeletedAt, nil
  3331. }
  3332. // ClearDeletedAt clears the value of the "deleted_at" field.
  3333. func (m *AllocAgentMutation) ClearDeletedAt() {
  3334. m.deleted_at = nil
  3335. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3336. }
  3337. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3338. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3339. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3340. return ok
  3341. }
  3342. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3343. func (m *AllocAgentMutation) ResetDeletedAt() {
  3344. m.deleted_at = nil
  3345. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3346. }
  3347. // SetUserID sets the "user_id" field.
  3348. func (m *AllocAgentMutation) SetUserID(s string) {
  3349. m.user_id = &s
  3350. }
  3351. // UserID returns the value of the "user_id" field in the mutation.
  3352. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3353. v := m.user_id
  3354. if v == nil {
  3355. return
  3356. }
  3357. return *v, true
  3358. }
  3359. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3360. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3362. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3363. if !m.op.Is(OpUpdateOne) {
  3364. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3365. }
  3366. if m.id == nil || m.oldValue == nil {
  3367. return v, errors.New("OldUserID requires an ID field in the mutation")
  3368. }
  3369. oldValue, err := m.oldValue(ctx)
  3370. if err != nil {
  3371. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3372. }
  3373. return oldValue.UserID, nil
  3374. }
  3375. // ClearUserID clears the value of the "user_id" field.
  3376. func (m *AllocAgentMutation) ClearUserID() {
  3377. m.user_id = nil
  3378. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3379. }
  3380. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3381. func (m *AllocAgentMutation) UserIDCleared() bool {
  3382. _, ok := m.clearedFields[allocagent.FieldUserID]
  3383. return ok
  3384. }
  3385. // ResetUserID resets all changes to the "user_id" field.
  3386. func (m *AllocAgentMutation) ResetUserID() {
  3387. m.user_id = nil
  3388. delete(m.clearedFields, allocagent.FieldUserID)
  3389. }
  3390. // SetOrganizationID sets the "organization_id" field.
  3391. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3392. m.organization_id = &u
  3393. m.addorganization_id = nil
  3394. }
  3395. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3396. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3397. v := m.organization_id
  3398. if v == nil {
  3399. return
  3400. }
  3401. return *v, true
  3402. }
  3403. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3404. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3406. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3407. if !m.op.Is(OpUpdateOne) {
  3408. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3409. }
  3410. if m.id == nil || m.oldValue == nil {
  3411. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3412. }
  3413. oldValue, err := m.oldValue(ctx)
  3414. if err != nil {
  3415. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3416. }
  3417. return oldValue.OrganizationID, nil
  3418. }
  3419. // AddOrganizationID adds u to the "organization_id" field.
  3420. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3421. if m.addorganization_id != nil {
  3422. *m.addorganization_id += u
  3423. } else {
  3424. m.addorganization_id = &u
  3425. }
  3426. }
  3427. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3428. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3429. v := m.addorganization_id
  3430. if v == nil {
  3431. return
  3432. }
  3433. return *v, true
  3434. }
  3435. // ClearOrganizationID clears the value of the "organization_id" field.
  3436. func (m *AllocAgentMutation) ClearOrganizationID() {
  3437. m.organization_id = nil
  3438. m.addorganization_id = nil
  3439. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3440. }
  3441. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3442. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3443. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3444. return ok
  3445. }
  3446. // ResetOrganizationID resets all changes to the "organization_id" field.
  3447. func (m *AllocAgentMutation) ResetOrganizationID() {
  3448. m.organization_id = nil
  3449. m.addorganization_id = nil
  3450. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3451. }
  3452. // SetAgents sets the "agents" field.
  3453. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3454. m.agents = &u
  3455. m.appendagents = nil
  3456. }
  3457. // Agents returns the value of the "agents" field in the mutation.
  3458. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3459. v := m.agents
  3460. if v == nil {
  3461. return
  3462. }
  3463. return *v, true
  3464. }
  3465. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3466. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3468. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3469. if !m.op.Is(OpUpdateOne) {
  3470. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3471. }
  3472. if m.id == nil || m.oldValue == nil {
  3473. return v, errors.New("OldAgents requires an ID field in the mutation")
  3474. }
  3475. oldValue, err := m.oldValue(ctx)
  3476. if err != nil {
  3477. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3478. }
  3479. return oldValue.Agents, nil
  3480. }
  3481. // AppendAgents adds u to the "agents" field.
  3482. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3483. m.appendagents = append(m.appendagents, u...)
  3484. }
  3485. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3486. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3487. if len(m.appendagents) == 0 {
  3488. return nil, false
  3489. }
  3490. return m.appendagents, true
  3491. }
  3492. // ResetAgents resets all changes to the "agents" field.
  3493. func (m *AllocAgentMutation) ResetAgents() {
  3494. m.agents = nil
  3495. m.appendagents = nil
  3496. }
  3497. // SetStatus sets the "status" field.
  3498. func (m *AllocAgentMutation) SetStatus(i int) {
  3499. m.status = &i
  3500. m.addstatus = nil
  3501. }
  3502. // Status returns the value of the "status" field in the mutation.
  3503. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3504. v := m.status
  3505. if v == nil {
  3506. return
  3507. }
  3508. return *v, true
  3509. }
  3510. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3511. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3513. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3514. if !m.op.Is(OpUpdateOne) {
  3515. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3516. }
  3517. if m.id == nil || m.oldValue == nil {
  3518. return v, errors.New("OldStatus requires an ID field in the mutation")
  3519. }
  3520. oldValue, err := m.oldValue(ctx)
  3521. if err != nil {
  3522. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3523. }
  3524. return oldValue.Status, nil
  3525. }
  3526. // AddStatus adds i to the "status" field.
  3527. func (m *AllocAgentMutation) AddStatus(i int) {
  3528. if m.addstatus != nil {
  3529. *m.addstatus += i
  3530. } else {
  3531. m.addstatus = &i
  3532. }
  3533. }
  3534. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3535. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3536. v := m.addstatus
  3537. if v == nil {
  3538. return
  3539. }
  3540. return *v, true
  3541. }
  3542. // ClearStatus clears the value of the "status" field.
  3543. func (m *AllocAgentMutation) ClearStatus() {
  3544. m.status = nil
  3545. m.addstatus = nil
  3546. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3547. }
  3548. // StatusCleared returns if the "status" field was cleared in this mutation.
  3549. func (m *AllocAgentMutation) StatusCleared() bool {
  3550. _, ok := m.clearedFields[allocagent.FieldStatus]
  3551. return ok
  3552. }
  3553. // ResetStatus resets all changes to the "status" field.
  3554. func (m *AllocAgentMutation) ResetStatus() {
  3555. m.status = nil
  3556. m.addstatus = nil
  3557. delete(m.clearedFields, allocagent.FieldStatus)
  3558. }
  3559. // Where appends a list predicates to the AllocAgentMutation builder.
  3560. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3561. m.predicates = append(m.predicates, ps...)
  3562. }
  3563. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3564. // users can use type-assertion to append predicates that do not depend on any generated package.
  3565. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3566. p := make([]predicate.AllocAgent, len(ps))
  3567. for i := range ps {
  3568. p[i] = ps[i]
  3569. }
  3570. m.Where(p...)
  3571. }
  3572. // Op returns the operation name.
  3573. func (m *AllocAgentMutation) Op() Op {
  3574. return m.op
  3575. }
  3576. // SetOp allows setting the mutation operation.
  3577. func (m *AllocAgentMutation) SetOp(op Op) {
  3578. m.op = op
  3579. }
  3580. // Type returns the node type of this mutation (AllocAgent).
  3581. func (m *AllocAgentMutation) Type() string {
  3582. return m.typ
  3583. }
  3584. // Fields returns all fields that were changed during this mutation. Note that in
  3585. // order to get all numeric fields that were incremented/decremented, call
  3586. // AddedFields().
  3587. func (m *AllocAgentMutation) Fields() []string {
  3588. fields := make([]string, 0, 7)
  3589. if m.created_at != nil {
  3590. fields = append(fields, allocagent.FieldCreatedAt)
  3591. }
  3592. if m.updated_at != nil {
  3593. fields = append(fields, allocagent.FieldUpdatedAt)
  3594. }
  3595. if m.deleted_at != nil {
  3596. fields = append(fields, allocagent.FieldDeletedAt)
  3597. }
  3598. if m.user_id != nil {
  3599. fields = append(fields, allocagent.FieldUserID)
  3600. }
  3601. if m.organization_id != nil {
  3602. fields = append(fields, allocagent.FieldOrganizationID)
  3603. }
  3604. if m.agents != nil {
  3605. fields = append(fields, allocagent.FieldAgents)
  3606. }
  3607. if m.status != nil {
  3608. fields = append(fields, allocagent.FieldStatus)
  3609. }
  3610. return fields
  3611. }
  3612. // Field returns the value of a field with the given name. The second boolean
  3613. // return value indicates that this field was not set, or was not defined in the
  3614. // schema.
  3615. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3616. switch name {
  3617. case allocagent.FieldCreatedAt:
  3618. return m.CreatedAt()
  3619. case allocagent.FieldUpdatedAt:
  3620. return m.UpdatedAt()
  3621. case allocagent.FieldDeletedAt:
  3622. return m.DeletedAt()
  3623. case allocagent.FieldUserID:
  3624. return m.UserID()
  3625. case allocagent.FieldOrganizationID:
  3626. return m.OrganizationID()
  3627. case allocagent.FieldAgents:
  3628. return m.Agents()
  3629. case allocagent.FieldStatus:
  3630. return m.Status()
  3631. }
  3632. return nil, false
  3633. }
  3634. // OldField returns the old value of the field from the database. An error is
  3635. // returned if the mutation operation is not UpdateOne, or the query to the
  3636. // database failed.
  3637. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3638. switch name {
  3639. case allocagent.FieldCreatedAt:
  3640. return m.OldCreatedAt(ctx)
  3641. case allocagent.FieldUpdatedAt:
  3642. return m.OldUpdatedAt(ctx)
  3643. case allocagent.FieldDeletedAt:
  3644. return m.OldDeletedAt(ctx)
  3645. case allocagent.FieldUserID:
  3646. return m.OldUserID(ctx)
  3647. case allocagent.FieldOrganizationID:
  3648. return m.OldOrganizationID(ctx)
  3649. case allocagent.FieldAgents:
  3650. return m.OldAgents(ctx)
  3651. case allocagent.FieldStatus:
  3652. return m.OldStatus(ctx)
  3653. }
  3654. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3655. }
  3656. // SetField sets the value of a field with the given name. It returns an error if
  3657. // the field is not defined in the schema, or if the type mismatched the field
  3658. // type.
  3659. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3660. switch name {
  3661. case allocagent.FieldCreatedAt:
  3662. v, ok := value.(time.Time)
  3663. if !ok {
  3664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3665. }
  3666. m.SetCreatedAt(v)
  3667. return nil
  3668. case allocagent.FieldUpdatedAt:
  3669. v, ok := value.(time.Time)
  3670. if !ok {
  3671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3672. }
  3673. m.SetUpdatedAt(v)
  3674. return nil
  3675. case allocagent.FieldDeletedAt:
  3676. v, ok := value.(time.Time)
  3677. if !ok {
  3678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3679. }
  3680. m.SetDeletedAt(v)
  3681. return nil
  3682. case allocagent.FieldUserID:
  3683. v, ok := value.(string)
  3684. if !ok {
  3685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3686. }
  3687. m.SetUserID(v)
  3688. return nil
  3689. case allocagent.FieldOrganizationID:
  3690. v, ok := value.(uint64)
  3691. if !ok {
  3692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3693. }
  3694. m.SetOrganizationID(v)
  3695. return nil
  3696. case allocagent.FieldAgents:
  3697. v, ok := value.([]uint64)
  3698. if !ok {
  3699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3700. }
  3701. m.SetAgents(v)
  3702. return nil
  3703. case allocagent.FieldStatus:
  3704. v, ok := value.(int)
  3705. if !ok {
  3706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3707. }
  3708. m.SetStatus(v)
  3709. return nil
  3710. }
  3711. return fmt.Errorf("unknown AllocAgent field %s", name)
  3712. }
  3713. // AddedFields returns all numeric fields that were incremented/decremented during
  3714. // this mutation.
  3715. func (m *AllocAgentMutation) AddedFields() []string {
  3716. var fields []string
  3717. if m.addorganization_id != nil {
  3718. fields = append(fields, allocagent.FieldOrganizationID)
  3719. }
  3720. if m.addstatus != nil {
  3721. fields = append(fields, allocagent.FieldStatus)
  3722. }
  3723. return fields
  3724. }
  3725. // AddedField returns the numeric value that was incremented/decremented on a field
  3726. // with the given name. The second boolean return value indicates that this field
  3727. // was not set, or was not defined in the schema.
  3728. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3729. switch name {
  3730. case allocagent.FieldOrganizationID:
  3731. return m.AddedOrganizationID()
  3732. case allocagent.FieldStatus:
  3733. return m.AddedStatus()
  3734. }
  3735. return nil, false
  3736. }
  3737. // AddField adds the value to the field with the given name. It returns an error if
  3738. // the field is not defined in the schema, or if the type mismatched the field
  3739. // type.
  3740. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3741. switch name {
  3742. case allocagent.FieldOrganizationID:
  3743. v, ok := value.(int64)
  3744. if !ok {
  3745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3746. }
  3747. m.AddOrganizationID(v)
  3748. return nil
  3749. case allocagent.FieldStatus:
  3750. v, ok := value.(int)
  3751. if !ok {
  3752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3753. }
  3754. m.AddStatus(v)
  3755. return nil
  3756. }
  3757. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3758. }
  3759. // ClearedFields returns all nullable fields that were cleared during this
  3760. // mutation.
  3761. func (m *AllocAgentMutation) ClearedFields() []string {
  3762. var fields []string
  3763. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3764. fields = append(fields, allocagent.FieldDeletedAt)
  3765. }
  3766. if m.FieldCleared(allocagent.FieldUserID) {
  3767. fields = append(fields, allocagent.FieldUserID)
  3768. }
  3769. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3770. fields = append(fields, allocagent.FieldOrganizationID)
  3771. }
  3772. if m.FieldCleared(allocagent.FieldStatus) {
  3773. fields = append(fields, allocagent.FieldStatus)
  3774. }
  3775. return fields
  3776. }
  3777. // FieldCleared returns a boolean indicating if a field with the given name was
  3778. // cleared in this mutation.
  3779. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3780. _, ok := m.clearedFields[name]
  3781. return ok
  3782. }
  3783. // ClearField clears the value of the field with the given name. It returns an
  3784. // error if the field is not defined in the schema.
  3785. func (m *AllocAgentMutation) ClearField(name string) error {
  3786. switch name {
  3787. case allocagent.FieldDeletedAt:
  3788. m.ClearDeletedAt()
  3789. return nil
  3790. case allocagent.FieldUserID:
  3791. m.ClearUserID()
  3792. return nil
  3793. case allocagent.FieldOrganizationID:
  3794. m.ClearOrganizationID()
  3795. return nil
  3796. case allocagent.FieldStatus:
  3797. m.ClearStatus()
  3798. return nil
  3799. }
  3800. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3801. }
  3802. // ResetField resets all changes in the mutation for the field with the given name.
  3803. // It returns an error if the field is not defined in the schema.
  3804. func (m *AllocAgentMutation) ResetField(name string) error {
  3805. switch name {
  3806. case allocagent.FieldCreatedAt:
  3807. m.ResetCreatedAt()
  3808. return nil
  3809. case allocagent.FieldUpdatedAt:
  3810. m.ResetUpdatedAt()
  3811. return nil
  3812. case allocagent.FieldDeletedAt:
  3813. m.ResetDeletedAt()
  3814. return nil
  3815. case allocagent.FieldUserID:
  3816. m.ResetUserID()
  3817. return nil
  3818. case allocagent.FieldOrganizationID:
  3819. m.ResetOrganizationID()
  3820. return nil
  3821. case allocagent.FieldAgents:
  3822. m.ResetAgents()
  3823. return nil
  3824. case allocagent.FieldStatus:
  3825. m.ResetStatus()
  3826. return nil
  3827. }
  3828. return fmt.Errorf("unknown AllocAgent field %s", name)
  3829. }
  3830. // AddedEdges returns all edge names that were set/added in this mutation.
  3831. func (m *AllocAgentMutation) AddedEdges() []string {
  3832. edges := make([]string, 0, 0)
  3833. return edges
  3834. }
  3835. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3836. // name in this mutation.
  3837. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3838. return nil
  3839. }
  3840. // RemovedEdges returns all edge names that were removed in this mutation.
  3841. func (m *AllocAgentMutation) RemovedEdges() []string {
  3842. edges := make([]string, 0, 0)
  3843. return edges
  3844. }
  3845. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3846. // the given name in this mutation.
  3847. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3848. return nil
  3849. }
  3850. // ClearedEdges returns all edge names that were cleared in this mutation.
  3851. func (m *AllocAgentMutation) ClearedEdges() []string {
  3852. edges := make([]string, 0, 0)
  3853. return edges
  3854. }
  3855. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3856. // was cleared in this mutation.
  3857. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3858. return false
  3859. }
  3860. // ClearEdge clears the value of the edge with the given name. It returns an error
  3861. // if that edge is not defined in the schema.
  3862. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3863. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3864. }
  3865. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3866. // It returns an error if the edge is not defined in the schema.
  3867. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3868. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3869. }
  3870. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3871. type BatchMsgMutation struct {
  3872. config
  3873. op Op
  3874. typ string
  3875. id *uint64
  3876. created_at *time.Time
  3877. updated_at *time.Time
  3878. deleted_at *time.Time
  3879. status *uint8
  3880. addstatus *int8
  3881. batch_no *string
  3882. task_name *string
  3883. fromwxid *string
  3884. msg *string
  3885. tag *string
  3886. tagids *string
  3887. total *int32
  3888. addtotal *int32
  3889. success *int32
  3890. addsuccess *int32
  3891. fail *int32
  3892. addfail *int32
  3893. start_time *time.Time
  3894. stop_time *time.Time
  3895. send_time *time.Time
  3896. _type *int32
  3897. add_type *int32
  3898. organization_id *uint64
  3899. addorganization_id *int64
  3900. clearedFields map[string]struct{}
  3901. done bool
  3902. oldValue func(context.Context) (*BatchMsg, error)
  3903. predicates []predicate.BatchMsg
  3904. }
  3905. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3906. // batchmsgOption allows management of the mutation configuration using functional options.
  3907. type batchmsgOption func(*BatchMsgMutation)
  3908. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3909. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3910. m := &BatchMsgMutation{
  3911. config: c,
  3912. op: op,
  3913. typ: TypeBatchMsg,
  3914. clearedFields: make(map[string]struct{}),
  3915. }
  3916. for _, opt := range opts {
  3917. opt(m)
  3918. }
  3919. return m
  3920. }
  3921. // withBatchMsgID sets the ID field of the mutation.
  3922. func withBatchMsgID(id uint64) batchmsgOption {
  3923. return func(m *BatchMsgMutation) {
  3924. var (
  3925. err error
  3926. once sync.Once
  3927. value *BatchMsg
  3928. )
  3929. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3930. once.Do(func() {
  3931. if m.done {
  3932. err = errors.New("querying old values post mutation is not allowed")
  3933. } else {
  3934. value, err = m.Client().BatchMsg.Get(ctx, id)
  3935. }
  3936. })
  3937. return value, err
  3938. }
  3939. m.id = &id
  3940. }
  3941. }
  3942. // withBatchMsg sets the old BatchMsg of the mutation.
  3943. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3944. return func(m *BatchMsgMutation) {
  3945. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3946. return node, nil
  3947. }
  3948. m.id = &node.ID
  3949. }
  3950. }
  3951. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3952. // executed in a transaction (ent.Tx), a transactional client is returned.
  3953. func (m BatchMsgMutation) Client() *Client {
  3954. client := &Client{config: m.config}
  3955. client.init()
  3956. return client
  3957. }
  3958. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3959. // it returns an error otherwise.
  3960. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3961. if _, ok := m.driver.(*txDriver); !ok {
  3962. return nil, errors.New("ent: mutation is not running in a transaction")
  3963. }
  3964. tx := &Tx{config: m.config}
  3965. tx.init()
  3966. return tx, nil
  3967. }
  3968. // SetID sets the value of the id field. Note that this
  3969. // operation is only accepted on creation of BatchMsg entities.
  3970. func (m *BatchMsgMutation) SetID(id uint64) {
  3971. m.id = &id
  3972. }
  3973. // ID returns the ID value in the mutation. Note that the ID is only available
  3974. // if it was provided to the builder or after it was returned from the database.
  3975. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3976. if m.id == nil {
  3977. return
  3978. }
  3979. return *m.id, true
  3980. }
  3981. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3982. // That means, if the mutation is applied within a transaction with an isolation level such
  3983. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3984. // or updated by the mutation.
  3985. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3986. switch {
  3987. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3988. id, exists := m.ID()
  3989. if exists {
  3990. return []uint64{id}, nil
  3991. }
  3992. fallthrough
  3993. case m.op.Is(OpUpdate | OpDelete):
  3994. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3995. default:
  3996. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3997. }
  3998. }
  3999. // SetCreatedAt sets the "created_at" field.
  4000. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4001. m.created_at = &t
  4002. }
  4003. // CreatedAt returns the value of the "created_at" field in the mutation.
  4004. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4005. v := m.created_at
  4006. if v == nil {
  4007. return
  4008. }
  4009. return *v, true
  4010. }
  4011. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4012. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4014. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4015. if !m.op.Is(OpUpdateOne) {
  4016. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4017. }
  4018. if m.id == nil || m.oldValue == nil {
  4019. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4020. }
  4021. oldValue, err := m.oldValue(ctx)
  4022. if err != nil {
  4023. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4024. }
  4025. return oldValue.CreatedAt, nil
  4026. }
  4027. // ResetCreatedAt resets all changes to the "created_at" field.
  4028. func (m *BatchMsgMutation) ResetCreatedAt() {
  4029. m.created_at = nil
  4030. }
  4031. // SetUpdatedAt sets the "updated_at" field.
  4032. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4033. m.updated_at = &t
  4034. }
  4035. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4036. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4037. v := m.updated_at
  4038. if v == nil {
  4039. return
  4040. }
  4041. return *v, true
  4042. }
  4043. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4044. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4046. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4047. if !m.op.Is(OpUpdateOne) {
  4048. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4049. }
  4050. if m.id == nil || m.oldValue == nil {
  4051. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4052. }
  4053. oldValue, err := m.oldValue(ctx)
  4054. if err != nil {
  4055. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4056. }
  4057. return oldValue.UpdatedAt, nil
  4058. }
  4059. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4060. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4061. m.updated_at = nil
  4062. }
  4063. // SetDeletedAt sets the "deleted_at" field.
  4064. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4065. m.deleted_at = &t
  4066. }
  4067. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4068. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4069. v := m.deleted_at
  4070. if v == nil {
  4071. return
  4072. }
  4073. return *v, true
  4074. }
  4075. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4076. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4078. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4079. if !m.op.Is(OpUpdateOne) {
  4080. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4081. }
  4082. if m.id == nil || m.oldValue == nil {
  4083. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4084. }
  4085. oldValue, err := m.oldValue(ctx)
  4086. if err != nil {
  4087. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4088. }
  4089. return oldValue.DeletedAt, nil
  4090. }
  4091. // ClearDeletedAt clears the value of the "deleted_at" field.
  4092. func (m *BatchMsgMutation) ClearDeletedAt() {
  4093. m.deleted_at = nil
  4094. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4095. }
  4096. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4097. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4098. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4099. return ok
  4100. }
  4101. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4102. func (m *BatchMsgMutation) ResetDeletedAt() {
  4103. m.deleted_at = nil
  4104. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4105. }
  4106. // SetStatus sets the "status" field.
  4107. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4108. m.status = &u
  4109. m.addstatus = nil
  4110. }
  4111. // Status returns the value of the "status" field in the mutation.
  4112. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4113. v := m.status
  4114. if v == nil {
  4115. return
  4116. }
  4117. return *v, true
  4118. }
  4119. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4120. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4122. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4123. if !m.op.Is(OpUpdateOne) {
  4124. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4125. }
  4126. if m.id == nil || m.oldValue == nil {
  4127. return v, errors.New("OldStatus requires an ID field in the mutation")
  4128. }
  4129. oldValue, err := m.oldValue(ctx)
  4130. if err != nil {
  4131. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4132. }
  4133. return oldValue.Status, nil
  4134. }
  4135. // AddStatus adds u to the "status" field.
  4136. func (m *BatchMsgMutation) AddStatus(u int8) {
  4137. if m.addstatus != nil {
  4138. *m.addstatus += u
  4139. } else {
  4140. m.addstatus = &u
  4141. }
  4142. }
  4143. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4144. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4145. v := m.addstatus
  4146. if v == nil {
  4147. return
  4148. }
  4149. return *v, true
  4150. }
  4151. // ClearStatus clears the value of the "status" field.
  4152. func (m *BatchMsgMutation) ClearStatus() {
  4153. m.status = nil
  4154. m.addstatus = nil
  4155. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4156. }
  4157. // StatusCleared returns if the "status" field was cleared in this mutation.
  4158. func (m *BatchMsgMutation) StatusCleared() bool {
  4159. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4160. return ok
  4161. }
  4162. // ResetStatus resets all changes to the "status" field.
  4163. func (m *BatchMsgMutation) ResetStatus() {
  4164. m.status = nil
  4165. m.addstatus = nil
  4166. delete(m.clearedFields, batchmsg.FieldStatus)
  4167. }
  4168. // SetBatchNo sets the "batch_no" field.
  4169. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4170. m.batch_no = &s
  4171. }
  4172. // BatchNo returns the value of the "batch_no" field in the mutation.
  4173. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4174. v := m.batch_no
  4175. if v == nil {
  4176. return
  4177. }
  4178. return *v, true
  4179. }
  4180. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4181. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4183. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4184. if !m.op.Is(OpUpdateOne) {
  4185. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4186. }
  4187. if m.id == nil || m.oldValue == nil {
  4188. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4189. }
  4190. oldValue, err := m.oldValue(ctx)
  4191. if err != nil {
  4192. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4193. }
  4194. return oldValue.BatchNo, nil
  4195. }
  4196. // ClearBatchNo clears the value of the "batch_no" field.
  4197. func (m *BatchMsgMutation) ClearBatchNo() {
  4198. m.batch_no = nil
  4199. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4200. }
  4201. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4202. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4203. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4204. return ok
  4205. }
  4206. // ResetBatchNo resets all changes to the "batch_no" field.
  4207. func (m *BatchMsgMutation) ResetBatchNo() {
  4208. m.batch_no = nil
  4209. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4210. }
  4211. // SetTaskName sets the "task_name" field.
  4212. func (m *BatchMsgMutation) SetTaskName(s string) {
  4213. m.task_name = &s
  4214. }
  4215. // TaskName returns the value of the "task_name" field in the mutation.
  4216. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4217. v := m.task_name
  4218. if v == nil {
  4219. return
  4220. }
  4221. return *v, true
  4222. }
  4223. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4224. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4226. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4227. if !m.op.Is(OpUpdateOne) {
  4228. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4229. }
  4230. if m.id == nil || m.oldValue == nil {
  4231. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4232. }
  4233. oldValue, err := m.oldValue(ctx)
  4234. if err != nil {
  4235. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4236. }
  4237. return oldValue.TaskName, nil
  4238. }
  4239. // ClearTaskName clears the value of the "task_name" field.
  4240. func (m *BatchMsgMutation) ClearTaskName() {
  4241. m.task_name = nil
  4242. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4243. }
  4244. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4245. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4246. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4247. return ok
  4248. }
  4249. // ResetTaskName resets all changes to the "task_name" field.
  4250. func (m *BatchMsgMutation) ResetTaskName() {
  4251. m.task_name = nil
  4252. delete(m.clearedFields, batchmsg.FieldTaskName)
  4253. }
  4254. // SetFromwxid sets the "fromwxid" field.
  4255. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4256. m.fromwxid = &s
  4257. }
  4258. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4259. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4260. v := m.fromwxid
  4261. if v == nil {
  4262. return
  4263. }
  4264. return *v, true
  4265. }
  4266. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4267. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4269. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4270. if !m.op.Is(OpUpdateOne) {
  4271. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4272. }
  4273. if m.id == nil || m.oldValue == nil {
  4274. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4275. }
  4276. oldValue, err := m.oldValue(ctx)
  4277. if err != nil {
  4278. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4279. }
  4280. return oldValue.Fromwxid, nil
  4281. }
  4282. // ClearFromwxid clears the value of the "fromwxid" field.
  4283. func (m *BatchMsgMutation) ClearFromwxid() {
  4284. m.fromwxid = nil
  4285. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4286. }
  4287. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4288. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4289. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4290. return ok
  4291. }
  4292. // ResetFromwxid resets all changes to the "fromwxid" field.
  4293. func (m *BatchMsgMutation) ResetFromwxid() {
  4294. m.fromwxid = nil
  4295. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4296. }
  4297. // SetMsg sets the "msg" field.
  4298. func (m *BatchMsgMutation) SetMsg(s string) {
  4299. m.msg = &s
  4300. }
  4301. // Msg returns the value of the "msg" field in the mutation.
  4302. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4303. v := m.msg
  4304. if v == nil {
  4305. return
  4306. }
  4307. return *v, true
  4308. }
  4309. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4310. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4312. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4313. if !m.op.Is(OpUpdateOne) {
  4314. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4315. }
  4316. if m.id == nil || m.oldValue == nil {
  4317. return v, errors.New("OldMsg requires an ID field in the mutation")
  4318. }
  4319. oldValue, err := m.oldValue(ctx)
  4320. if err != nil {
  4321. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4322. }
  4323. return oldValue.Msg, nil
  4324. }
  4325. // ClearMsg clears the value of the "msg" field.
  4326. func (m *BatchMsgMutation) ClearMsg() {
  4327. m.msg = nil
  4328. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4329. }
  4330. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4331. func (m *BatchMsgMutation) MsgCleared() bool {
  4332. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4333. return ok
  4334. }
  4335. // ResetMsg resets all changes to the "msg" field.
  4336. func (m *BatchMsgMutation) ResetMsg() {
  4337. m.msg = nil
  4338. delete(m.clearedFields, batchmsg.FieldMsg)
  4339. }
  4340. // SetTag sets the "tag" field.
  4341. func (m *BatchMsgMutation) SetTag(s string) {
  4342. m.tag = &s
  4343. }
  4344. // Tag returns the value of the "tag" field in the mutation.
  4345. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4346. v := m.tag
  4347. if v == nil {
  4348. return
  4349. }
  4350. return *v, true
  4351. }
  4352. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4353. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4355. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4356. if !m.op.Is(OpUpdateOne) {
  4357. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4358. }
  4359. if m.id == nil || m.oldValue == nil {
  4360. return v, errors.New("OldTag requires an ID field in the mutation")
  4361. }
  4362. oldValue, err := m.oldValue(ctx)
  4363. if err != nil {
  4364. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4365. }
  4366. return oldValue.Tag, nil
  4367. }
  4368. // ClearTag clears the value of the "tag" field.
  4369. func (m *BatchMsgMutation) ClearTag() {
  4370. m.tag = nil
  4371. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4372. }
  4373. // TagCleared returns if the "tag" field was cleared in this mutation.
  4374. func (m *BatchMsgMutation) TagCleared() bool {
  4375. _, ok := m.clearedFields[batchmsg.FieldTag]
  4376. return ok
  4377. }
  4378. // ResetTag resets all changes to the "tag" field.
  4379. func (m *BatchMsgMutation) ResetTag() {
  4380. m.tag = nil
  4381. delete(m.clearedFields, batchmsg.FieldTag)
  4382. }
  4383. // SetTagids sets the "tagids" field.
  4384. func (m *BatchMsgMutation) SetTagids(s string) {
  4385. m.tagids = &s
  4386. }
  4387. // Tagids returns the value of the "tagids" field in the mutation.
  4388. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4389. v := m.tagids
  4390. if v == nil {
  4391. return
  4392. }
  4393. return *v, true
  4394. }
  4395. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4396. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4398. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4399. if !m.op.Is(OpUpdateOne) {
  4400. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4401. }
  4402. if m.id == nil || m.oldValue == nil {
  4403. return v, errors.New("OldTagids requires an ID field in the mutation")
  4404. }
  4405. oldValue, err := m.oldValue(ctx)
  4406. if err != nil {
  4407. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4408. }
  4409. return oldValue.Tagids, nil
  4410. }
  4411. // ClearTagids clears the value of the "tagids" field.
  4412. func (m *BatchMsgMutation) ClearTagids() {
  4413. m.tagids = nil
  4414. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4415. }
  4416. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4417. func (m *BatchMsgMutation) TagidsCleared() bool {
  4418. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4419. return ok
  4420. }
  4421. // ResetTagids resets all changes to the "tagids" field.
  4422. func (m *BatchMsgMutation) ResetTagids() {
  4423. m.tagids = nil
  4424. delete(m.clearedFields, batchmsg.FieldTagids)
  4425. }
  4426. // SetTotal sets the "total" field.
  4427. func (m *BatchMsgMutation) SetTotal(i int32) {
  4428. m.total = &i
  4429. m.addtotal = nil
  4430. }
  4431. // Total returns the value of the "total" field in the mutation.
  4432. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4433. v := m.total
  4434. if v == nil {
  4435. return
  4436. }
  4437. return *v, true
  4438. }
  4439. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4440. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4442. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4443. if !m.op.Is(OpUpdateOne) {
  4444. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4445. }
  4446. if m.id == nil || m.oldValue == nil {
  4447. return v, errors.New("OldTotal requires an ID field in the mutation")
  4448. }
  4449. oldValue, err := m.oldValue(ctx)
  4450. if err != nil {
  4451. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4452. }
  4453. return oldValue.Total, nil
  4454. }
  4455. // AddTotal adds i to the "total" field.
  4456. func (m *BatchMsgMutation) AddTotal(i int32) {
  4457. if m.addtotal != nil {
  4458. *m.addtotal += i
  4459. } else {
  4460. m.addtotal = &i
  4461. }
  4462. }
  4463. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4464. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4465. v := m.addtotal
  4466. if v == nil {
  4467. return
  4468. }
  4469. return *v, true
  4470. }
  4471. // ClearTotal clears the value of the "total" field.
  4472. func (m *BatchMsgMutation) ClearTotal() {
  4473. m.total = nil
  4474. m.addtotal = nil
  4475. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4476. }
  4477. // TotalCleared returns if the "total" field was cleared in this mutation.
  4478. func (m *BatchMsgMutation) TotalCleared() bool {
  4479. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4480. return ok
  4481. }
  4482. // ResetTotal resets all changes to the "total" field.
  4483. func (m *BatchMsgMutation) ResetTotal() {
  4484. m.total = nil
  4485. m.addtotal = nil
  4486. delete(m.clearedFields, batchmsg.FieldTotal)
  4487. }
  4488. // SetSuccess sets the "success" field.
  4489. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4490. m.success = &i
  4491. m.addsuccess = nil
  4492. }
  4493. // Success returns the value of the "success" field in the mutation.
  4494. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4495. v := m.success
  4496. if v == nil {
  4497. return
  4498. }
  4499. return *v, true
  4500. }
  4501. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4502. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4504. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4505. if !m.op.Is(OpUpdateOne) {
  4506. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4507. }
  4508. if m.id == nil || m.oldValue == nil {
  4509. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4510. }
  4511. oldValue, err := m.oldValue(ctx)
  4512. if err != nil {
  4513. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4514. }
  4515. return oldValue.Success, nil
  4516. }
  4517. // AddSuccess adds i to the "success" field.
  4518. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4519. if m.addsuccess != nil {
  4520. *m.addsuccess += i
  4521. } else {
  4522. m.addsuccess = &i
  4523. }
  4524. }
  4525. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4526. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4527. v := m.addsuccess
  4528. if v == nil {
  4529. return
  4530. }
  4531. return *v, true
  4532. }
  4533. // ClearSuccess clears the value of the "success" field.
  4534. func (m *BatchMsgMutation) ClearSuccess() {
  4535. m.success = nil
  4536. m.addsuccess = nil
  4537. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4538. }
  4539. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4540. func (m *BatchMsgMutation) SuccessCleared() bool {
  4541. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4542. return ok
  4543. }
  4544. // ResetSuccess resets all changes to the "success" field.
  4545. func (m *BatchMsgMutation) ResetSuccess() {
  4546. m.success = nil
  4547. m.addsuccess = nil
  4548. delete(m.clearedFields, batchmsg.FieldSuccess)
  4549. }
  4550. // SetFail sets the "fail" field.
  4551. func (m *BatchMsgMutation) SetFail(i int32) {
  4552. m.fail = &i
  4553. m.addfail = nil
  4554. }
  4555. // Fail returns the value of the "fail" field in the mutation.
  4556. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4557. v := m.fail
  4558. if v == nil {
  4559. return
  4560. }
  4561. return *v, true
  4562. }
  4563. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4564. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4566. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4567. if !m.op.Is(OpUpdateOne) {
  4568. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4569. }
  4570. if m.id == nil || m.oldValue == nil {
  4571. return v, errors.New("OldFail requires an ID field in the mutation")
  4572. }
  4573. oldValue, err := m.oldValue(ctx)
  4574. if err != nil {
  4575. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4576. }
  4577. return oldValue.Fail, nil
  4578. }
  4579. // AddFail adds i to the "fail" field.
  4580. func (m *BatchMsgMutation) AddFail(i int32) {
  4581. if m.addfail != nil {
  4582. *m.addfail += i
  4583. } else {
  4584. m.addfail = &i
  4585. }
  4586. }
  4587. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4588. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4589. v := m.addfail
  4590. if v == nil {
  4591. return
  4592. }
  4593. return *v, true
  4594. }
  4595. // ClearFail clears the value of the "fail" field.
  4596. func (m *BatchMsgMutation) ClearFail() {
  4597. m.fail = nil
  4598. m.addfail = nil
  4599. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4600. }
  4601. // FailCleared returns if the "fail" field was cleared in this mutation.
  4602. func (m *BatchMsgMutation) FailCleared() bool {
  4603. _, ok := m.clearedFields[batchmsg.FieldFail]
  4604. return ok
  4605. }
  4606. // ResetFail resets all changes to the "fail" field.
  4607. func (m *BatchMsgMutation) ResetFail() {
  4608. m.fail = nil
  4609. m.addfail = nil
  4610. delete(m.clearedFields, batchmsg.FieldFail)
  4611. }
  4612. // SetStartTime sets the "start_time" field.
  4613. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4614. m.start_time = &t
  4615. }
  4616. // StartTime returns the value of the "start_time" field in the mutation.
  4617. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4618. v := m.start_time
  4619. if v == nil {
  4620. return
  4621. }
  4622. return *v, true
  4623. }
  4624. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4625. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4627. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4628. if !m.op.Is(OpUpdateOne) {
  4629. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4630. }
  4631. if m.id == nil || m.oldValue == nil {
  4632. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4633. }
  4634. oldValue, err := m.oldValue(ctx)
  4635. if err != nil {
  4636. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4637. }
  4638. return oldValue.StartTime, nil
  4639. }
  4640. // ClearStartTime clears the value of the "start_time" field.
  4641. func (m *BatchMsgMutation) ClearStartTime() {
  4642. m.start_time = nil
  4643. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4644. }
  4645. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4646. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4647. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4648. return ok
  4649. }
  4650. // ResetStartTime resets all changes to the "start_time" field.
  4651. func (m *BatchMsgMutation) ResetStartTime() {
  4652. m.start_time = nil
  4653. delete(m.clearedFields, batchmsg.FieldStartTime)
  4654. }
  4655. // SetStopTime sets the "stop_time" field.
  4656. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4657. m.stop_time = &t
  4658. }
  4659. // StopTime returns the value of the "stop_time" field in the mutation.
  4660. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4661. v := m.stop_time
  4662. if v == nil {
  4663. return
  4664. }
  4665. return *v, true
  4666. }
  4667. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4668. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4670. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4671. if !m.op.Is(OpUpdateOne) {
  4672. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4673. }
  4674. if m.id == nil || m.oldValue == nil {
  4675. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4676. }
  4677. oldValue, err := m.oldValue(ctx)
  4678. if err != nil {
  4679. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4680. }
  4681. return oldValue.StopTime, nil
  4682. }
  4683. // ClearStopTime clears the value of the "stop_time" field.
  4684. func (m *BatchMsgMutation) ClearStopTime() {
  4685. m.stop_time = nil
  4686. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4687. }
  4688. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4689. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4690. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4691. return ok
  4692. }
  4693. // ResetStopTime resets all changes to the "stop_time" field.
  4694. func (m *BatchMsgMutation) ResetStopTime() {
  4695. m.stop_time = nil
  4696. delete(m.clearedFields, batchmsg.FieldStopTime)
  4697. }
  4698. // SetSendTime sets the "send_time" field.
  4699. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4700. m.send_time = &t
  4701. }
  4702. // SendTime returns the value of the "send_time" field in the mutation.
  4703. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4704. v := m.send_time
  4705. if v == nil {
  4706. return
  4707. }
  4708. return *v, true
  4709. }
  4710. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4711. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4713. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4714. if !m.op.Is(OpUpdateOne) {
  4715. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4716. }
  4717. if m.id == nil || m.oldValue == nil {
  4718. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4719. }
  4720. oldValue, err := m.oldValue(ctx)
  4721. if err != nil {
  4722. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4723. }
  4724. return oldValue.SendTime, nil
  4725. }
  4726. // ClearSendTime clears the value of the "send_time" field.
  4727. func (m *BatchMsgMutation) ClearSendTime() {
  4728. m.send_time = nil
  4729. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4730. }
  4731. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4732. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4733. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4734. return ok
  4735. }
  4736. // ResetSendTime resets all changes to the "send_time" field.
  4737. func (m *BatchMsgMutation) ResetSendTime() {
  4738. m.send_time = nil
  4739. delete(m.clearedFields, batchmsg.FieldSendTime)
  4740. }
  4741. // SetType sets the "type" field.
  4742. func (m *BatchMsgMutation) SetType(i int32) {
  4743. m._type = &i
  4744. m.add_type = nil
  4745. }
  4746. // GetType returns the value of the "type" field in the mutation.
  4747. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4748. v := m._type
  4749. if v == nil {
  4750. return
  4751. }
  4752. return *v, true
  4753. }
  4754. // OldType returns the old "type" field's value of the BatchMsg entity.
  4755. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4757. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4758. if !m.op.Is(OpUpdateOne) {
  4759. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4760. }
  4761. if m.id == nil || m.oldValue == nil {
  4762. return v, errors.New("OldType requires an ID field in the mutation")
  4763. }
  4764. oldValue, err := m.oldValue(ctx)
  4765. if err != nil {
  4766. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4767. }
  4768. return oldValue.Type, nil
  4769. }
  4770. // AddType adds i to the "type" field.
  4771. func (m *BatchMsgMutation) AddType(i int32) {
  4772. if m.add_type != nil {
  4773. *m.add_type += i
  4774. } else {
  4775. m.add_type = &i
  4776. }
  4777. }
  4778. // AddedType returns the value that was added to the "type" field in this mutation.
  4779. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4780. v := m.add_type
  4781. if v == nil {
  4782. return
  4783. }
  4784. return *v, true
  4785. }
  4786. // ClearType clears the value of the "type" field.
  4787. func (m *BatchMsgMutation) ClearType() {
  4788. m._type = nil
  4789. m.add_type = nil
  4790. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4791. }
  4792. // TypeCleared returns if the "type" field was cleared in this mutation.
  4793. func (m *BatchMsgMutation) TypeCleared() bool {
  4794. _, ok := m.clearedFields[batchmsg.FieldType]
  4795. return ok
  4796. }
  4797. // ResetType resets all changes to the "type" field.
  4798. func (m *BatchMsgMutation) ResetType() {
  4799. m._type = nil
  4800. m.add_type = nil
  4801. delete(m.clearedFields, batchmsg.FieldType)
  4802. }
  4803. // SetOrganizationID sets the "organization_id" field.
  4804. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4805. m.organization_id = &u
  4806. m.addorganization_id = nil
  4807. }
  4808. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4809. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4810. v := m.organization_id
  4811. if v == nil {
  4812. return
  4813. }
  4814. return *v, true
  4815. }
  4816. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4817. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4819. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4820. if !m.op.Is(OpUpdateOne) {
  4821. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4822. }
  4823. if m.id == nil || m.oldValue == nil {
  4824. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4825. }
  4826. oldValue, err := m.oldValue(ctx)
  4827. if err != nil {
  4828. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4829. }
  4830. return oldValue.OrganizationID, nil
  4831. }
  4832. // AddOrganizationID adds u to the "organization_id" field.
  4833. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4834. if m.addorganization_id != nil {
  4835. *m.addorganization_id += u
  4836. } else {
  4837. m.addorganization_id = &u
  4838. }
  4839. }
  4840. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4841. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4842. v := m.addorganization_id
  4843. if v == nil {
  4844. return
  4845. }
  4846. return *v, true
  4847. }
  4848. // ResetOrganizationID resets all changes to the "organization_id" field.
  4849. func (m *BatchMsgMutation) ResetOrganizationID() {
  4850. m.organization_id = nil
  4851. m.addorganization_id = nil
  4852. }
  4853. // Where appends a list predicates to the BatchMsgMutation builder.
  4854. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4855. m.predicates = append(m.predicates, ps...)
  4856. }
  4857. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4858. // users can use type-assertion to append predicates that do not depend on any generated package.
  4859. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4860. p := make([]predicate.BatchMsg, len(ps))
  4861. for i := range ps {
  4862. p[i] = ps[i]
  4863. }
  4864. m.Where(p...)
  4865. }
  4866. // Op returns the operation name.
  4867. func (m *BatchMsgMutation) Op() Op {
  4868. return m.op
  4869. }
  4870. // SetOp allows setting the mutation operation.
  4871. func (m *BatchMsgMutation) SetOp(op Op) {
  4872. m.op = op
  4873. }
  4874. // Type returns the node type of this mutation (BatchMsg).
  4875. func (m *BatchMsgMutation) Type() string {
  4876. return m.typ
  4877. }
  4878. // Fields returns all fields that were changed during this mutation. Note that in
  4879. // order to get all numeric fields that were incremented/decremented, call
  4880. // AddedFields().
  4881. func (m *BatchMsgMutation) Fields() []string {
  4882. fields := make([]string, 0, 18)
  4883. if m.created_at != nil {
  4884. fields = append(fields, batchmsg.FieldCreatedAt)
  4885. }
  4886. if m.updated_at != nil {
  4887. fields = append(fields, batchmsg.FieldUpdatedAt)
  4888. }
  4889. if m.deleted_at != nil {
  4890. fields = append(fields, batchmsg.FieldDeletedAt)
  4891. }
  4892. if m.status != nil {
  4893. fields = append(fields, batchmsg.FieldStatus)
  4894. }
  4895. if m.batch_no != nil {
  4896. fields = append(fields, batchmsg.FieldBatchNo)
  4897. }
  4898. if m.task_name != nil {
  4899. fields = append(fields, batchmsg.FieldTaskName)
  4900. }
  4901. if m.fromwxid != nil {
  4902. fields = append(fields, batchmsg.FieldFromwxid)
  4903. }
  4904. if m.msg != nil {
  4905. fields = append(fields, batchmsg.FieldMsg)
  4906. }
  4907. if m.tag != nil {
  4908. fields = append(fields, batchmsg.FieldTag)
  4909. }
  4910. if m.tagids != nil {
  4911. fields = append(fields, batchmsg.FieldTagids)
  4912. }
  4913. if m.total != nil {
  4914. fields = append(fields, batchmsg.FieldTotal)
  4915. }
  4916. if m.success != nil {
  4917. fields = append(fields, batchmsg.FieldSuccess)
  4918. }
  4919. if m.fail != nil {
  4920. fields = append(fields, batchmsg.FieldFail)
  4921. }
  4922. if m.start_time != nil {
  4923. fields = append(fields, batchmsg.FieldStartTime)
  4924. }
  4925. if m.stop_time != nil {
  4926. fields = append(fields, batchmsg.FieldStopTime)
  4927. }
  4928. if m.send_time != nil {
  4929. fields = append(fields, batchmsg.FieldSendTime)
  4930. }
  4931. if m._type != nil {
  4932. fields = append(fields, batchmsg.FieldType)
  4933. }
  4934. if m.organization_id != nil {
  4935. fields = append(fields, batchmsg.FieldOrganizationID)
  4936. }
  4937. return fields
  4938. }
  4939. // Field returns the value of a field with the given name. The second boolean
  4940. // return value indicates that this field was not set, or was not defined in the
  4941. // schema.
  4942. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4943. switch name {
  4944. case batchmsg.FieldCreatedAt:
  4945. return m.CreatedAt()
  4946. case batchmsg.FieldUpdatedAt:
  4947. return m.UpdatedAt()
  4948. case batchmsg.FieldDeletedAt:
  4949. return m.DeletedAt()
  4950. case batchmsg.FieldStatus:
  4951. return m.Status()
  4952. case batchmsg.FieldBatchNo:
  4953. return m.BatchNo()
  4954. case batchmsg.FieldTaskName:
  4955. return m.TaskName()
  4956. case batchmsg.FieldFromwxid:
  4957. return m.Fromwxid()
  4958. case batchmsg.FieldMsg:
  4959. return m.Msg()
  4960. case batchmsg.FieldTag:
  4961. return m.Tag()
  4962. case batchmsg.FieldTagids:
  4963. return m.Tagids()
  4964. case batchmsg.FieldTotal:
  4965. return m.Total()
  4966. case batchmsg.FieldSuccess:
  4967. return m.Success()
  4968. case batchmsg.FieldFail:
  4969. return m.Fail()
  4970. case batchmsg.FieldStartTime:
  4971. return m.StartTime()
  4972. case batchmsg.FieldStopTime:
  4973. return m.StopTime()
  4974. case batchmsg.FieldSendTime:
  4975. return m.SendTime()
  4976. case batchmsg.FieldType:
  4977. return m.GetType()
  4978. case batchmsg.FieldOrganizationID:
  4979. return m.OrganizationID()
  4980. }
  4981. return nil, false
  4982. }
  4983. // OldField returns the old value of the field from the database. An error is
  4984. // returned if the mutation operation is not UpdateOne, or the query to the
  4985. // database failed.
  4986. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4987. switch name {
  4988. case batchmsg.FieldCreatedAt:
  4989. return m.OldCreatedAt(ctx)
  4990. case batchmsg.FieldUpdatedAt:
  4991. return m.OldUpdatedAt(ctx)
  4992. case batchmsg.FieldDeletedAt:
  4993. return m.OldDeletedAt(ctx)
  4994. case batchmsg.FieldStatus:
  4995. return m.OldStatus(ctx)
  4996. case batchmsg.FieldBatchNo:
  4997. return m.OldBatchNo(ctx)
  4998. case batchmsg.FieldTaskName:
  4999. return m.OldTaskName(ctx)
  5000. case batchmsg.FieldFromwxid:
  5001. return m.OldFromwxid(ctx)
  5002. case batchmsg.FieldMsg:
  5003. return m.OldMsg(ctx)
  5004. case batchmsg.FieldTag:
  5005. return m.OldTag(ctx)
  5006. case batchmsg.FieldTagids:
  5007. return m.OldTagids(ctx)
  5008. case batchmsg.FieldTotal:
  5009. return m.OldTotal(ctx)
  5010. case batchmsg.FieldSuccess:
  5011. return m.OldSuccess(ctx)
  5012. case batchmsg.FieldFail:
  5013. return m.OldFail(ctx)
  5014. case batchmsg.FieldStartTime:
  5015. return m.OldStartTime(ctx)
  5016. case batchmsg.FieldStopTime:
  5017. return m.OldStopTime(ctx)
  5018. case batchmsg.FieldSendTime:
  5019. return m.OldSendTime(ctx)
  5020. case batchmsg.FieldType:
  5021. return m.OldType(ctx)
  5022. case batchmsg.FieldOrganizationID:
  5023. return m.OldOrganizationID(ctx)
  5024. }
  5025. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5026. }
  5027. // SetField sets the value of a field with the given name. It returns an error if
  5028. // the field is not defined in the schema, or if the type mismatched the field
  5029. // type.
  5030. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5031. switch name {
  5032. case batchmsg.FieldCreatedAt:
  5033. v, ok := value.(time.Time)
  5034. if !ok {
  5035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5036. }
  5037. m.SetCreatedAt(v)
  5038. return nil
  5039. case batchmsg.FieldUpdatedAt:
  5040. v, ok := value.(time.Time)
  5041. if !ok {
  5042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5043. }
  5044. m.SetUpdatedAt(v)
  5045. return nil
  5046. case batchmsg.FieldDeletedAt:
  5047. v, ok := value.(time.Time)
  5048. if !ok {
  5049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5050. }
  5051. m.SetDeletedAt(v)
  5052. return nil
  5053. case batchmsg.FieldStatus:
  5054. v, ok := value.(uint8)
  5055. if !ok {
  5056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5057. }
  5058. m.SetStatus(v)
  5059. return nil
  5060. case batchmsg.FieldBatchNo:
  5061. v, ok := value.(string)
  5062. if !ok {
  5063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5064. }
  5065. m.SetBatchNo(v)
  5066. return nil
  5067. case batchmsg.FieldTaskName:
  5068. v, ok := value.(string)
  5069. if !ok {
  5070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5071. }
  5072. m.SetTaskName(v)
  5073. return nil
  5074. case batchmsg.FieldFromwxid:
  5075. v, ok := value.(string)
  5076. if !ok {
  5077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5078. }
  5079. m.SetFromwxid(v)
  5080. return nil
  5081. case batchmsg.FieldMsg:
  5082. v, ok := value.(string)
  5083. if !ok {
  5084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5085. }
  5086. m.SetMsg(v)
  5087. return nil
  5088. case batchmsg.FieldTag:
  5089. v, ok := value.(string)
  5090. if !ok {
  5091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5092. }
  5093. m.SetTag(v)
  5094. return nil
  5095. case batchmsg.FieldTagids:
  5096. v, ok := value.(string)
  5097. if !ok {
  5098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5099. }
  5100. m.SetTagids(v)
  5101. return nil
  5102. case batchmsg.FieldTotal:
  5103. v, ok := value.(int32)
  5104. if !ok {
  5105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5106. }
  5107. m.SetTotal(v)
  5108. return nil
  5109. case batchmsg.FieldSuccess:
  5110. v, ok := value.(int32)
  5111. if !ok {
  5112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5113. }
  5114. m.SetSuccess(v)
  5115. return nil
  5116. case batchmsg.FieldFail:
  5117. v, ok := value.(int32)
  5118. if !ok {
  5119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5120. }
  5121. m.SetFail(v)
  5122. return nil
  5123. case batchmsg.FieldStartTime:
  5124. v, ok := value.(time.Time)
  5125. if !ok {
  5126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5127. }
  5128. m.SetStartTime(v)
  5129. return nil
  5130. case batchmsg.FieldStopTime:
  5131. v, ok := value.(time.Time)
  5132. if !ok {
  5133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5134. }
  5135. m.SetStopTime(v)
  5136. return nil
  5137. case batchmsg.FieldSendTime:
  5138. v, ok := value.(time.Time)
  5139. if !ok {
  5140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5141. }
  5142. m.SetSendTime(v)
  5143. return nil
  5144. case batchmsg.FieldType:
  5145. v, ok := value.(int32)
  5146. if !ok {
  5147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5148. }
  5149. m.SetType(v)
  5150. return nil
  5151. case batchmsg.FieldOrganizationID:
  5152. v, ok := value.(uint64)
  5153. if !ok {
  5154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5155. }
  5156. m.SetOrganizationID(v)
  5157. return nil
  5158. }
  5159. return fmt.Errorf("unknown BatchMsg field %s", name)
  5160. }
  5161. // AddedFields returns all numeric fields that were incremented/decremented during
  5162. // this mutation.
  5163. func (m *BatchMsgMutation) AddedFields() []string {
  5164. var fields []string
  5165. if m.addstatus != nil {
  5166. fields = append(fields, batchmsg.FieldStatus)
  5167. }
  5168. if m.addtotal != nil {
  5169. fields = append(fields, batchmsg.FieldTotal)
  5170. }
  5171. if m.addsuccess != nil {
  5172. fields = append(fields, batchmsg.FieldSuccess)
  5173. }
  5174. if m.addfail != nil {
  5175. fields = append(fields, batchmsg.FieldFail)
  5176. }
  5177. if m.add_type != nil {
  5178. fields = append(fields, batchmsg.FieldType)
  5179. }
  5180. if m.addorganization_id != nil {
  5181. fields = append(fields, batchmsg.FieldOrganizationID)
  5182. }
  5183. return fields
  5184. }
  5185. // AddedField returns the numeric value that was incremented/decremented on a field
  5186. // with the given name. The second boolean return value indicates that this field
  5187. // was not set, or was not defined in the schema.
  5188. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5189. switch name {
  5190. case batchmsg.FieldStatus:
  5191. return m.AddedStatus()
  5192. case batchmsg.FieldTotal:
  5193. return m.AddedTotal()
  5194. case batchmsg.FieldSuccess:
  5195. return m.AddedSuccess()
  5196. case batchmsg.FieldFail:
  5197. return m.AddedFail()
  5198. case batchmsg.FieldType:
  5199. return m.AddedType()
  5200. case batchmsg.FieldOrganizationID:
  5201. return m.AddedOrganizationID()
  5202. }
  5203. return nil, false
  5204. }
  5205. // AddField adds the value to the field with the given name. It returns an error if
  5206. // the field is not defined in the schema, or if the type mismatched the field
  5207. // type.
  5208. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5209. switch name {
  5210. case batchmsg.FieldStatus:
  5211. v, ok := value.(int8)
  5212. if !ok {
  5213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5214. }
  5215. m.AddStatus(v)
  5216. return nil
  5217. case batchmsg.FieldTotal:
  5218. v, ok := value.(int32)
  5219. if !ok {
  5220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5221. }
  5222. m.AddTotal(v)
  5223. return nil
  5224. case batchmsg.FieldSuccess:
  5225. v, ok := value.(int32)
  5226. if !ok {
  5227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5228. }
  5229. m.AddSuccess(v)
  5230. return nil
  5231. case batchmsg.FieldFail:
  5232. v, ok := value.(int32)
  5233. if !ok {
  5234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5235. }
  5236. m.AddFail(v)
  5237. return nil
  5238. case batchmsg.FieldType:
  5239. v, ok := value.(int32)
  5240. if !ok {
  5241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5242. }
  5243. m.AddType(v)
  5244. return nil
  5245. case batchmsg.FieldOrganizationID:
  5246. v, ok := value.(int64)
  5247. if !ok {
  5248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5249. }
  5250. m.AddOrganizationID(v)
  5251. return nil
  5252. }
  5253. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5254. }
  5255. // ClearedFields returns all nullable fields that were cleared during this
  5256. // mutation.
  5257. func (m *BatchMsgMutation) ClearedFields() []string {
  5258. var fields []string
  5259. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5260. fields = append(fields, batchmsg.FieldDeletedAt)
  5261. }
  5262. if m.FieldCleared(batchmsg.FieldStatus) {
  5263. fields = append(fields, batchmsg.FieldStatus)
  5264. }
  5265. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5266. fields = append(fields, batchmsg.FieldBatchNo)
  5267. }
  5268. if m.FieldCleared(batchmsg.FieldTaskName) {
  5269. fields = append(fields, batchmsg.FieldTaskName)
  5270. }
  5271. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5272. fields = append(fields, batchmsg.FieldFromwxid)
  5273. }
  5274. if m.FieldCleared(batchmsg.FieldMsg) {
  5275. fields = append(fields, batchmsg.FieldMsg)
  5276. }
  5277. if m.FieldCleared(batchmsg.FieldTag) {
  5278. fields = append(fields, batchmsg.FieldTag)
  5279. }
  5280. if m.FieldCleared(batchmsg.FieldTagids) {
  5281. fields = append(fields, batchmsg.FieldTagids)
  5282. }
  5283. if m.FieldCleared(batchmsg.FieldTotal) {
  5284. fields = append(fields, batchmsg.FieldTotal)
  5285. }
  5286. if m.FieldCleared(batchmsg.FieldSuccess) {
  5287. fields = append(fields, batchmsg.FieldSuccess)
  5288. }
  5289. if m.FieldCleared(batchmsg.FieldFail) {
  5290. fields = append(fields, batchmsg.FieldFail)
  5291. }
  5292. if m.FieldCleared(batchmsg.FieldStartTime) {
  5293. fields = append(fields, batchmsg.FieldStartTime)
  5294. }
  5295. if m.FieldCleared(batchmsg.FieldStopTime) {
  5296. fields = append(fields, batchmsg.FieldStopTime)
  5297. }
  5298. if m.FieldCleared(batchmsg.FieldSendTime) {
  5299. fields = append(fields, batchmsg.FieldSendTime)
  5300. }
  5301. if m.FieldCleared(batchmsg.FieldType) {
  5302. fields = append(fields, batchmsg.FieldType)
  5303. }
  5304. return fields
  5305. }
  5306. // FieldCleared returns a boolean indicating if a field with the given name was
  5307. // cleared in this mutation.
  5308. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5309. _, ok := m.clearedFields[name]
  5310. return ok
  5311. }
  5312. // ClearField clears the value of the field with the given name. It returns an
  5313. // error if the field is not defined in the schema.
  5314. func (m *BatchMsgMutation) ClearField(name string) error {
  5315. switch name {
  5316. case batchmsg.FieldDeletedAt:
  5317. m.ClearDeletedAt()
  5318. return nil
  5319. case batchmsg.FieldStatus:
  5320. m.ClearStatus()
  5321. return nil
  5322. case batchmsg.FieldBatchNo:
  5323. m.ClearBatchNo()
  5324. return nil
  5325. case batchmsg.FieldTaskName:
  5326. m.ClearTaskName()
  5327. return nil
  5328. case batchmsg.FieldFromwxid:
  5329. m.ClearFromwxid()
  5330. return nil
  5331. case batchmsg.FieldMsg:
  5332. m.ClearMsg()
  5333. return nil
  5334. case batchmsg.FieldTag:
  5335. m.ClearTag()
  5336. return nil
  5337. case batchmsg.FieldTagids:
  5338. m.ClearTagids()
  5339. return nil
  5340. case batchmsg.FieldTotal:
  5341. m.ClearTotal()
  5342. return nil
  5343. case batchmsg.FieldSuccess:
  5344. m.ClearSuccess()
  5345. return nil
  5346. case batchmsg.FieldFail:
  5347. m.ClearFail()
  5348. return nil
  5349. case batchmsg.FieldStartTime:
  5350. m.ClearStartTime()
  5351. return nil
  5352. case batchmsg.FieldStopTime:
  5353. m.ClearStopTime()
  5354. return nil
  5355. case batchmsg.FieldSendTime:
  5356. m.ClearSendTime()
  5357. return nil
  5358. case batchmsg.FieldType:
  5359. m.ClearType()
  5360. return nil
  5361. }
  5362. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5363. }
  5364. // ResetField resets all changes in the mutation for the field with the given name.
  5365. // It returns an error if the field is not defined in the schema.
  5366. func (m *BatchMsgMutation) ResetField(name string) error {
  5367. switch name {
  5368. case batchmsg.FieldCreatedAt:
  5369. m.ResetCreatedAt()
  5370. return nil
  5371. case batchmsg.FieldUpdatedAt:
  5372. m.ResetUpdatedAt()
  5373. return nil
  5374. case batchmsg.FieldDeletedAt:
  5375. m.ResetDeletedAt()
  5376. return nil
  5377. case batchmsg.FieldStatus:
  5378. m.ResetStatus()
  5379. return nil
  5380. case batchmsg.FieldBatchNo:
  5381. m.ResetBatchNo()
  5382. return nil
  5383. case batchmsg.FieldTaskName:
  5384. m.ResetTaskName()
  5385. return nil
  5386. case batchmsg.FieldFromwxid:
  5387. m.ResetFromwxid()
  5388. return nil
  5389. case batchmsg.FieldMsg:
  5390. m.ResetMsg()
  5391. return nil
  5392. case batchmsg.FieldTag:
  5393. m.ResetTag()
  5394. return nil
  5395. case batchmsg.FieldTagids:
  5396. m.ResetTagids()
  5397. return nil
  5398. case batchmsg.FieldTotal:
  5399. m.ResetTotal()
  5400. return nil
  5401. case batchmsg.FieldSuccess:
  5402. m.ResetSuccess()
  5403. return nil
  5404. case batchmsg.FieldFail:
  5405. m.ResetFail()
  5406. return nil
  5407. case batchmsg.FieldStartTime:
  5408. m.ResetStartTime()
  5409. return nil
  5410. case batchmsg.FieldStopTime:
  5411. m.ResetStopTime()
  5412. return nil
  5413. case batchmsg.FieldSendTime:
  5414. m.ResetSendTime()
  5415. return nil
  5416. case batchmsg.FieldType:
  5417. m.ResetType()
  5418. return nil
  5419. case batchmsg.FieldOrganizationID:
  5420. m.ResetOrganizationID()
  5421. return nil
  5422. }
  5423. return fmt.Errorf("unknown BatchMsg field %s", name)
  5424. }
  5425. // AddedEdges returns all edge names that were set/added in this mutation.
  5426. func (m *BatchMsgMutation) AddedEdges() []string {
  5427. edges := make([]string, 0, 0)
  5428. return edges
  5429. }
  5430. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5431. // name in this mutation.
  5432. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5433. return nil
  5434. }
  5435. // RemovedEdges returns all edge names that were removed in this mutation.
  5436. func (m *BatchMsgMutation) RemovedEdges() []string {
  5437. edges := make([]string, 0, 0)
  5438. return edges
  5439. }
  5440. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5441. // the given name in this mutation.
  5442. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5443. return nil
  5444. }
  5445. // ClearedEdges returns all edge names that were cleared in this mutation.
  5446. func (m *BatchMsgMutation) ClearedEdges() []string {
  5447. edges := make([]string, 0, 0)
  5448. return edges
  5449. }
  5450. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5451. // was cleared in this mutation.
  5452. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5453. return false
  5454. }
  5455. // ClearEdge clears the value of the edge with the given name. It returns an error
  5456. // if that edge is not defined in the schema.
  5457. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5458. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5459. }
  5460. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5461. // It returns an error if the edge is not defined in the schema.
  5462. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5463. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5464. }
  5465. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5466. type CategoryMutation struct {
  5467. config
  5468. op Op
  5469. typ string
  5470. id *uint64
  5471. created_at *time.Time
  5472. updated_at *time.Time
  5473. deleted_at *time.Time
  5474. name *string
  5475. organization_id *uint64
  5476. addorganization_id *int64
  5477. clearedFields map[string]struct{}
  5478. done bool
  5479. oldValue func(context.Context) (*Category, error)
  5480. predicates []predicate.Category
  5481. }
  5482. var _ ent.Mutation = (*CategoryMutation)(nil)
  5483. // categoryOption allows management of the mutation configuration using functional options.
  5484. type categoryOption func(*CategoryMutation)
  5485. // newCategoryMutation creates new mutation for the Category entity.
  5486. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5487. m := &CategoryMutation{
  5488. config: c,
  5489. op: op,
  5490. typ: TypeCategory,
  5491. clearedFields: make(map[string]struct{}),
  5492. }
  5493. for _, opt := range opts {
  5494. opt(m)
  5495. }
  5496. return m
  5497. }
  5498. // withCategoryID sets the ID field of the mutation.
  5499. func withCategoryID(id uint64) categoryOption {
  5500. return func(m *CategoryMutation) {
  5501. var (
  5502. err error
  5503. once sync.Once
  5504. value *Category
  5505. )
  5506. m.oldValue = func(ctx context.Context) (*Category, error) {
  5507. once.Do(func() {
  5508. if m.done {
  5509. err = errors.New("querying old values post mutation is not allowed")
  5510. } else {
  5511. value, err = m.Client().Category.Get(ctx, id)
  5512. }
  5513. })
  5514. return value, err
  5515. }
  5516. m.id = &id
  5517. }
  5518. }
  5519. // withCategory sets the old Category of the mutation.
  5520. func withCategory(node *Category) categoryOption {
  5521. return func(m *CategoryMutation) {
  5522. m.oldValue = func(context.Context) (*Category, error) {
  5523. return node, nil
  5524. }
  5525. m.id = &node.ID
  5526. }
  5527. }
  5528. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5529. // executed in a transaction (ent.Tx), a transactional client is returned.
  5530. func (m CategoryMutation) Client() *Client {
  5531. client := &Client{config: m.config}
  5532. client.init()
  5533. return client
  5534. }
  5535. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5536. // it returns an error otherwise.
  5537. func (m CategoryMutation) Tx() (*Tx, error) {
  5538. if _, ok := m.driver.(*txDriver); !ok {
  5539. return nil, errors.New("ent: mutation is not running in a transaction")
  5540. }
  5541. tx := &Tx{config: m.config}
  5542. tx.init()
  5543. return tx, nil
  5544. }
  5545. // SetID sets the value of the id field. Note that this
  5546. // operation is only accepted on creation of Category entities.
  5547. func (m *CategoryMutation) SetID(id uint64) {
  5548. m.id = &id
  5549. }
  5550. // ID returns the ID value in the mutation. Note that the ID is only available
  5551. // if it was provided to the builder or after it was returned from the database.
  5552. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5553. if m.id == nil {
  5554. return
  5555. }
  5556. return *m.id, true
  5557. }
  5558. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5559. // That means, if the mutation is applied within a transaction with an isolation level such
  5560. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5561. // or updated by the mutation.
  5562. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5563. switch {
  5564. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5565. id, exists := m.ID()
  5566. if exists {
  5567. return []uint64{id}, nil
  5568. }
  5569. fallthrough
  5570. case m.op.Is(OpUpdate | OpDelete):
  5571. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5572. default:
  5573. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5574. }
  5575. }
  5576. // SetCreatedAt sets the "created_at" field.
  5577. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5578. m.created_at = &t
  5579. }
  5580. // CreatedAt returns the value of the "created_at" field in the mutation.
  5581. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5582. v := m.created_at
  5583. if v == nil {
  5584. return
  5585. }
  5586. return *v, true
  5587. }
  5588. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5589. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5591. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5592. if !m.op.Is(OpUpdateOne) {
  5593. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5594. }
  5595. if m.id == nil || m.oldValue == nil {
  5596. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5597. }
  5598. oldValue, err := m.oldValue(ctx)
  5599. if err != nil {
  5600. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5601. }
  5602. return oldValue.CreatedAt, nil
  5603. }
  5604. // ResetCreatedAt resets all changes to the "created_at" field.
  5605. func (m *CategoryMutation) ResetCreatedAt() {
  5606. m.created_at = nil
  5607. }
  5608. // SetUpdatedAt sets the "updated_at" field.
  5609. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5610. m.updated_at = &t
  5611. }
  5612. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5613. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5614. v := m.updated_at
  5615. if v == nil {
  5616. return
  5617. }
  5618. return *v, true
  5619. }
  5620. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5621. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5623. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5624. if !m.op.Is(OpUpdateOne) {
  5625. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5626. }
  5627. if m.id == nil || m.oldValue == nil {
  5628. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5629. }
  5630. oldValue, err := m.oldValue(ctx)
  5631. if err != nil {
  5632. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5633. }
  5634. return oldValue.UpdatedAt, nil
  5635. }
  5636. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5637. func (m *CategoryMutation) ResetUpdatedAt() {
  5638. m.updated_at = nil
  5639. }
  5640. // SetDeletedAt sets the "deleted_at" field.
  5641. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5642. m.deleted_at = &t
  5643. }
  5644. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5645. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5646. v := m.deleted_at
  5647. if v == nil {
  5648. return
  5649. }
  5650. return *v, true
  5651. }
  5652. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5653. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5655. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5656. if !m.op.Is(OpUpdateOne) {
  5657. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5658. }
  5659. if m.id == nil || m.oldValue == nil {
  5660. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5661. }
  5662. oldValue, err := m.oldValue(ctx)
  5663. if err != nil {
  5664. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5665. }
  5666. return oldValue.DeletedAt, nil
  5667. }
  5668. // ClearDeletedAt clears the value of the "deleted_at" field.
  5669. func (m *CategoryMutation) ClearDeletedAt() {
  5670. m.deleted_at = nil
  5671. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5672. }
  5673. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5674. func (m *CategoryMutation) DeletedAtCleared() bool {
  5675. _, ok := m.clearedFields[category.FieldDeletedAt]
  5676. return ok
  5677. }
  5678. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5679. func (m *CategoryMutation) ResetDeletedAt() {
  5680. m.deleted_at = nil
  5681. delete(m.clearedFields, category.FieldDeletedAt)
  5682. }
  5683. // SetName sets the "name" field.
  5684. func (m *CategoryMutation) SetName(s string) {
  5685. m.name = &s
  5686. }
  5687. // Name returns the value of the "name" field in the mutation.
  5688. func (m *CategoryMutation) Name() (r string, exists bool) {
  5689. v := m.name
  5690. if v == nil {
  5691. return
  5692. }
  5693. return *v, true
  5694. }
  5695. // OldName returns the old "name" field's value of the Category entity.
  5696. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5698. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5699. if !m.op.Is(OpUpdateOne) {
  5700. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5701. }
  5702. if m.id == nil || m.oldValue == nil {
  5703. return v, errors.New("OldName requires an ID field in the mutation")
  5704. }
  5705. oldValue, err := m.oldValue(ctx)
  5706. if err != nil {
  5707. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5708. }
  5709. return oldValue.Name, nil
  5710. }
  5711. // ResetName resets all changes to the "name" field.
  5712. func (m *CategoryMutation) ResetName() {
  5713. m.name = nil
  5714. }
  5715. // SetOrganizationID sets the "organization_id" field.
  5716. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5717. m.organization_id = &u
  5718. m.addorganization_id = nil
  5719. }
  5720. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5721. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5722. v := m.organization_id
  5723. if v == nil {
  5724. return
  5725. }
  5726. return *v, true
  5727. }
  5728. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5729. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5731. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5732. if !m.op.Is(OpUpdateOne) {
  5733. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5734. }
  5735. if m.id == nil || m.oldValue == nil {
  5736. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5737. }
  5738. oldValue, err := m.oldValue(ctx)
  5739. if err != nil {
  5740. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5741. }
  5742. return oldValue.OrganizationID, nil
  5743. }
  5744. // AddOrganizationID adds u to the "organization_id" field.
  5745. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5746. if m.addorganization_id != nil {
  5747. *m.addorganization_id += u
  5748. } else {
  5749. m.addorganization_id = &u
  5750. }
  5751. }
  5752. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5753. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5754. v := m.addorganization_id
  5755. if v == nil {
  5756. return
  5757. }
  5758. return *v, true
  5759. }
  5760. // ResetOrganizationID resets all changes to the "organization_id" field.
  5761. func (m *CategoryMutation) ResetOrganizationID() {
  5762. m.organization_id = nil
  5763. m.addorganization_id = nil
  5764. }
  5765. // Where appends a list predicates to the CategoryMutation builder.
  5766. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5767. m.predicates = append(m.predicates, ps...)
  5768. }
  5769. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5770. // users can use type-assertion to append predicates that do not depend on any generated package.
  5771. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5772. p := make([]predicate.Category, len(ps))
  5773. for i := range ps {
  5774. p[i] = ps[i]
  5775. }
  5776. m.Where(p...)
  5777. }
  5778. // Op returns the operation name.
  5779. func (m *CategoryMutation) Op() Op {
  5780. return m.op
  5781. }
  5782. // SetOp allows setting the mutation operation.
  5783. func (m *CategoryMutation) SetOp(op Op) {
  5784. m.op = op
  5785. }
  5786. // Type returns the node type of this mutation (Category).
  5787. func (m *CategoryMutation) Type() string {
  5788. return m.typ
  5789. }
  5790. // Fields returns all fields that were changed during this mutation. Note that in
  5791. // order to get all numeric fields that were incremented/decremented, call
  5792. // AddedFields().
  5793. func (m *CategoryMutation) Fields() []string {
  5794. fields := make([]string, 0, 5)
  5795. if m.created_at != nil {
  5796. fields = append(fields, category.FieldCreatedAt)
  5797. }
  5798. if m.updated_at != nil {
  5799. fields = append(fields, category.FieldUpdatedAt)
  5800. }
  5801. if m.deleted_at != nil {
  5802. fields = append(fields, category.FieldDeletedAt)
  5803. }
  5804. if m.name != nil {
  5805. fields = append(fields, category.FieldName)
  5806. }
  5807. if m.organization_id != nil {
  5808. fields = append(fields, category.FieldOrganizationID)
  5809. }
  5810. return fields
  5811. }
  5812. // Field returns the value of a field with the given name. The second boolean
  5813. // return value indicates that this field was not set, or was not defined in the
  5814. // schema.
  5815. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5816. switch name {
  5817. case category.FieldCreatedAt:
  5818. return m.CreatedAt()
  5819. case category.FieldUpdatedAt:
  5820. return m.UpdatedAt()
  5821. case category.FieldDeletedAt:
  5822. return m.DeletedAt()
  5823. case category.FieldName:
  5824. return m.Name()
  5825. case category.FieldOrganizationID:
  5826. return m.OrganizationID()
  5827. }
  5828. return nil, false
  5829. }
  5830. // OldField returns the old value of the field from the database. An error is
  5831. // returned if the mutation operation is not UpdateOne, or the query to the
  5832. // database failed.
  5833. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5834. switch name {
  5835. case category.FieldCreatedAt:
  5836. return m.OldCreatedAt(ctx)
  5837. case category.FieldUpdatedAt:
  5838. return m.OldUpdatedAt(ctx)
  5839. case category.FieldDeletedAt:
  5840. return m.OldDeletedAt(ctx)
  5841. case category.FieldName:
  5842. return m.OldName(ctx)
  5843. case category.FieldOrganizationID:
  5844. return m.OldOrganizationID(ctx)
  5845. }
  5846. return nil, fmt.Errorf("unknown Category field %s", name)
  5847. }
  5848. // SetField sets the value of a field with the given name. It returns an error if
  5849. // the field is not defined in the schema, or if the type mismatched the field
  5850. // type.
  5851. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5852. switch name {
  5853. case category.FieldCreatedAt:
  5854. v, ok := value.(time.Time)
  5855. if !ok {
  5856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5857. }
  5858. m.SetCreatedAt(v)
  5859. return nil
  5860. case category.FieldUpdatedAt:
  5861. v, ok := value.(time.Time)
  5862. if !ok {
  5863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5864. }
  5865. m.SetUpdatedAt(v)
  5866. return nil
  5867. case category.FieldDeletedAt:
  5868. v, ok := value.(time.Time)
  5869. if !ok {
  5870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5871. }
  5872. m.SetDeletedAt(v)
  5873. return nil
  5874. case category.FieldName:
  5875. v, ok := value.(string)
  5876. if !ok {
  5877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5878. }
  5879. m.SetName(v)
  5880. return nil
  5881. case category.FieldOrganizationID:
  5882. v, ok := value.(uint64)
  5883. if !ok {
  5884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5885. }
  5886. m.SetOrganizationID(v)
  5887. return nil
  5888. }
  5889. return fmt.Errorf("unknown Category field %s", name)
  5890. }
  5891. // AddedFields returns all numeric fields that were incremented/decremented during
  5892. // this mutation.
  5893. func (m *CategoryMutation) AddedFields() []string {
  5894. var fields []string
  5895. if m.addorganization_id != nil {
  5896. fields = append(fields, category.FieldOrganizationID)
  5897. }
  5898. return fields
  5899. }
  5900. // AddedField returns the numeric value that was incremented/decremented on a field
  5901. // with the given name. The second boolean return value indicates that this field
  5902. // was not set, or was not defined in the schema.
  5903. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5904. switch name {
  5905. case category.FieldOrganizationID:
  5906. return m.AddedOrganizationID()
  5907. }
  5908. return nil, false
  5909. }
  5910. // AddField adds the value to the field with the given name. It returns an error if
  5911. // the field is not defined in the schema, or if the type mismatched the field
  5912. // type.
  5913. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5914. switch name {
  5915. case category.FieldOrganizationID:
  5916. v, ok := value.(int64)
  5917. if !ok {
  5918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5919. }
  5920. m.AddOrganizationID(v)
  5921. return nil
  5922. }
  5923. return fmt.Errorf("unknown Category numeric field %s", name)
  5924. }
  5925. // ClearedFields returns all nullable fields that were cleared during this
  5926. // mutation.
  5927. func (m *CategoryMutation) ClearedFields() []string {
  5928. var fields []string
  5929. if m.FieldCleared(category.FieldDeletedAt) {
  5930. fields = append(fields, category.FieldDeletedAt)
  5931. }
  5932. return fields
  5933. }
  5934. // FieldCleared returns a boolean indicating if a field with the given name was
  5935. // cleared in this mutation.
  5936. func (m *CategoryMutation) FieldCleared(name string) bool {
  5937. _, ok := m.clearedFields[name]
  5938. return ok
  5939. }
  5940. // ClearField clears the value of the field with the given name. It returns an
  5941. // error if the field is not defined in the schema.
  5942. func (m *CategoryMutation) ClearField(name string) error {
  5943. switch name {
  5944. case category.FieldDeletedAt:
  5945. m.ClearDeletedAt()
  5946. return nil
  5947. }
  5948. return fmt.Errorf("unknown Category nullable field %s", name)
  5949. }
  5950. // ResetField resets all changes in the mutation for the field with the given name.
  5951. // It returns an error if the field is not defined in the schema.
  5952. func (m *CategoryMutation) ResetField(name string) error {
  5953. switch name {
  5954. case category.FieldCreatedAt:
  5955. m.ResetCreatedAt()
  5956. return nil
  5957. case category.FieldUpdatedAt:
  5958. m.ResetUpdatedAt()
  5959. return nil
  5960. case category.FieldDeletedAt:
  5961. m.ResetDeletedAt()
  5962. return nil
  5963. case category.FieldName:
  5964. m.ResetName()
  5965. return nil
  5966. case category.FieldOrganizationID:
  5967. m.ResetOrganizationID()
  5968. return nil
  5969. }
  5970. return fmt.Errorf("unknown Category field %s", name)
  5971. }
  5972. // AddedEdges returns all edge names that were set/added in this mutation.
  5973. func (m *CategoryMutation) AddedEdges() []string {
  5974. edges := make([]string, 0, 0)
  5975. return edges
  5976. }
  5977. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5978. // name in this mutation.
  5979. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5980. return nil
  5981. }
  5982. // RemovedEdges returns all edge names that were removed in this mutation.
  5983. func (m *CategoryMutation) RemovedEdges() []string {
  5984. edges := make([]string, 0, 0)
  5985. return edges
  5986. }
  5987. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5988. // the given name in this mutation.
  5989. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5990. return nil
  5991. }
  5992. // ClearedEdges returns all edge names that were cleared in this mutation.
  5993. func (m *CategoryMutation) ClearedEdges() []string {
  5994. edges := make([]string, 0, 0)
  5995. return edges
  5996. }
  5997. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5998. // was cleared in this mutation.
  5999. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6000. return false
  6001. }
  6002. // ClearEdge clears the value of the edge with the given name. It returns an error
  6003. // if that edge is not defined in the schema.
  6004. func (m *CategoryMutation) ClearEdge(name string) error {
  6005. return fmt.Errorf("unknown Category unique edge %s", name)
  6006. }
  6007. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6008. // It returns an error if the edge is not defined in the schema.
  6009. func (m *CategoryMutation) ResetEdge(name string) error {
  6010. return fmt.Errorf("unknown Category edge %s", name)
  6011. }
  6012. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6013. type ChatRecordsMutation struct {
  6014. config
  6015. op Op
  6016. typ string
  6017. id *uint64
  6018. created_at *time.Time
  6019. updated_at *time.Time
  6020. deleted_at *time.Time
  6021. content *string
  6022. content_type *uint8
  6023. addcontent_type *int8
  6024. session_id *uint64
  6025. addsession_id *int64
  6026. user_id *uint64
  6027. adduser_id *int64
  6028. bot_id *uint64
  6029. addbot_id *int64
  6030. bot_type *uint8
  6031. addbot_type *int8
  6032. clearedFields map[string]struct{}
  6033. done bool
  6034. oldValue func(context.Context) (*ChatRecords, error)
  6035. predicates []predicate.ChatRecords
  6036. }
  6037. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6038. // chatrecordsOption allows management of the mutation configuration using functional options.
  6039. type chatrecordsOption func(*ChatRecordsMutation)
  6040. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6041. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6042. m := &ChatRecordsMutation{
  6043. config: c,
  6044. op: op,
  6045. typ: TypeChatRecords,
  6046. clearedFields: make(map[string]struct{}),
  6047. }
  6048. for _, opt := range opts {
  6049. opt(m)
  6050. }
  6051. return m
  6052. }
  6053. // withChatRecordsID sets the ID field of the mutation.
  6054. func withChatRecordsID(id uint64) chatrecordsOption {
  6055. return func(m *ChatRecordsMutation) {
  6056. var (
  6057. err error
  6058. once sync.Once
  6059. value *ChatRecords
  6060. )
  6061. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6062. once.Do(func() {
  6063. if m.done {
  6064. err = errors.New("querying old values post mutation is not allowed")
  6065. } else {
  6066. value, err = m.Client().ChatRecords.Get(ctx, id)
  6067. }
  6068. })
  6069. return value, err
  6070. }
  6071. m.id = &id
  6072. }
  6073. }
  6074. // withChatRecords sets the old ChatRecords of the mutation.
  6075. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6076. return func(m *ChatRecordsMutation) {
  6077. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6078. return node, nil
  6079. }
  6080. m.id = &node.ID
  6081. }
  6082. }
  6083. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6084. // executed in a transaction (ent.Tx), a transactional client is returned.
  6085. func (m ChatRecordsMutation) Client() *Client {
  6086. client := &Client{config: m.config}
  6087. client.init()
  6088. return client
  6089. }
  6090. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6091. // it returns an error otherwise.
  6092. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6093. if _, ok := m.driver.(*txDriver); !ok {
  6094. return nil, errors.New("ent: mutation is not running in a transaction")
  6095. }
  6096. tx := &Tx{config: m.config}
  6097. tx.init()
  6098. return tx, nil
  6099. }
  6100. // SetID sets the value of the id field. Note that this
  6101. // operation is only accepted on creation of ChatRecords entities.
  6102. func (m *ChatRecordsMutation) SetID(id uint64) {
  6103. m.id = &id
  6104. }
  6105. // ID returns the ID value in the mutation. Note that the ID is only available
  6106. // if it was provided to the builder or after it was returned from the database.
  6107. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6108. if m.id == nil {
  6109. return
  6110. }
  6111. return *m.id, true
  6112. }
  6113. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6114. // That means, if the mutation is applied within a transaction with an isolation level such
  6115. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6116. // or updated by the mutation.
  6117. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6118. switch {
  6119. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6120. id, exists := m.ID()
  6121. if exists {
  6122. return []uint64{id}, nil
  6123. }
  6124. fallthrough
  6125. case m.op.Is(OpUpdate | OpDelete):
  6126. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6127. default:
  6128. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6129. }
  6130. }
  6131. // SetCreatedAt sets the "created_at" field.
  6132. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6133. m.created_at = &t
  6134. }
  6135. // CreatedAt returns the value of the "created_at" field in the mutation.
  6136. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6137. v := m.created_at
  6138. if v == nil {
  6139. return
  6140. }
  6141. return *v, true
  6142. }
  6143. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6144. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6146. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6147. if !m.op.Is(OpUpdateOne) {
  6148. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6149. }
  6150. if m.id == nil || m.oldValue == nil {
  6151. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6152. }
  6153. oldValue, err := m.oldValue(ctx)
  6154. if err != nil {
  6155. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6156. }
  6157. return oldValue.CreatedAt, nil
  6158. }
  6159. // ResetCreatedAt resets all changes to the "created_at" field.
  6160. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6161. m.created_at = nil
  6162. }
  6163. // SetUpdatedAt sets the "updated_at" field.
  6164. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6165. m.updated_at = &t
  6166. }
  6167. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6168. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6169. v := m.updated_at
  6170. if v == nil {
  6171. return
  6172. }
  6173. return *v, true
  6174. }
  6175. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6176. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6178. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6179. if !m.op.Is(OpUpdateOne) {
  6180. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6181. }
  6182. if m.id == nil || m.oldValue == nil {
  6183. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6184. }
  6185. oldValue, err := m.oldValue(ctx)
  6186. if err != nil {
  6187. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6188. }
  6189. return oldValue.UpdatedAt, nil
  6190. }
  6191. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6192. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6193. m.updated_at = nil
  6194. }
  6195. // SetDeletedAt sets the "deleted_at" field.
  6196. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6197. m.deleted_at = &t
  6198. }
  6199. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6200. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6201. v := m.deleted_at
  6202. if v == nil {
  6203. return
  6204. }
  6205. return *v, true
  6206. }
  6207. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6208. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6210. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6211. if !m.op.Is(OpUpdateOne) {
  6212. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6213. }
  6214. if m.id == nil || m.oldValue == nil {
  6215. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6216. }
  6217. oldValue, err := m.oldValue(ctx)
  6218. if err != nil {
  6219. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6220. }
  6221. return oldValue.DeletedAt, nil
  6222. }
  6223. // ClearDeletedAt clears the value of the "deleted_at" field.
  6224. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6225. m.deleted_at = nil
  6226. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6227. }
  6228. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6229. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6230. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6231. return ok
  6232. }
  6233. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6234. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6235. m.deleted_at = nil
  6236. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6237. }
  6238. // SetContent sets the "content" field.
  6239. func (m *ChatRecordsMutation) SetContent(s string) {
  6240. m.content = &s
  6241. }
  6242. // Content returns the value of the "content" field in the mutation.
  6243. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6244. v := m.content
  6245. if v == nil {
  6246. return
  6247. }
  6248. return *v, true
  6249. }
  6250. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6251. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6253. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6254. if !m.op.Is(OpUpdateOne) {
  6255. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6256. }
  6257. if m.id == nil || m.oldValue == nil {
  6258. return v, errors.New("OldContent requires an ID field in the mutation")
  6259. }
  6260. oldValue, err := m.oldValue(ctx)
  6261. if err != nil {
  6262. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6263. }
  6264. return oldValue.Content, nil
  6265. }
  6266. // ResetContent resets all changes to the "content" field.
  6267. func (m *ChatRecordsMutation) ResetContent() {
  6268. m.content = nil
  6269. }
  6270. // SetContentType sets the "content_type" field.
  6271. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6272. m.content_type = &u
  6273. m.addcontent_type = nil
  6274. }
  6275. // ContentType returns the value of the "content_type" field in the mutation.
  6276. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6277. v := m.content_type
  6278. if v == nil {
  6279. return
  6280. }
  6281. return *v, true
  6282. }
  6283. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6284. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6286. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6287. if !m.op.Is(OpUpdateOne) {
  6288. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6289. }
  6290. if m.id == nil || m.oldValue == nil {
  6291. return v, errors.New("OldContentType requires an ID field in the mutation")
  6292. }
  6293. oldValue, err := m.oldValue(ctx)
  6294. if err != nil {
  6295. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6296. }
  6297. return oldValue.ContentType, nil
  6298. }
  6299. // AddContentType adds u to the "content_type" field.
  6300. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6301. if m.addcontent_type != nil {
  6302. *m.addcontent_type += u
  6303. } else {
  6304. m.addcontent_type = &u
  6305. }
  6306. }
  6307. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6308. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6309. v := m.addcontent_type
  6310. if v == nil {
  6311. return
  6312. }
  6313. return *v, true
  6314. }
  6315. // ResetContentType resets all changes to the "content_type" field.
  6316. func (m *ChatRecordsMutation) ResetContentType() {
  6317. m.content_type = nil
  6318. m.addcontent_type = nil
  6319. }
  6320. // SetSessionID sets the "session_id" field.
  6321. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6322. m.session_id = &u
  6323. m.addsession_id = nil
  6324. }
  6325. // SessionID returns the value of the "session_id" field in the mutation.
  6326. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6327. v := m.session_id
  6328. if v == nil {
  6329. return
  6330. }
  6331. return *v, true
  6332. }
  6333. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6334. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6336. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6337. if !m.op.Is(OpUpdateOne) {
  6338. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6339. }
  6340. if m.id == nil || m.oldValue == nil {
  6341. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6342. }
  6343. oldValue, err := m.oldValue(ctx)
  6344. if err != nil {
  6345. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6346. }
  6347. return oldValue.SessionID, nil
  6348. }
  6349. // AddSessionID adds u to the "session_id" field.
  6350. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6351. if m.addsession_id != nil {
  6352. *m.addsession_id += u
  6353. } else {
  6354. m.addsession_id = &u
  6355. }
  6356. }
  6357. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6358. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6359. v := m.addsession_id
  6360. if v == nil {
  6361. return
  6362. }
  6363. return *v, true
  6364. }
  6365. // ResetSessionID resets all changes to the "session_id" field.
  6366. func (m *ChatRecordsMutation) ResetSessionID() {
  6367. m.session_id = nil
  6368. m.addsession_id = nil
  6369. }
  6370. // SetUserID sets the "user_id" field.
  6371. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6372. m.user_id = &u
  6373. m.adduser_id = nil
  6374. }
  6375. // UserID returns the value of the "user_id" field in the mutation.
  6376. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6377. v := m.user_id
  6378. if v == nil {
  6379. return
  6380. }
  6381. return *v, true
  6382. }
  6383. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6384. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6386. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6387. if !m.op.Is(OpUpdateOne) {
  6388. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6389. }
  6390. if m.id == nil || m.oldValue == nil {
  6391. return v, errors.New("OldUserID requires an ID field in the mutation")
  6392. }
  6393. oldValue, err := m.oldValue(ctx)
  6394. if err != nil {
  6395. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6396. }
  6397. return oldValue.UserID, nil
  6398. }
  6399. // AddUserID adds u to the "user_id" field.
  6400. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6401. if m.adduser_id != nil {
  6402. *m.adduser_id += u
  6403. } else {
  6404. m.adduser_id = &u
  6405. }
  6406. }
  6407. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6408. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6409. v := m.adduser_id
  6410. if v == nil {
  6411. return
  6412. }
  6413. return *v, true
  6414. }
  6415. // ResetUserID resets all changes to the "user_id" field.
  6416. func (m *ChatRecordsMutation) ResetUserID() {
  6417. m.user_id = nil
  6418. m.adduser_id = nil
  6419. }
  6420. // SetBotID sets the "bot_id" field.
  6421. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6422. m.bot_id = &u
  6423. m.addbot_id = nil
  6424. }
  6425. // BotID returns the value of the "bot_id" field in the mutation.
  6426. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6427. v := m.bot_id
  6428. if v == nil {
  6429. return
  6430. }
  6431. return *v, true
  6432. }
  6433. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6434. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6436. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6437. if !m.op.Is(OpUpdateOne) {
  6438. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6439. }
  6440. if m.id == nil || m.oldValue == nil {
  6441. return v, errors.New("OldBotID requires an ID field in the mutation")
  6442. }
  6443. oldValue, err := m.oldValue(ctx)
  6444. if err != nil {
  6445. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6446. }
  6447. return oldValue.BotID, nil
  6448. }
  6449. // AddBotID adds u to the "bot_id" field.
  6450. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6451. if m.addbot_id != nil {
  6452. *m.addbot_id += u
  6453. } else {
  6454. m.addbot_id = &u
  6455. }
  6456. }
  6457. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6458. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6459. v := m.addbot_id
  6460. if v == nil {
  6461. return
  6462. }
  6463. return *v, true
  6464. }
  6465. // ResetBotID resets all changes to the "bot_id" field.
  6466. func (m *ChatRecordsMutation) ResetBotID() {
  6467. m.bot_id = nil
  6468. m.addbot_id = nil
  6469. }
  6470. // SetBotType sets the "bot_type" field.
  6471. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6472. m.bot_type = &u
  6473. m.addbot_type = nil
  6474. }
  6475. // BotType returns the value of the "bot_type" field in the mutation.
  6476. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6477. v := m.bot_type
  6478. if v == nil {
  6479. return
  6480. }
  6481. return *v, true
  6482. }
  6483. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6484. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6486. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6487. if !m.op.Is(OpUpdateOne) {
  6488. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6489. }
  6490. if m.id == nil || m.oldValue == nil {
  6491. return v, errors.New("OldBotType requires an ID field in the mutation")
  6492. }
  6493. oldValue, err := m.oldValue(ctx)
  6494. if err != nil {
  6495. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6496. }
  6497. return oldValue.BotType, nil
  6498. }
  6499. // AddBotType adds u to the "bot_type" field.
  6500. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6501. if m.addbot_type != nil {
  6502. *m.addbot_type += u
  6503. } else {
  6504. m.addbot_type = &u
  6505. }
  6506. }
  6507. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6508. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6509. v := m.addbot_type
  6510. if v == nil {
  6511. return
  6512. }
  6513. return *v, true
  6514. }
  6515. // ResetBotType resets all changes to the "bot_type" field.
  6516. func (m *ChatRecordsMutation) ResetBotType() {
  6517. m.bot_type = nil
  6518. m.addbot_type = nil
  6519. }
  6520. // Where appends a list predicates to the ChatRecordsMutation builder.
  6521. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6522. m.predicates = append(m.predicates, ps...)
  6523. }
  6524. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6525. // users can use type-assertion to append predicates that do not depend on any generated package.
  6526. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6527. p := make([]predicate.ChatRecords, len(ps))
  6528. for i := range ps {
  6529. p[i] = ps[i]
  6530. }
  6531. m.Where(p...)
  6532. }
  6533. // Op returns the operation name.
  6534. func (m *ChatRecordsMutation) Op() Op {
  6535. return m.op
  6536. }
  6537. // SetOp allows setting the mutation operation.
  6538. func (m *ChatRecordsMutation) SetOp(op Op) {
  6539. m.op = op
  6540. }
  6541. // Type returns the node type of this mutation (ChatRecords).
  6542. func (m *ChatRecordsMutation) Type() string {
  6543. return m.typ
  6544. }
  6545. // Fields returns all fields that were changed during this mutation. Note that in
  6546. // order to get all numeric fields that were incremented/decremented, call
  6547. // AddedFields().
  6548. func (m *ChatRecordsMutation) Fields() []string {
  6549. fields := make([]string, 0, 9)
  6550. if m.created_at != nil {
  6551. fields = append(fields, chatrecords.FieldCreatedAt)
  6552. }
  6553. if m.updated_at != nil {
  6554. fields = append(fields, chatrecords.FieldUpdatedAt)
  6555. }
  6556. if m.deleted_at != nil {
  6557. fields = append(fields, chatrecords.FieldDeletedAt)
  6558. }
  6559. if m.content != nil {
  6560. fields = append(fields, chatrecords.FieldContent)
  6561. }
  6562. if m.content_type != nil {
  6563. fields = append(fields, chatrecords.FieldContentType)
  6564. }
  6565. if m.session_id != nil {
  6566. fields = append(fields, chatrecords.FieldSessionID)
  6567. }
  6568. if m.user_id != nil {
  6569. fields = append(fields, chatrecords.FieldUserID)
  6570. }
  6571. if m.bot_id != nil {
  6572. fields = append(fields, chatrecords.FieldBotID)
  6573. }
  6574. if m.bot_type != nil {
  6575. fields = append(fields, chatrecords.FieldBotType)
  6576. }
  6577. return fields
  6578. }
  6579. // Field returns the value of a field with the given name. The second boolean
  6580. // return value indicates that this field was not set, or was not defined in the
  6581. // schema.
  6582. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6583. switch name {
  6584. case chatrecords.FieldCreatedAt:
  6585. return m.CreatedAt()
  6586. case chatrecords.FieldUpdatedAt:
  6587. return m.UpdatedAt()
  6588. case chatrecords.FieldDeletedAt:
  6589. return m.DeletedAt()
  6590. case chatrecords.FieldContent:
  6591. return m.Content()
  6592. case chatrecords.FieldContentType:
  6593. return m.ContentType()
  6594. case chatrecords.FieldSessionID:
  6595. return m.SessionID()
  6596. case chatrecords.FieldUserID:
  6597. return m.UserID()
  6598. case chatrecords.FieldBotID:
  6599. return m.BotID()
  6600. case chatrecords.FieldBotType:
  6601. return m.BotType()
  6602. }
  6603. return nil, false
  6604. }
  6605. // OldField returns the old value of the field from the database. An error is
  6606. // returned if the mutation operation is not UpdateOne, or the query to the
  6607. // database failed.
  6608. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6609. switch name {
  6610. case chatrecords.FieldCreatedAt:
  6611. return m.OldCreatedAt(ctx)
  6612. case chatrecords.FieldUpdatedAt:
  6613. return m.OldUpdatedAt(ctx)
  6614. case chatrecords.FieldDeletedAt:
  6615. return m.OldDeletedAt(ctx)
  6616. case chatrecords.FieldContent:
  6617. return m.OldContent(ctx)
  6618. case chatrecords.FieldContentType:
  6619. return m.OldContentType(ctx)
  6620. case chatrecords.FieldSessionID:
  6621. return m.OldSessionID(ctx)
  6622. case chatrecords.FieldUserID:
  6623. return m.OldUserID(ctx)
  6624. case chatrecords.FieldBotID:
  6625. return m.OldBotID(ctx)
  6626. case chatrecords.FieldBotType:
  6627. return m.OldBotType(ctx)
  6628. }
  6629. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6630. }
  6631. // SetField sets the value of a field with the given name. It returns an error if
  6632. // the field is not defined in the schema, or if the type mismatched the field
  6633. // type.
  6634. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6635. switch name {
  6636. case chatrecords.FieldCreatedAt:
  6637. v, ok := value.(time.Time)
  6638. if !ok {
  6639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6640. }
  6641. m.SetCreatedAt(v)
  6642. return nil
  6643. case chatrecords.FieldUpdatedAt:
  6644. v, ok := value.(time.Time)
  6645. if !ok {
  6646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6647. }
  6648. m.SetUpdatedAt(v)
  6649. return nil
  6650. case chatrecords.FieldDeletedAt:
  6651. v, ok := value.(time.Time)
  6652. if !ok {
  6653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6654. }
  6655. m.SetDeletedAt(v)
  6656. return nil
  6657. case chatrecords.FieldContent:
  6658. v, ok := value.(string)
  6659. if !ok {
  6660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6661. }
  6662. m.SetContent(v)
  6663. return nil
  6664. case chatrecords.FieldContentType:
  6665. v, ok := value.(uint8)
  6666. if !ok {
  6667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6668. }
  6669. m.SetContentType(v)
  6670. return nil
  6671. case chatrecords.FieldSessionID:
  6672. v, ok := value.(uint64)
  6673. if !ok {
  6674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6675. }
  6676. m.SetSessionID(v)
  6677. return nil
  6678. case chatrecords.FieldUserID:
  6679. v, ok := value.(uint64)
  6680. if !ok {
  6681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6682. }
  6683. m.SetUserID(v)
  6684. return nil
  6685. case chatrecords.FieldBotID:
  6686. v, ok := value.(uint64)
  6687. if !ok {
  6688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6689. }
  6690. m.SetBotID(v)
  6691. return nil
  6692. case chatrecords.FieldBotType:
  6693. v, ok := value.(uint8)
  6694. if !ok {
  6695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6696. }
  6697. m.SetBotType(v)
  6698. return nil
  6699. }
  6700. return fmt.Errorf("unknown ChatRecords field %s", name)
  6701. }
  6702. // AddedFields returns all numeric fields that were incremented/decremented during
  6703. // this mutation.
  6704. func (m *ChatRecordsMutation) AddedFields() []string {
  6705. var fields []string
  6706. if m.addcontent_type != nil {
  6707. fields = append(fields, chatrecords.FieldContentType)
  6708. }
  6709. if m.addsession_id != nil {
  6710. fields = append(fields, chatrecords.FieldSessionID)
  6711. }
  6712. if m.adduser_id != nil {
  6713. fields = append(fields, chatrecords.FieldUserID)
  6714. }
  6715. if m.addbot_id != nil {
  6716. fields = append(fields, chatrecords.FieldBotID)
  6717. }
  6718. if m.addbot_type != nil {
  6719. fields = append(fields, chatrecords.FieldBotType)
  6720. }
  6721. return fields
  6722. }
  6723. // AddedField returns the numeric value that was incremented/decremented on a field
  6724. // with the given name. The second boolean return value indicates that this field
  6725. // was not set, or was not defined in the schema.
  6726. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6727. switch name {
  6728. case chatrecords.FieldContentType:
  6729. return m.AddedContentType()
  6730. case chatrecords.FieldSessionID:
  6731. return m.AddedSessionID()
  6732. case chatrecords.FieldUserID:
  6733. return m.AddedUserID()
  6734. case chatrecords.FieldBotID:
  6735. return m.AddedBotID()
  6736. case chatrecords.FieldBotType:
  6737. return m.AddedBotType()
  6738. }
  6739. return nil, false
  6740. }
  6741. // AddField adds the value to the field with the given name. It returns an error if
  6742. // the field is not defined in the schema, or if the type mismatched the field
  6743. // type.
  6744. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6745. switch name {
  6746. case chatrecords.FieldContentType:
  6747. v, ok := value.(int8)
  6748. if !ok {
  6749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6750. }
  6751. m.AddContentType(v)
  6752. return nil
  6753. case chatrecords.FieldSessionID:
  6754. v, ok := value.(int64)
  6755. if !ok {
  6756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6757. }
  6758. m.AddSessionID(v)
  6759. return nil
  6760. case chatrecords.FieldUserID:
  6761. v, ok := value.(int64)
  6762. if !ok {
  6763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6764. }
  6765. m.AddUserID(v)
  6766. return nil
  6767. case chatrecords.FieldBotID:
  6768. v, ok := value.(int64)
  6769. if !ok {
  6770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6771. }
  6772. m.AddBotID(v)
  6773. return nil
  6774. case chatrecords.FieldBotType:
  6775. v, ok := value.(int8)
  6776. if !ok {
  6777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6778. }
  6779. m.AddBotType(v)
  6780. return nil
  6781. }
  6782. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6783. }
  6784. // ClearedFields returns all nullable fields that were cleared during this
  6785. // mutation.
  6786. func (m *ChatRecordsMutation) ClearedFields() []string {
  6787. var fields []string
  6788. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6789. fields = append(fields, chatrecords.FieldDeletedAt)
  6790. }
  6791. return fields
  6792. }
  6793. // FieldCleared returns a boolean indicating if a field with the given name was
  6794. // cleared in this mutation.
  6795. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6796. _, ok := m.clearedFields[name]
  6797. return ok
  6798. }
  6799. // ClearField clears the value of the field with the given name. It returns an
  6800. // error if the field is not defined in the schema.
  6801. func (m *ChatRecordsMutation) ClearField(name string) error {
  6802. switch name {
  6803. case chatrecords.FieldDeletedAt:
  6804. m.ClearDeletedAt()
  6805. return nil
  6806. }
  6807. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6808. }
  6809. // ResetField resets all changes in the mutation for the field with the given name.
  6810. // It returns an error if the field is not defined in the schema.
  6811. func (m *ChatRecordsMutation) ResetField(name string) error {
  6812. switch name {
  6813. case chatrecords.FieldCreatedAt:
  6814. m.ResetCreatedAt()
  6815. return nil
  6816. case chatrecords.FieldUpdatedAt:
  6817. m.ResetUpdatedAt()
  6818. return nil
  6819. case chatrecords.FieldDeletedAt:
  6820. m.ResetDeletedAt()
  6821. return nil
  6822. case chatrecords.FieldContent:
  6823. m.ResetContent()
  6824. return nil
  6825. case chatrecords.FieldContentType:
  6826. m.ResetContentType()
  6827. return nil
  6828. case chatrecords.FieldSessionID:
  6829. m.ResetSessionID()
  6830. return nil
  6831. case chatrecords.FieldUserID:
  6832. m.ResetUserID()
  6833. return nil
  6834. case chatrecords.FieldBotID:
  6835. m.ResetBotID()
  6836. return nil
  6837. case chatrecords.FieldBotType:
  6838. m.ResetBotType()
  6839. return nil
  6840. }
  6841. return fmt.Errorf("unknown ChatRecords field %s", name)
  6842. }
  6843. // AddedEdges returns all edge names that were set/added in this mutation.
  6844. func (m *ChatRecordsMutation) AddedEdges() []string {
  6845. edges := make([]string, 0, 0)
  6846. return edges
  6847. }
  6848. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6849. // name in this mutation.
  6850. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6851. return nil
  6852. }
  6853. // RemovedEdges returns all edge names that were removed in this mutation.
  6854. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6855. edges := make([]string, 0, 0)
  6856. return edges
  6857. }
  6858. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6859. // the given name in this mutation.
  6860. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6861. return nil
  6862. }
  6863. // ClearedEdges returns all edge names that were cleared in this mutation.
  6864. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6865. edges := make([]string, 0, 0)
  6866. return edges
  6867. }
  6868. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6869. // was cleared in this mutation.
  6870. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6871. return false
  6872. }
  6873. // ClearEdge clears the value of the edge with the given name. It returns an error
  6874. // if that edge is not defined in the schema.
  6875. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6876. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6877. }
  6878. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6879. // It returns an error if the edge is not defined in the schema.
  6880. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6881. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6882. }
  6883. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6884. type ChatSessionMutation struct {
  6885. config
  6886. op Op
  6887. typ string
  6888. id *uint64
  6889. created_at *time.Time
  6890. updated_at *time.Time
  6891. deleted_at *time.Time
  6892. name *string
  6893. user_id *uint64
  6894. adduser_id *int64
  6895. bot_id *uint64
  6896. addbot_id *int64
  6897. bot_type *uint8
  6898. addbot_type *int8
  6899. clearedFields map[string]struct{}
  6900. done bool
  6901. oldValue func(context.Context) (*ChatSession, error)
  6902. predicates []predicate.ChatSession
  6903. }
  6904. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6905. // chatsessionOption allows management of the mutation configuration using functional options.
  6906. type chatsessionOption func(*ChatSessionMutation)
  6907. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6908. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6909. m := &ChatSessionMutation{
  6910. config: c,
  6911. op: op,
  6912. typ: TypeChatSession,
  6913. clearedFields: make(map[string]struct{}),
  6914. }
  6915. for _, opt := range opts {
  6916. opt(m)
  6917. }
  6918. return m
  6919. }
  6920. // withChatSessionID sets the ID field of the mutation.
  6921. func withChatSessionID(id uint64) chatsessionOption {
  6922. return func(m *ChatSessionMutation) {
  6923. var (
  6924. err error
  6925. once sync.Once
  6926. value *ChatSession
  6927. )
  6928. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6929. once.Do(func() {
  6930. if m.done {
  6931. err = errors.New("querying old values post mutation is not allowed")
  6932. } else {
  6933. value, err = m.Client().ChatSession.Get(ctx, id)
  6934. }
  6935. })
  6936. return value, err
  6937. }
  6938. m.id = &id
  6939. }
  6940. }
  6941. // withChatSession sets the old ChatSession of the mutation.
  6942. func withChatSession(node *ChatSession) chatsessionOption {
  6943. return func(m *ChatSessionMutation) {
  6944. m.oldValue = func(context.Context) (*ChatSession, error) {
  6945. return node, nil
  6946. }
  6947. m.id = &node.ID
  6948. }
  6949. }
  6950. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6951. // executed in a transaction (ent.Tx), a transactional client is returned.
  6952. func (m ChatSessionMutation) Client() *Client {
  6953. client := &Client{config: m.config}
  6954. client.init()
  6955. return client
  6956. }
  6957. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6958. // it returns an error otherwise.
  6959. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6960. if _, ok := m.driver.(*txDriver); !ok {
  6961. return nil, errors.New("ent: mutation is not running in a transaction")
  6962. }
  6963. tx := &Tx{config: m.config}
  6964. tx.init()
  6965. return tx, nil
  6966. }
  6967. // SetID sets the value of the id field. Note that this
  6968. // operation is only accepted on creation of ChatSession entities.
  6969. func (m *ChatSessionMutation) SetID(id uint64) {
  6970. m.id = &id
  6971. }
  6972. // ID returns the ID value in the mutation. Note that the ID is only available
  6973. // if it was provided to the builder or after it was returned from the database.
  6974. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6975. if m.id == nil {
  6976. return
  6977. }
  6978. return *m.id, true
  6979. }
  6980. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6981. // That means, if the mutation is applied within a transaction with an isolation level such
  6982. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6983. // or updated by the mutation.
  6984. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6985. switch {
  6986. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6987. id, exists := m.ID()
  6988. if exists {
  6989. return []uint64{id}, nil
  6990. }
  6991. fallthrough
  6992. case m.op.Is(OpUpdate | OpDelete):
  6993. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6994. default:
  6995. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6996. }
  6997. }
  6998. // SetCreatedAt sets the "created_at" field.
  6999. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7000. m.created_at = &t
  7001. }
  7002. // CreatedAt returns the value of the "created_at" field in the mutation.
  7003. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7004. v := m.created_at
  7005. if v == nil {
  7006. return
  7007. }
  7008. return *v, true
  7009. }
  7010. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7011. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7013. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7014. if !m.op.Is(OpUpdateOne) {
  7015. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7016. }
  7017. if m.id == nil || m.oldValue == nil {
  7018. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7019. }
  7020. oldValue, err := m.oldValue(ctx)
  7021. if err != nil {
  7022. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7023. }
  7024. return oldValue.CreatedAt, nil
  7025. }
  7026. // ResetCreatedAt resets all changes to the "created_at" field.
  7027. func (m *ChatSessionMutation) ResetCreatedAt() {
  7028. m.created_at = nil
  7029. }
  7030. // SetUpdatedAt sets the "updated_at" field.
  7031. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7032. m.updated_at = &t
  7033. }
  7034. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7035. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7036. v := m.updated_at
  7037. if v == nil {
  7038. return
  7039. }
  7040. return *v, true
  7041. }
  7042. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7043. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7045. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7046. if !m.op.Is(OpUpdateOne) {
  7047. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7048. }
  7049. if m.id == nil || m.oldValue == nil {
  7050. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7051. }
  7052. oldValue, err := m.oldValue(ctx)
  7053. if err != nil {
  7054. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7055. }
  7056. return oldValue.UpdatedAt, nil
  7057. }
  7058. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7059. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7060. m.updated_at = nil
  7061. }
  7062. // SetDeletedAt sets the "deleted_at" field.
  7063. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7064. m.deleted_at = &t
  7065. }
  7066. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7067. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7068. v := m.deleted_at
  7069. if v == nil {
  7070. return
  7071. }
  7072. return *v, true
  7073. }
  7074. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7075. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7077. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7078. if !m.op.Is(OpUpdateOne) {
  7079. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7080. }
  7081. if m.id == nil || m.oldValue == nil {
  7082. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7083. }
  7084. oldValue, err := m.oldValue(ctx)
  7085. if err != nil {
  7086. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7087. }
  7088. return oldValue.DeletedAt, nil
  7089. }
  7090. // ClearDeletedAt clears the value of the "deleted_at" field.
  7091. func (m *ChatSessionMutation) ClearDeletedAt() {
  7092. m.deleted_at = nil
  7093. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7094. }
  7095. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7096. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7097. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7098. return ok
  7099. }
  7100. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7101. func (m *ChatSessionMutation) ResetDeletedAt() {
  7102. m.deleted_at = nil
  7103. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7104. }
  7105. // SetName sets the "name" field.
  7106. func (m *ChatSessionMutation) SetName(s string) {
  7107. m.name = &s
  7108. }
  7109. // Name returns the value of the "name" field in the mutation.
  7110. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7111. v := m.name
  7112. if v == nil {
  7113. return
  7114. }
  7115. return *v, true
  7116. }
  7117. // OldName returns the old "name" field's value of the ChatSession entity.
  7118. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7120. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7121. if !m.op.Is(OpUpdateOne) {
  7122. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7123. }
  7124. if m.id == nil || m.oldValue == nil {
  7125. return v, errors.New("OldName requires an ID field in the mutation")
  7126. }
  7127. oldValue, err := m.oldValue(ctx)
  7128. if err != nil {
  7129. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7130. }
  7131. return oldValue.Name, nil
  7132. }
  7133. // ResetName resets all changes to the "name" field.
  7134. func (m *ChatSessionMutation) ResetName() {
  7135. m.name = nil
  7136. }
  7137. // SetUserID sets the "user_id" field.
  7138. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7139. m.user_id = &u
  7140. m.adduser_id = nil
  7141. }
  7142. // UserID returns the value of the "user_id" field in the mutation.
  7143. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7144. v := m.user_id
  7145. if v == nil {
  7146. return
  7147. }
  7148. return *v, true
  7149. }
  7150. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7151. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7153. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7154. if !m.op.Is(OpUpdateOne) {
  7155. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7156. }
  7157. if m.id == nil || m.oldValue == nil {
  7158. return v, errors.New("OldUserID requires an ID field in the mutation")
  7159. }
  7160. oldValue, err := m.oldValue(ctx)
  7161. if err != nil {
  7162. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7163. }
  7164. return oldValue.UserID, nil
  7165. }
  7166. // AddUserID adds u to the "user_id" field.
  7167. func (m *ChatSessionMutation) AddUserID(u int64) {
  7168. if m.adduser_id != nil {
  7169. *m.adduser_id += u
  7170. } else {
  7171. m.adduser_id = &u
  7172. }
  7173. }
  7174. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7175. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7176. v := m.adduser_id
  7177. if v == nil {
  7178. return
  7179. }
  7180. return *v, true
  7181. }
  7182. // ResetUserID resets all changes to the "user_id" field.
  7183. func (m *ChatSessionMutation) ResetUserID() {
  7184. m.user_id = nil
  7185. m.adduser_id = nil
  7186. }
  7187. // SetBotID sets the "bot_id" field.
  7188. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7189. m.bot_id = &u
  7190. m.addbot_id = nil
  7191. }
  7192. // BotID returns the value of the "bot_id" field in the mutation.
  7193. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7194. v := m.bot_id
  7195. if v == nil {
  7196. return
  7197. }
  7198. return *v, true
  7199. }
  7200. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7201. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7203. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7204. if !m.op.Is(OpUpdateOne) {
  7205. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7206. }
  7207. if m.id == nil || m.oldValue == nil {
  7208. return v, errors.New("OldBotID requires an ID field in the mutation")
  7209. }
  7210. oldValue, err := m.oldValue(ctx)
  7211. if err != nil {
  7212. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7213. }
  7214. return oldValue.BotID, nil
  7215. }
  7216. // AddBotID adds u to the "bot_id" field.
  7217. func (m *ChatSessionMutation) AddBotID(u int64) {
  7218. if m.addbot_id != nil {
  7219. *m.addbot_id += u
  7220. } else {
  7221. m.addbot_id = &u
  7222. }
  7223. }
  7224. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7225. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7226. v := m.addbot_id
  7227. if v == nil {
  7228. return
  7229. }
  7230. return *v, true
  7231. }
  7232. // ResetBotID resets all changes to the "bot_id" field.
  7233. func (m *ChatSessionMutation) ResetBotID() {
  7234. m.bot_id = nil
  7235. m.addbot_id = nil
  7236. }
  7237. // SetBotType sets the "bot_type" field.
  7238. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7239. m.bot_type = &u
  7240. m.addbot_type = nil
  7241. }
  7242. // BotType returns the value of the "bot_type" field in the mutation.
  7243. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7244. v := m.bot_type
  7245. if v == nil {
  7246. return
  7247. }
  7248. return *v, true
  7249. }
  7250. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7251. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7253. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7254. if !m.op.Is(OpUpdateOne) {
  7255. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7256. }
  7257. if m.id == nil || m.oldValue == nil {
  7258. return v, errors.New("OldBotType requires an ID field in the mutation")
  7259. }
  7260. oldValue, err := m.oldValue(ctx)
  7261. if err != nil {
  7262. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7263. }
  7264. return oldValue.BotType, nil
  7265. }
  7266. // AddBotType adds u to the "bot_type" field.
  7267. func (m *ChatSessionMutation) AddBotType(u int8) {
  7268. if m.addbot_type != nil {
  7269. *m.addbot_type += u
  7270. } else {
  7271. m.addbot_type = &u
  7272. }
  7273. }
  7274. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7275. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7276. v := m.addbot_type
  7277. if v == nil {
  7278. return
  7279. }
  7280. return *v, true
  7281. }
  7282. // ResetBotType resets all changes to the "bot_type" field.
  7283. func (m *ChatSessionMutation) ResetBotType() {
  7284. m.bot_type = nil
  7285. m.addbot_type = nil
  7286. }
  7287. // Where appends a list predicates to the ChatSessionMutation builder.
  7288. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7289. m.predicates = append(m.predicates, ps...)
  7290. }
  7291. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7292. // users can use type-assertion to append predicates that do not depend on any generated package.
  7293. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7294. p := make([]predicate.ChatSession, len(ps))
  7295. for i := range ps {
  7296. p[i] = ps[i]
  7297. }
  7298. m.Where(p...)
  7299. }
  7300. // Op returns the operation name.
  7301. func (m *ChatSessionMutation) Op() Op {
  7302. return m.op
  7303. }
  7304. // SetOp allows setting the mutation operation.
  7305. func (m *ChatSessionMutation) SetOp(op Op) {
  7306. m.op = op
  7307. }
  7308. // Type returns the node type of this mutation (ChatSession).
  7309. func (m *ChatSessionMutation) Type() string {
  7310. return m.typ
  7311. }
  7312. // Fields returns all fields that were changed during this mutation. Note that in
  7313. // order to get all numeric fields that were incremented/decremented, call
  7314. // AddedFields().
  7315. func (m *ChatSessionMutation) Fields() []string {
  7316. fields := make([]string, 0, 7)
  7317. if m.created_at != nil {
  7318. fields = append(fields, chatsession.FieldCreatedAt)
  7319. }
  7320. if m.updated_at != nil {
  7321. fields = append(fields, chatsession.FieldUpdatedAt)
  7322. }
  7323. if m.deleted_at != nil {
  7324. fields = append(fields, chatsession.FieldDeletedAt)
  7325. }
  7326. if m.name != nil {
  7327. fields = append(fields, chatsession.FieldName)
  7328. }
  7329. if m.user_id != nil {
  7330. fields = append(fields, chatsession.FieldUserID)
  7331. }
  7332. if m.bot_id != nil {
  7333. fields = append(fields, chatsession.FieldBotID)
  7334. }
  7335. if m.bot_type != nil {
  7336. fields = append(fields, chatsession.FieldBotType)
  7337. }
  7338. return fields
  7339. }
  7340. // Field returns the value of a field with the given name. The second boolean
  7341. // return value indicates that this field was not set, or was not defined in the
  7342. // schema.
  7343. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7344. switch name {
  7345. case chatsession.FieldCreatedAt:
  7346. return m.CreatedAt()
  7347. case chatsession.FieldUpdatedAt:
  7348. return m.UpdatedAt()
  7349. case chatsession.FieldDeletedAt:
  7350. return m.DeletedAt()
  7351. case chatsession.FieldName:
  7352. return m.Name()
  7353. case chatsession.FieldUserID:
  7354. return m.UserID()
  7355. case chatsession.FieldBotID:
  7356. return m.BotID()
  7357. case chatsession.FieldBotType:
  7358. return m.BotType()
  7359. }
  7360. return nil, false
  7361. }
  7362. // OldField returns the old value of the field from the database. An error is
  7363. // returned if the mutation operation is not UpdateOne, or the query to the
  7364. // database failed.
  7365. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7366. switch name {
  7367. case chatsession.FieldCreatedAt:
  7368. return m.OldCreatedAt(ctx)
  7369. case chatsession.FieldUpdatedAt:
  7370. return m.OldUpdatedAt(ctx)
  7371. case chatsession.FieldDeletedAt:
  7372. return m.OldDeletedAt(ctx)
  7373. case chatsession.FieldName:
  7374. return m.OldName(ctx)
  7375. case chatsession.FieldUserID:
  7376. return m.OldUserID(ctx)
  7377. case chatsession.FieldBotID:
  7378. return m.OldBotID(ctx)
  7379. case chatsession.FieldBotType:
  7380. return m.OldBotType(ctx)
  7381. }
  7382. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7383. }
  7384. // SetField sets the value of a field with the given name. It returns an error if
  7385. // the field is not defined in the schema, or if the type mismatched the field
  7386. // type.
  7387. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7388. switch name {
  7389. case chatsession.FieldCreatedAt:
  7390. v, ok := value.(time.Time)
  7391. if !ok {
  7392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7393. }
  7394. m.SetCreatedAt(v)
  7395. return nil
  7396. case chatsession.FieldUpdatedAt:
  7397. v, ok := value.(time.Time)
  7398. if !ok {
  7399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7400. }
  7401. m.SetUpdatedAt(v)
  7402. return nil
  7403. case chatsession.FieldDeletedAt:
  7404. v, ok := value.(time.Time)
  7405. if !ok {
  7406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7407. }
  7408. m.SetDeletedAt(v)
  7409. return nil
  7410. case chatsession.FieldName:
  7411. v, ok := value.(string)
  7412. if !ok {
  7413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7414. }
  7415. m.SetName(v)
  7416. return nil
  7417. case chatsession.FieldUserID:
  7418. v, ok := value.(uint64)
  7419. if !ok {
  7420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7421. }
  7422. m.SetUserID(v)
  7423. return nil
  7424. case chatsession.FieldBotID:
  7425. v, ok := value.(uint64)
  7426. if !ok {
  7427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7428. }
  7429. m.SetBotID(v)
  7430. return nil
  7431. case chatsession.FieldBotType:
  7432. v, ok := value.(uint8)
  7433. if !ok {
  7434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7435. }
  7436. m.SetBotType(v)
  7437. return nil
  7438. }
  7439. return fmt.Errorf("unknown ChatSession field %s", name)
  7440. }
  7441. // AddedFields returns all numeric fields that were incremented/decremented during
  7442. // this mutation.
  7443. func (m *ChatSessionMutation) AddedFields() []string {
  7444. var fields []string
  7445. if m.adduser_id != nil {
  7446. fields = append(fields, chatsession.FieldUserID)
  7447. }
  7448. if m.addbot_id != nil {
  7449. fields = append(fields, chatsession.FieldBotID)
  7450. }
  7451. if m.addbot_type != nil {
  7452. fields = append(fields, chatsession.FieldBotType)
  7453. }
  7454. return fields
  7455. }
  7456. // AddedField returns the numeric value that was incremented/decremented on a field
  7457. // with the given name. The second boolean return value indicates that this field
  7458. // was not set, or was not defined in the schema.
  7459. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7460. switch name {
  7461. case chatsession.FieldUserID:
  7462. return m.AddedUserID()
  7463. case chatsession.FieldBotID:
  7464. return m.AddedBotID()
  7465. case chatsession.FieldBotType:
  7466. return m.AddedBotType()
  7467. }
  7468. return nil, false
  7469. }
  7470. // AddField adds the value to the field with the given name. It returns an error if
  7471. // the field is not defined in the schema, or if the type mismatched the field
  7472. // type.
  7473. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7474. switch name {
  7475. case chatsession.FieldUserID:
  7476. v, ok := value.(int64)
  7477. if !ok {
  7478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7479. }
  7480. m.AddUserID(v)
  7481. return nil
  7482. case chatsession.FieldBotID:
  7483. v, ok := value.(int64)
  7484. if !ok {
  7485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7486. }
  7487. m.AddBotID(v)
  7488. return nil
  7489. case chatsession.FieldBotType:
  7490. v, ok := value.(int8)
  7491. if !ok {
  7492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7493. }
  7494. m.AddBotType(v)
  7495. return nil
  7496. }
  7497. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7498. }
  7499. // ClearedFields returns all nullable fields that were cleared during this
  7500. // mutation.
  7501. func (m *ChatSessionMutation) ClearedFields() []string {
  7502. var fields []string
  7503. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7504. fields = append(fields, chatsession.FieldDeletedAt)
  7505. }
  7506. return fields
  7507. }
  7508. // FieldCleared returns a boolean indicating if a field with the given name was
  7509. // cleared in this mutation.
  7510. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7511. _, ok := m.clearedFields[name]
  7512. return ok
  7513. }
  7514. // ClearField clears the value of the field with the given name. It returns an
  7515. // error if the field is not defined in the schema.
  7516. func (m *ChatSessionMutation) ClearField(name string) error {
  7517. switch name {
  7518. case chatsession.FieldDeletedAt:
  7519. m.ClearDeletedAt()
  7520. return nil
  7521. }
  7522. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7523. }
  7524. // ResetField resets all changes in the mutation for the field with the given name.
  7525. // It returns an error if the field is not defined in the schema.
  7526. func (m *ChatSessionMutation) ResetField(name string) error {
  7527. switch name {
  7528. case chatsession.FieldCreatedAt:
  7529. m.ResetCreatedAt()
  7530. return nil
  7531. case chatsession.FieldUpdatedAt:
  7532. m.ResetUpdatedAt()
  7533. return nil
  7534. case chatsession.FieldDeletedAt:
  7535. m.ResetDeletedAt()
  7536. return nil
  7537. case chatsession.FieldName:
  7538. m.ResetName()
  7539. return nil
  7540. case chatsession.FieldUserID:
  7541. m.ResetUserID()
  7542. return nil
  7543. case chatsession.FieldBotID:
  7544. m.ResetBotID()
  7545. return nil
  7546. case chatsession.FieldBotType:
  7547. m.ResetBotType()
  7548. return nil
  7549. }
  7550. return fmt.Errorf("unknown ChatSession field %s", name)
  7551. }
  7552. // AddedEdges returns all edge names that were set/added in this mutation.
  7553. func (m *ChatSessionMutation) AddedEdges() []string {
  7554. edges := make([]string, 0, 0)
  7555. return edges
  7556. }
  7557. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7558. // name in this mutation.
  7559. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7560. return nil
  7561. }
  7562. // RemovedEdges returns all edge names that were removed in this mutation.
  7563. func (m *ChatSessionMutation) RemovedEdges() []string {
  7564. edges := make([]string, 0, 0)
  7565. return edges
  7566. }
  7567. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7568. // the given name in this mutation.
  7569. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7570. return nil
  7571. }
  7572. // ClearedEdges returns all edge names that were cleared in this mutation.
  7573. func (m *ChatSessionMutation) ClearedEdges() []string {
  7574. edges := make([]string, 0, 0)
  7575. return edges
  7576. }
  7577. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7578. // was cleared in this mutation.
  7579. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7580. return false
  7581. }
  7582. // ClearEdge clears the value of the edge with the given name. It returns an error
  7583. // if that edge is not defined in the schema.
  7584. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7585. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7586. }
  7587. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7588. // It returns an error if the edge is not defined in the schema.
  7589. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7590. return fmt.Errorf("unknown ChatSession edge %s", name)
  7591. }
  7592. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7593. type ContactMutation struct {
  7594. config
  7595. op Op
  7596. typ string
  7597. id *uint64
  7598. created_at *time.Time
  7599. updated_at *time.Time
  7600. status *uint8
  7601. addstatus *int8
  7602. deleted_at *time.Time
  7603. wx_wxid *string
  7604. _type *int
  7605. add_type *int
  7606. wxid *string
  7607. account *string
  7608. nickname *string
  7609. markname *string
  7610. headimg *string
  7611. sex *int
  7612. addsex *int
  7613. starrole *string
  7614. dontseeit *int
  7615. adddontseeit *int
  7616. dontseeme *int
  7617. adddontseeme *int
  7618. lag *string
  7619. gid *string
  7620. gname *string
  7621. v3 *string
  7622. organization_id *uint64
  7623. addorganization_id *int64
  7624. clearedFields map[string]struct{}
  7625. contact_relationships map[uint64]struct{}
  7626. removedcontact_relationships map[uint64]struct{}
  7627. clearedcontact_relationships bool
  7628. contact_messages map[uint64]struct{}
  7629. removedcontact_messages map[uint64]struct{}
  7630. clearedcontact_messages bool
  7631. done bool
  7632. oldValue func(context.Context) (*Contact, error)
  7633. predicates []predicate.Contact
  7634. }
  7635. var _ ent.Mutation = (*ContactMutation)(nil)
  7636. // contactOption allows management of the mutation configuration using functional options.
  7637. type contactOption func(*ContactMutation)
  7638. // newContactMutation creates new mutation for the Contact entity.
  7639. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7640. m := &ContactMutation{
  7641. config: c,
  7642. op: op,
  7643. typ: TypeContact,
  7644. clearedFields: make(map[string]struct{}),
  7645. }
  7646. for _, opt := range opts {
  7647. opt(m)
  7648. }
  7649. return m
  7650. }
  7651. // withContactID sets the ID field of the mutation.
  7652. func withContactID(id uint64) contactOption {
  7653. return func(m *ContactMutation) {
  7654. var (
  7655. err error
  7656. once sync.Once
  7657. value *Contact
  7658. )
  7659. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7660. once.Do(func() {
  7661. if m.done {
  7662. err = errors.New("querying old values post mutation is not allowed")
  7663. } else {
  7664. value, err = m.Client().Contact.Get(ctx, id)
  7665. }
  7666. })
  7667. return value, err
  7668. }
  7669. m.id = &id
  7670. }
  7671. }
  7672. // withContact sets the old Contact of the mutation.
  7673. func withContact(node *Contact) contactOption {
  7674. return func(m *ContactMutation) {
  7675. m.oldValue = func(context.Context) (*Contact, error) {
  7676. return node, nil
  7677. }
  7678. m.id = &node.ID
  7679. }
  7680. }
  7681. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7682. // executed in a transaction (ent.Tx), a transactional client is returned.
  7683. func (m ContactMutation) Client() *Client {
  7684. client := &Client{config: m.config}
  7685. client.init()
  7686. return client
  7687. }
  7688. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7689. // it returns an error otherwise.
  7690. func (m ContactMutation) Tx() (*Tx, error) {
  7691. if _, ok := m.driver.(*txDriver); !ok {
  7692. return nil, errors.New("ent: mutation is not running in a transaction")
  7693. }
  7694. tx := &Tx{config: m.config}
  7695. tx.init()
  7696. return tx, nil
  7697. }
  7698. // SetID sets the value of the id field. Note that this
  7699. // operation is only accepted on creation of Contact entities.
  7700. func (m *ContactMutation) SetID(id uint64) {
  7701. m.id = &id
  7702. }
  7703. // ID returns the ID value in the mutation. Note that the ID is only available
  7704. // if it was provided to the builder or after it was returned from the database.
  7705. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7706. if m.id == nil {
  7707. return
  7708. }
  7709. return *m.id, true
  7710. }
  7711. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7712. // That means, if the mutation is applied within a transaction with an isolation level such
  7713. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7714. // or updated by the mutation.
  7715. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7716. switch {
  7717. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7718. id, exists := m.ID()
  7719. if exists {
  7720. return []uint64{id}, nil
  7721. }
  7722. fallthrough
  7723. case m.op.Is(OpUpdate | OpDelete):
  7724. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7725. default:
  7726. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7727. }
  7728. }
  7729. // SetCreatedAt sets the "created_at" field.
  7730. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7731. m.created_at = &t
  7732. }
  7733. // CreatedAt returns the value of the "created_at" field in the mutation.
  7734. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7735. v := m.created_at
  7736. if v == nil {
  7737. return
  7738. }
  7739. return *v, true
  7740. }
  7741. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7742. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7744. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7745. if !m.op.Is(OpUpdateOne) {
  7746. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7747. }
  7748. if m.id == nil || m.oldValue == nil {
  7749. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7750. }
  7751. oldValue, err := m.oldValue(ctx)
  7752. if err != nil {
  7753. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7754. }
  7755. return oldValue.CreatedAt, nil
  7756. }
  7757. // ResetCreatedAt resets all changes to the "created_at" field.
  7758. func (m *ContactMutation) ResetCreatedAt() {
  7759. m.created_at = nil
  7760. }
  7761. // SetUpdatedAt sets the "updated_at" field.
  7762. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7763. m.updated_at = &t
  7764. }
  7765. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7766. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7767. v := m.updated_at
  7768. if v == nil {
  7769. return
  7770. }
  7771. return *v, true
  7772. }
  7773. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7774. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7776. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7777. if !m.op.Is(OpUpdateOne) {
  7778. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7779. }
  7780. if m.id == nil || m.oldValue == nil {
  7781. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7782. }
  7783. oldValue, err := m.oldValue(ctx)
  7784. if err != nil {
  7785. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7786. }
  7787. return oldValue.UpdatedAt, nil
  7788. }
  7789. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7790. func (m *ContactMutation) ResetUpdatedAt() {
  7791. m.updated_at = nil
  7792. }
  7793. // SetStatus sets the "status" field.
  7794. func (m *ContactMutation) SetStatus(u uint8) {
  7795. m.status = &u
  7796. m.addstatus = nil
  7797. }
  7798. // Status returns the value of the "status" field in the mutation.
  7799. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7800. v := m.status
  7801. if v == nil {
  7802. return
  7803. }
  7804. return *v, true
  7805. }
  7806. // OldStatus returns the old "status" field's value of the Contact entity.
  7807. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7809. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7810. if !m.op.Is(OpUpdateOne) {
  7811. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7812. }
  7813. if m.id == nil || m.oldValue == nil {
  7814. return v, errors.New("OldStatus requires an ID field in the mutation")
  7815. }
  7816. oldValue, err := m.oldValue(ctx)
  7817. if err != nil {
  7818. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7819. }
  7820. return oldValue.Status, nil
  7821. }
  7822. // AddStatus adds u to the "status" field.
  7823. func (m *ContactMutation) AddStatus(u int8) {
  7824. if m.addstatus != nil {
  7825. *m.addstatus += u
  7826. } else {
  7827. m.addstatus = &u
  7828. }
  7829. }
  7830. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7831. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7832. v := m.addstatus
  7833. if v == nil {
  7834. return
  7835. }
  7836. return *v, true
  7837. }
  7838. // ClearStatus clears the value of the "status" field.
  7839. func (m *ContactMutation) ClearStatus() {
  7840. m.status = nil
  7841. m.addstatus = nil
  7842. m.clearedFields[contact.FieldStatus] = struct{}{}
  7843. }
  7844. // StatusCleared returns if the "status" field was cleared in this mutation.
  7845. func (m *ContactMutation) StatusCleared() bool {
  7846. _, ok := m.clearedFields[contact.FieldStatus]
  7847. return ok
  7848. }
  7849. // ResetStatus resets all changes to the "status" field.
  7850. func (m *ContactMutation) ResetStatus() {
  7851. m.status = nil
  7852. m.addstatus = nil
  7853. delete(m.clearedFields, contact.FieldStatus)
  7854. }
  7855. // SetDeletedAt sets the "deleted_at" field.
  7856. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7857. m.deleted_at = &t
  7858. }
  7859. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7860. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7861. v := m.deleted_at
  7862. if v == nil {
  7863. return
  7864. }
  7865. return *v, true
  7866. }
  7867. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7868. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7870. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7871. if !m.op.Is(OpUpdateOne) {
  7872. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7873. }
  7874. if m.id == nil || m.oldValue == nil {
  7875. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7876. }
  7877. oldValue, err := m.oldValue(ctx)
  7878. if err != nil {
  7879. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7880. }
  7881. return oldValue.DeletedAt, nil
  7882. }
  7883. // ClearDeletedAt clears the value of the "deleted_at" field.
  7884. func (m *ContactMutation) ClearDeletedAt() {
  7885. m.deleted_at = nil
  7886. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7887. }
  7888. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7889. func (m *ContactMutation) DeletedAtCleared() bool {
  7890. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7891. return ok
  7892. }
  7893. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7894. func (m *ContactMutation) ResetDeletedAt() {
  7895. m.deleted_at = nil
  7896. delete(m.clearedFields, contact.FieldDeletedAt)
  7897. }
  7898. // SetWxWxid sets the "wx_wxid" field.
  7899. func (m *ContactMutation) SetWxWxid(s string) {
  7900. m.wx_wxid = &s
  7901. }
  7902. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7903. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7904. v := m.wx_wxid
  7905. if v == nil {
  7906. return
  7907. }
  7908. return *v, true
  7909. }
  7910. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7911. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7913. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7914. if !m.op.Is(OpUpdateOne) {
  7915. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7916. }
  7917. if m.id == nil || m.oldValue == nil {
  7918. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7919. }
  7920. oldValue, err := m.oldValue(ctx)
  7921. if err != nil {
  7922. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7923. }
  7924. return oldValue.WxWxid, nil
  7925. }
  7926. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7927. func (m *ContactMutation) ResetWxWxid() {
  7928. m.wx_wxid = nil
  7929. }
  7930. // SetType sets the "type" field.
  7931. func (m *ContactMutation) SetType(i int) {
  7932. m._type = &i
  7933. m.add_type = nil
  7934. }
  7935. // GetType returns the value of the "type" field in the mutation.
  7936. func (m *ContactMutation) GetType() (r int, exists bool) {
  7937. v := m._type
  7938. if v == nil {
  7939. return
  7940. }
  7941. return *v, true
  7942. }
  7943. // OldType returns the old "type" field's value of the Contact entity.
  7944. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7946. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7947. if !m.op.Is(OpUpdateOne) {
  7948. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7949. }
  7950. if m.id == nil || m.oldValue == nil {
  7951. return v, errors.New("OldType requires an ID field in the mutation")
  7952. }
  7953. oldValue, err := m.oldValue(ctx)
  7954. if err != nil {
  7955. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7956. }
  7957. return oldValue.Type, nil
  7958. }
  7959. // AddType adds i to the "type" field.
  7960. func (m *ContactMutation) AddType(i int) {
  7961. if m.add_type != nil {
  7962. *m.add_type += i
  7963. } else {
  7964. m.add_type = &i
  7965. }
  7966. }
  7967. // AddedType returns the value that was added to the "type" field in this mutation.
  7968. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7969. v := m.add_type
  7970. if v == nil {
  7971. return
  7972. }
  7973. return *v, true
  7974. }
  7975. // ClearType clears the value of the "type" field.
  7976. func (m *ContactMutation) ClearType() {
  7977. m._type = nil
  7978. m.add_type = nil
  7979. m.clearedFields[contact.FieldType] = struct{}{}
  7980. }
  7981. // TypeCleared returns if the "type" field was cleared in this mutation.
  7982. func (m *ContactMutation) TypeCleared() bool {
  7983. _, ok := m.clearedFields[contact.FieldType]
  7984. return ok
  7985. }
  7986. // ResetType resets all changes to the "type" field.
  7987. func (m *ContactMutation) ResetType() {
  7988. m._type = nil
  7989. m.add_type = nil
  7990. delete(m.clearedFields, contact.FieldType)
  7991. }
  7992. // SetWxid sets the "wxid" field.
  7993. func (m *ContactMutation) SetWxid(s string) {
  7994. m.wxid = &s
  7995. }
  7996. // Wxid returns the value of the "wxid" field in the mutation.
  7997. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7998. v := m.wxid
  7999. if v == nil {
  8000. return
  8001. }
  8002. return *v, true
  8003. }
  8004. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8005. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8007. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8008. if !m.op.Is(OpUpdateOne) {
  8009. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8010. }
  8011. if m.id == nil || m.oldValue == nil {
  8012. return v, errors.New("OldWxid requires an ID field in the mutation")
  8013. }
  8014. oldValue, err := m.oldValue(ctx)
  8015. if err != nil {
  8016. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8017. }
  8018. return oldValue.Wxid, nil
  8019. }
  8020. // ResetWxid resets all changes to the "wxid" field.
  8021. func (m *ContactMutation) ResetWxid() {
  8022. m.wxid = nil
  8023. }
  8024. // SetAccount sets the "account" field.
  8025. func (m *ContactMutation) SetAccount(s string) {
  8026. m.account = &s
  8027. }
  8028. // Account returns the value of the "account" field in the mutation.
  8029. func (m *ContactMutation) Account() (r string, exists bool) {
  8030. v := m.account
  8031. if v == nil {
  8032. return
  8033. }
  8034. return *v, true
  8035. }
  8036. // OldAccount returns the old "account" field's value of the Contact entity.
  8037. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8039. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8040. if !m.op.Is(OpUpdateOne) {
  8041. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8042. }
  8043. if m.id == nil || m.oldValue == nil {
  8044. return v, errors.New("OldAccount requires an ID field in the mutation")
  8045. }
  8046. oldValue, err := m.oldValue(ctx)
  8047. if err != nil {
  8048. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8049. }
  8050. return oldValue.Account, nil
  8051. }
  8052. // ResetAccount resets all changes to the "account" field.
  8053. func (m *ContactMutation) ResetAccount() {
  8054. m.account = nil
  8055. }
  8056. // SetNickname sets the "nickname" field.
  8057. func (m *ContactMutation) SetNickname(s string) {
  8058. m.nickname = &s
  8059. }
  8060. // Nickname returns the value of the "nickname" field in the mutation.
  8061. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8062. v := m.nickname
  8063. if v == nil {
  8064. return
  8065. }
  8066. return *v, true
  8067. }
  8068. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8069. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8071. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8072. if !m.op.Is(OpUpdateOne) {
  8073. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8074. }
  8075. if m.id == nil || m.oldValue == nil {
  8076. return v, errors.New("OldNickname requires an ID field in the mutation")
  8077. }
  8078. oldValue, err := m.oldValue(ctx)
  8079. if err != nil {
  8080. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8081. }
  8082. return oldValue.Nickname, nil
  8083. }
  8084. // ResetNickname resets all changes to the "nickname" field.
  8085. func (m *ContactMutation) ResetNickname() {
  8086. m.nickname = nil
  8087. }
  8088. // SetMarkname sets the "markname" field.
  8089. func (m *ContactMutation) SetMarkname(s string) {
  8090. m.markname = &s
  8091. }
  8092. // Markname returns the value of the "markname" field in the mutation.
  8093. func (m *ContactMutation) Markname() (r string, exists bool) {
  8094. v := m.markname
  8095. if v == nil {
  8096. return
  8097. }
  8098. return *v, true
  8099. }
  8100. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8101. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8103. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8104. if !m.op.Is(OpUpdateOne) {
  8105. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8106. }
  8107. if m.id == nil || m.oldValue == nil {
  8108. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8109. }
  8110. oldValue, err := m.oldValue(ctx)
  8111. if err != nil {
  8112. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8113. }
  8114. return oldValue.Markname, nil
  8115. }
  8116. // ResetMarkname resets all changes to the "markname" field.
  8117. func (m *ContactMutation) ResetMarkname() {
  8118. m.markname = nil
  8119. }
  8120. // SetHeadimg sets the "headimg" field.
  8121. func (m *ContactMutation) SetHeadimg(s string) {
  8122. m.headimg = &s
  8123. }
  8124. // Headimg returns the value of the "headimg" field in the mutation.
  8125. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8126. v := m.headimg
  8127. if v == nil {
  8128. return
  8129. }
  8130. return *v, true
  8131. }
  8132. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8133. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8135. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8136. if !m.op.Is(OpUpdateOne) {
  8137. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8138. }
  8139. if m.id == nil || m.oldValue == nil {
  8140. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8141. }
  8142. oldValue, err := m.oldValue(ctx)
  8143. if err != nil {
  8144. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8145. }
  8146. return oldValue.Headimg, nil
  8147. }
  8148. // ResetHeadimg resets all changes to the "headimg" field.
  8149. func (m *ContactMutation) ResetHeadimg() {
  8150. m.headimg = nil
  8151. }
  8152. // SetSex sets the "sex" field.
  8153. func (m *ContactMutation) SetSex(i int) {
  8154. m.sex = &i
  8155. m.addsex = nil
  8156. }
  8157. // Sex returns the value of the "sex" field in the mutation.
  8158. func (m *ContactMutation) Sex() (r int, exists bool) {
  8159. v := m.sex
  8160. if v == nil {
  8161. return
  8162. }
  8163. return *v, true
  8164. }
  8165. // OldSex returns the old "sex" field's value of the Contact entity.
  8166. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8168. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8169. if !m.op.Is(OpUpdateOne) {
  8170. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8171. }
  8172. if m.id == nil || m.oldValue == nil {
  8173. return v, errors.New("OldSex requires an ID field in the mutation")
  8174. }
  8175. oldValue, err := m.oldValue(ctx)
  8176. if err != nil {
  8177. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8178. }
  8179. return oldValue.Sex, nil
  8180. }
  8181. // AddSex adds i to the "sex" field.
  8182. func (m *ContactMutation) AddSex(i int) {
  8183. if m.addsex != nil {
  8184. *m.addsex += i
  8185. } else {
  8186. m.addsex = &i
  8187. }
  8188. }
  8189. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8190. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8191. v := m.addsex
  8192. if v == nil {
  8193. return
  8194. }
  8195. return *v, true
  8196. }
  8197. // ResetSex resets all changes to the "sex" field.
  8198. func (m *ContactMutation) ResetSex() {
  8199. m.sex = nil
  8200. m.addsex = nil
  8201. }
  8202. // SetStarrole sets the "starrole" field.
  8203. func (m *ContactMutation) SetStarrole(s string) {
  8204. m.starrole = &s
  8205. }
  8206. // Starrole returns the value of the "starrole" field in the mutation.
  8207. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8208. v := m.starrole
  8209. if v == nil {
  8210. return
  8211. }
  8212. return *v, true
  8213. }
  8214. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8215. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8217. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8218. if !m.op.Is(OpUpdateOne) {
  8219. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8220. }
  8221. if m.id == nil || m.oldValue == nil {
  8222. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8223. }
  8224. oldValue, err := m.oldValue(ctx)
  8225. if err != nil {
  8226. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8227. }
  8228. return oldValue.Starrole, nil
  8229. }
  8230. // ResetStarrole resets all changes to the "starrole" field.
  8231. func (m *ContactMutation) ResetStarrole() {
  8232. m.starrole = nil
  8233. }
  8234. // SetDontseeit sets the "dontseeit" field.
  8235. func (m *ContactMutation) SetDontseeit(i int) {
  8236. m.dontseeit = &i
  8237. m.adddontseeit = nil
  8238. }
  8239. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8240. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8241. v := m.dontseeit
  8242. if v == nil {
  8243. return
  8244. }
  8245. return *v, true
  8246. }
  8247. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8248. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8250. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8251. if !m.op.Is(OpUpdateOne) {
  8252. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8253. }
  8254. if m.id == nil || m.oldValue == nil {
  8255. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8256. }
  8257. oldValue, err := m.oldValue(ctx)
  8258. if err != nil {
  8259. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8260. }
  8261. return oldValue.Dontseeit, nil
  8262. }
  8263. // AddDontseeit adds i to the "dontseeit" field.
  8264. func (m *ContactMutation) AddDontseeit(i int) {
  8265. if m.adddontseeit != nil {
  8266. *m.adddontseeit += i
  8267. } else {
  8268. m.adddontseeit = &i
  8269. }
  8270. }
  8271. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8272. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8273. v := m.adddontseeit
  8274. if v == nil {
  8275. return
  8276. }
  8277. return *v, true
  8278. }
  8279. // ResetDontseeit resets all changes to the "dontseeit" field.
  8280. func (m *ContactMutation) ResetDontseeit() {
  8281. m.dontseeit = nil
  8282. m.adddontseeit = nil
  8283. }
  8284. // SetDontseeme sets the "dontseeme" field.
  8285. func (m *ContactMutation) SetDontseeme(i int) {
  8286. m.dontseeme = &i
  8287. m.adddontseeme = nil
  8288. }
  8289. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8290. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8291. v := m.dontseeme
  8292. if v == nil {
  8293. return
  8294. }
  8295. return *v, true
  8296. }
  8297. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8298. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8300. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8301. if !m.op.Is(OpUpdateOne) {
  8302. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8303. }
  8304. if m.id == nil || m.oldValue == nil {
  8305. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8306. }
  8307. oldValue, err := m.oldValue(ctx)
  8308. if err != nil {
  8309. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8310. }
  8311. return oldValue.Dontseeme, nil
  8312. }
  8313. // AddDontseeme adds i to the "dontseeme" field.
  8314. func (m *ContactMutation) AddDontseeme(i int) {
  8315. if m.adddontseeme != nil {
  8316. *m.adddontseeme += i
  8317. } else {
  8318. m.adddontseeme = &i
  8319. }
  8320. }
  8321. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8322. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8323. v := m.adddontseeme
  8324. if v == nil {
  8325. return
  8326. }
  8327. return *v, true
  8328. }
  8329. // ResetDontseeme resets all changes to the "dontseeme" field.
  8330. func (m *ContactMutation) ResetDontseeme() {
  8331. m.dontseeme = nil
  8332. m.adddontseeme = nil
  8333. }
  8334. // SetLag sets the "lag" field.
  8335. func (m *ContactMutation) SetLag(s string) {
  8336. m.lag = &s
  8337. }
  8338. // Lag returns the value of the "lag" field in the mutation.
  8339. func (m *ContactMutation) Lag() (r string, exists bool) {
  8340. v := m.lag
  8341. if v == nil {
  8342. return
  8343. }
  8344. return *v, true
  8345. }
  8346. // OldLag returns the old "lag" field's value of the Contact entity.
  8347. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8349. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8350. if !m.op.Is(OpUpdateOne) {
  8351. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8352. }
  8353. if m.id == nil || m.oldValue == nil {
  8354. return v, errors.New("OldLag requires an ID field in the mutation")
  8355. }
  8356. oldValue, err := m.oldValue(ctx)
  8357. if err != nil {
  8358. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8359. }
  8360. return oldValue.Lag, nil
  8361. }
  8362. // ResetLag resets all changes to the "lag" field.
  8363. func (m *ContactMutation) ResetLag() {
  8364. m.lag = nil
  8365. }
  8366. // SetGid sets the "gid" field.
  8367. func (m *ContactMutation) SetGid(s string) {
  8368. m.gid = &s
  8369. }
  8370. // Gid returns the value of the "gid" field in the mutation.
  8371. func (m *ContactMutation) Gid() (r string, exists bool) {
  8372. v := m.gid
  8373. if v == nil {
  8374. return
  8375. }
  8376. return *v, true
  8377. }
  8378. // OldGid returns the old "gid" field's value of the Contact entity.
  8379. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8381. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8382. if !m.op.Is(OpUpdateOne) {
  8383. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8384. }
  8385. if m.id == nil || m.oldValue == nil {
  8386. return v, errors.New("OldGid requires an ID field in the mutation")
  8387. }
  8388. oldValue, err := m.oldValue(ctx)
  8389. if err != nil {
  8390. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8391. }
  8392. return oldValue.Gid, nil
  8393. }
  8394. // ResetGid resets all changes to the "gid" field.
  8395. func (m *ContactMutation) ResetGid() {
  8396. m.gid = nil
  8397. }
  8398. // SetGname sets the "gname" field.
  8399. func (m *ContactMutation) SetGname(s string) {
  8400. m.gname = &s
  8401. }
  8402. // Gname returns the value of the "gname" field in the mutation.
  8403. func (m *ContactMutation) Gname() (r string, exists bool) {
  8404. v := m.gname
  8405. if v == nil {
  8406. return
  8407. }
  8408. return *v, true
  8409. }
  8410. // OldGname returns the old "gname" field's value of the Contact entity.
  8411. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8413. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8414. if !m.op.Is(OpUpdateOne) {
  8415. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8416. }
  8417. if m.id == nil || m.oldValue == nil {
  8418. return v, errors.New("OldGname requires an ID field in the mutation")
  8419. }
  8420. oldValue, err := m.oldValue(ctx)
  8421. if err != nil {
  8422. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8423. }
  8424. return oldValue.Gname, nil
  8425. }
  8426. // ResetGname resets all changes to the "gname" field.
  8427. func (m *ContactMutation) ResetGname() {
  8428. m.gname = nil
  8429. }
  8430. // SetV3 sets the "v3" field.
  8431. func (m *ContactMutation) SetV3(s string) {
  8432. m.v3 = &s
  8433. }
  8434. // V3 returns the value of the "v3" field in the mutation.
  8435. func (m *ContactMutation) V3() (r string, exists bool) {
  8436. v := m.v3
  8437. if v == nil {
  8438. return
  8439. }
  8440. return *v, true
  8441. }
  8442. // OldV3 returns the old "v3" field's value of the Contact entity.
  8443. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8445. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8446. if !m.op.Is(OpUpdateOne) {
  8447. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8448. }
  8449. if m.id == nil || m.oldValue == nil {
  8450. return v, errors.New("OldV3 requires an ID field in the mutation")
  8451. }
  8452. oldValue, err := m.oldValue(ctx)
  8453. if err != nil {
  8454. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8455. }
  8456. return oldValue.V3, nil
  8457. }
  8458. // ResetV3 resets all changes to the "v3" field.
  8459. func (m *ContactMutation) ResetV3() {
  8460. m.v3 = nil
  8461. }
  8462. // SetOrganizationID sets the "organization_id" field.
  8463. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8464. m.organization_id = &u
  8465. m.addorganization_id = nil
  8466. }
  8467. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8468. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8469. v := m.organization_id
  8470. if v == nil {
  8471. return
  8472. }
  8473. return *v, true
  8474. }
  8475. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8476. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8478. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8479. if !m.op.Is(OpUpdateOne) {
  8480. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8481. }
  8482. if m.id == nil || m.oldValue == nil {
  8483. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8484. }
  8485. oldValue, err := m.oldValue(ctx)
  8486. if err != nil {
  8487. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8488. }
  8489. return oldValue.OrganizationID, nil
  8490. }
  8491. // AddOrganizationID adds u to the "organization_id" field.
  8492. func (m *ContactMutation) AddOrganizationID(u int64) {
  8493. if m.addorganization_id != nil {
  8494. *m.addorganization_id += u
  8495. } else {
  8496. m.addorganization_id = &u
  8497. }
  8498. }
  8499. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8500. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8501. v := m.addorganization_id
  8502. if v == nil {
  8503. return
  8504. }
  8505. return *v, true
  8506. }
  8507. // ClearOrganizationID clears the value of the "organization_id" field.
  8508. func (m *ContactMutation) ClearOrganizationID() {
  8509. m.organization_id = nil
  8510. m.addorganization_id = nil
  8511. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8512. }
  8513. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8514. func (m *ContactMutation) OrganizationIDCleared() bool {
  8515. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8516. return ok
  8517. }
  8518. // ResetOrganizationID resets all changes to the "organization_id" field.
  8519. func (m *ContactMutation) ResetOrganizationID() {
  8520. m.organization_id = nil
  8521. m.addorganization_id = nil
  8522. delete(m.clearedFields, contact.FieldOrganizationID)
  8523. }
  8524. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8525. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8526. if m.contact_relationships == nil {
  8527. m.contact_relationships = make(map[uint64]struct{})
  8528. }
  8529. for i := range ids {
  8530. m.contact_relationships[ids[i]] = struct{}{}
  8531. }
  8532. }
  8533. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8534. func (m *ContactMutation) ClearContactRelationships() {
  8535. m.clearedcontact_relationships = true
  8536. }
  8537. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8538. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8539. return m.clearedcontact_relationships
  8540. }
  8541. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8542. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8543. if m.removedcontact_relationships == nil {
  8544. m.removedcontact_relationships = make(map[uint64]struct{})
  8545. }
  8546. for i := range ids {
  8547. delete(m.contact_relationships, ids[i])
  8548. m.removedcontact_relationships[ids[i]] = struct{}{}
  8549. }
  8550. }
  8551. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8552. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8553. for id := range m.removedcontact_relationships {
  8554. ids = append(ids, id)
  8555. }
  8556. return
  8557. }
  8558. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8559. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8560. for id := range m.contact_relationships {
  8561. ids = append(ids, id)
  8562. }
  8563. return
  8564. }
  8565. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8566. func (m *ContactMutation) ResetContactRelationships() {
  8567. m.contact_relationships = nil
  8568. m.clearedcontact_relationships = false
  8569. m.removedcontact_relationships = nil
  8570. }
  8571. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8572. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8573. if m.contact_messages == nil {
  8574. m.contact_messages = make(map[uint64]struct{})
  8575. }
  8576. for i := range ids {
  8577. m.contact_messages[ids[i]] = struct{}{}
  8578. }
  8579. }
  8580. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8581. func (m *ContactMutation) ClearContactMessages() {
  8582. m.clearedcontact_messages = true
  8583. }
  8584. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8585. func (m *ContactMutation) ContactMessagesCleared() bool {
  8586. return m.clearedcontact_messages
  8587. }
  8588. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8589. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8590. if m.removedcontact_messages == nil {
  8591. m.removedcontact_messages = make(map[uint64]struct{})
  8592. }
  8593. for i := range ids {
  8594. delete(m.contact_messages, ids[i])
  8595. m.removedcontact_messages[ids[i]] = struct{}{}
  8596. }
  8597. }
  8598. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8599. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8600. for id := range m.removedcontact_messages {
  8601. ids = append(ids, id)
  8602. }
  8603. return
  8604. }
  8605. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8606. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8607. for id := range m.contact_messages {
  8608. ids = append(ids, id)
  8609. }
  8610. return
  8611. }
  8612. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8613. func (m *ContactMutation) ResetContactMessages() {
  8614. m.contact_messages = nil
  8615. m.clearedcontact_messages = false
  8616. m.removedcontact_messages = nil
  8617. }
  8618. // Where appends a list predicates to the ContactMutation builder.
  8619. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8620. m.predicates = append(m.predicates, ps...)
  8621. }
  8622. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8623. // users can use type-assertion to append predicates that do not depend on any generated package.
  8624. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8625. p := make([]predicate.Contact, len(ps))
  8626. for i := range ps {
  8627. p[i] = ps[i]
  8628. }
  8629. m.Where(p...)
  8630. }
  8631. // Op returns the operation name.
  8632. func (m *ContactMutation) Op() Op {
  8633. return m.op
  8634. }
  8635. // SetOp allows setting the mutation operation.
  8636. func (m *ContactMutation) SetOp(op Op) {
  8637. m.op = op
  8638. }
  8639. // Type returns the node type of this mutation (Contact).
  8640. func (m *ContactMutation) Type() string {
  8641. return m.typ
  8642. }
  8643. // Fields returns all fields that were changed during this mutation. Note that in
  8644. // order to get all numeric fields that were incremented/decremented, call
  8645. // AddedFields().
  8646. func (m *ContactMutation) Fields() []string {
  8647. fields := make([]string, 0, 20)
  8648. if m.created_at != nil {
  8649. fields = append(fields, contact.FieldCreatedAt)
  8650. }
  8651. if m.updated_at != nil {
  8652. fields = append(fields, contact.FieldUpdatedAt)
  8653. }
  8654. if m.status != nil {
  8655. fields = append(fields, contact.FieldStatus)
  8656. }
  8657. if m.deleted_at != nil {
  8658. fields = append(fields, contact.FieldDeletedAt)
  8659. }
  8660. if m.wx_wxid != nil {
  8661. fields = append(fields, contact.FieldWxWxid)
  8662. }
  8663. if m._type != nil {
  8664. fields = append(fields, contact.FieldType)
  8665. }
  8666. if m.wxid != nil {
  8667. fields = append(fields, contact.FieldWxid)
  8668. }
  8669. if m.account != nil {
  8670. fields = append(fields, contact.FieldAccount)
  8671. }
  8672. if m.nickname != nil {
  8673. fields = append(fields, contact.FieldNickname)
  8674. }
  8675. if m.markname != nil {
  8676. fields = append(fields, contact.FieldMarkname)
  8677. }
  8678. if m.headimg != nil {
  8679. fields = append(fields, contact.FieldHeadimg)
  8680. }
  8681. if m.sex != nil {
  8682. fields = append(fields, contact.FieldSex)
  8683. }
  8684. if m.starrole != nil {
  8685. fields = append(fields, contact.FieldStarrole)
  8686. }
  8687. if m.dontseeit != nil {
  8688. fields = append(fields, contact.FieldDontseeit)
  8689. }
  8690. if m.dontseeme != nil {
  8691. fields = append(fields, contact.FieldDontseeme)
  8692. }
  8693. if m.lag != nil {
  8694. fields = append(fields, contact.FieldLag)
  8695. }
  8696. if m.gid != nil {
  8697. fields = append(fields, contact.FieldGid)
  8698. }
  8699. if m.gname != nil {
  8700. fields = append(fields, contact.FieldGname)
  8701. }
  8702. if m.v3 != nil {
  8703. fields = append(fields, contact.FieldV3)
  8704. }
  8705. if m.organization_id != nil {
  8706. fields = append(fields, contact.FieldOrganizationID)
  8707. }
  8708. return fields
  8709. }
  8710. // Field returns the value of a field with the given name. The second boolean
  8711. // return value indicates that this field was not set, or was not defined in the
  8712. // schema.
  8713. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8714. switch name {
  8715. case contact.FieldCreatedAt:
  8716. return m.CreatedAt()
  8717. case contact.FieldUpdatedAt:
  8718. return m.UpdatedAt()
  8719. case contact.FieldStatus:
  8720. return m.Status()
  8721. case contact.FieldDeletedAt:
  8722. return m.DeletedAt()
  8723. case contact.FieldWxWxid:
  8724. return m.WxWxid()
  8725. case contact.FieldType:
  8726. return m.GetType()
  8727. case contact.FieldWxid:
  8728. return m.Wxid()
  8729. case contact.FieldAccount:
  8730. return m.Account()
  8731. case contact.FieldNickname:
  8732. return m.Nickname()
  8733. case contact.FieldMarkname:
  8734. return m.Markname()
  8735. case contact.FieldHeadimg:
  8736. return m.Headimg()
  8737. case contact.FieldSex:
  8738. return m.Sex()
  8739. case contact.FieldStarrole:
  8740. return m.Starrole()
  8741. case contact.FieldDontseeit:
  8742. return m.Dontseeit()
  8743. case contact.FieldDontseeme:
  8744. return m.Dontseeme()
  8745. case contact.FieldLag:
  8746. return m.Lag()
  8747. case contact.FieldGid:
  8748. return m.Gid()
  8749. case contact.FieldGname:
  8750. return m.Gname()
  8751. case contact.FieldV3:
  8752. return m.V3()
  8753. case contact.FieldOrganizationID:
  8754. return m.OrganizationID()
  8755. }
  8756. return nil, false
  8757. }
  8758. // OldField returns the old value of the field from the database. An error is
  8759. // returned if the mutation operation is not UpdateOne, or the query to the
  8760. // database failed.
  8761. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8762. switch name {
  8763. case contact.FieldCreatedAt:
  8764. return m.OldCreatedAt(ctx)
  8765. case contact.FieldUpdatedAt:
  8766. return m.OldUpdatedAt(ctx)
  8767. case contact.FieldStatus:
  8768. return m.OldStatus(ctx)
  8769. case contact.FieldDeletedAt:
  8770. return m.OldDeletedAt(ctx)
  8771. case contact.FieldWxWxid:
  8772. return m.OldWxWxid(ctx)
  8773. case contact.FieldType:
  8774. return m.OldType(ctx)
  8775. case contact.FieldWxid:
  8776. return m.OldWxid(ctx)
  8777. case contact.FieldAccount:
  8778. return m.OldAccount(ctx)
  8779. case contact.FieldNickname:
  8780. return m.OldNickname(ctx)
  8781. case contact.FieldMarkname:
  8782. return m.OldMarkname(ctx)
  8783. case contact.FieldHeadimg:
  8784. return m.OldHeadimg(ctx)
  8785. case contact.FieldSex:
  8786. return m.OldSex(ctx)
  8787. case contact.FieldStarrole:
  8788. return m.OldStarrole(ctx)
  8789. case contact.FieldDontseeit:
  8790. return m.OldDontseeit(ctx)
  8791. case contact.FieldDontseeme:
  8792. return m.OldDontseeme(ctx)
  8793. case contact.FieldLag:
  8794. return m.OldLag(ctx)
  8795. case contact.FieldGid:
  8796. return m.OldGid(ctx)
  8797. case contact.FieldGname:
  8798. return m.OldGname(ctx)
  8799. case contact.FieldV3:
  8800. return m.OldV3(ctx)
  8801. case contact.FieldOrganizationID:
  8802. return m.OldOrganizationID(ctx)
  8803. }
  8804. return nil, fmt.Errorf("unknown Contact field %s", name)
  8805. }
  8806. // SetField sets the value of a field with the given name. It returns an error if
  8807. // the field is not defined in the schema, or if the type mismatched the field
  8808. // type.
  8809. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8810. switch name {
  8811. case contact.FieldCreatedAt:
  8812. v, ok := value.(time.Time)
  8813. if !ok {
  8814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8815. }
  8816. m.SetCreatedAt(v)
  8817. return nil
  8818. case contact.FieldUpdatedAt:
  8819. v, ok := value.(time.Time)
  8820. if !ok {
  8821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8822. }
  8823. m.SetUpdatedAt(v)
  8824. return nil
  8825. case contact.FieldStatus:
  8826. v, ok := value.(uint8)
  8827. if !ok {
  8828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8829. }
  8830. m.SetStatus(v)
  8831. return nil
  8832. case contact.FieldDeletedAt:
  8833. v, ok := value.(time.Time)
  8834. if !ok {
  8835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8836. }
  8837. m.SetDeletedAt(v)
  8838. return nil
  8839. case contact.FieldWxWxid:
  8840. v, ok := value.(string)
  8841. if !ok {
  8842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8843. }
  8844. m.SetWxWxid(v)
  8845. return nil
  8846. case contact.FieldType:
  8847. v, ok := value.(int)
  8848. if !ok {
  8849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8850. }
  8851. m.SetType(v)
  8852. return nil
  8853. case contact.FieldWxid:
  8854. v, ok := value.(string)
  8855. if !ok {
  8856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8857. }
  8858. m.SetWxid(v)
  8859. return nil
  8860. case contact.FieldAccount:
  8861. v, ok := value.(string)
  8862. if !ok {
  8863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8864. }
  8865. m.SetAccount(v)
  8866. return nil
  8867. case contact.FieldNickname:
  8868. v, ok := value.(string)
  8869. if !ok {
  8870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8871. }
  8872. m.SetNickname(v)
  8873. return nil
  8874. case contact.FieldMarkname:
  8875. v, ok := value.(string)
  8876. if !ok {
  8877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8878. }
  8879. m.SetMarkname(v)
  8880. return nil
  8881. case contact.FieldHeadimg:
  8882. v, ok := value.(string)
  8883. if !ok {
  8884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8885. }
  8886. m.SetHeadimg(v)
  8887. return nil
  8888. case contact.FieldSex:
  8889. v, ok := value.(int)
  8890. if !ok {
  8891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8892. }
  8893. m.SetSex(v)
  8894. return nil
  8895. case contact.FieldStarrole:
  8896. v, ok := value.(string)
  8897. if !ok {
  8898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8899. }
  8900. m.SetStarrole(v)
  8901. return nil
  8902. case contact.FieldDontseeit:
  8903. v, ok := value.(int)
  8904. if !ok {
  8905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8906. }
  8907. m.SetDontseeit(v)
  8908. return nil
  8909. case contact.FieldDontseeme:
  8910. v, ok := value.(int)
  8911. if !ok {
  8912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8913. }
  8914. m.SetDontseeme(v)
  8915. return nil
  8916. case contact.FieldLag:
  8917. v, ok := value.(string)
  8918. if !ok {
  8919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8920. }
  8921. m.SetLag(v)
  8922. return nil
  8923. case contact.FieldGid:
  8924. v, ok := value.(string)
  8925. if !ok {
  8926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8927. }
  8928. m.SetGid(v)
  8929. return nil
  8930. case contact.FieldGname:
  8931. v, ok := value.(string)
  8932. if !ok {
  8933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8934. }
  8935. m.SetGname(v)
  8936. return nil
  8937. case contact.FieldV3:
  8938. v, ok := value.(string)
  8939. if !ok {
  8940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8941. }
  8942. m.SetV3(v)
  8943. return nil
  8944. case contact.FieldOrganizationID:
  8945. v, ok := value.(uint64)
  8946. if !ok {
  8947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8948. }
  8949. m.SetOrganizationID(v)
  8950. return nil
  8951. }
  8952. return fmt.Errorf("unknown Contact field %s", name)
  8953. }
  8954. // AddedFields returns all numeric fields that were incremented/decremented during
  8955. // this mutation.
  8956. func (m *ContactMutation) AddedFields() []string {
  8957. var fields []string
  8958. if m.addstatus != nil {
  8959. fields = append(fields, contact.FieldStatus)
  8960. }
  8961. if m.add_type != nil {
  8962. fields = append(fields, contact.FieldType)
  8963. }
  8964. if m.addsex != nil {
  8965. fields = append(fields, contact.FieldSex)
  8966. }
  8967. if m.adddontseeit != nil {
  8968. fields = append(fields, contact.FieldDontseeit)
  8969. }
  8970. if m.adddontseeme != nil {
  8971. fields = append(fields, contact.FieldDontseeme)
  8972. }
  8973. if m.addorganization_id != nil {
  8974. fields = append(fields, contact.FieldOrganizationID)
  8975. }
  8976. return fields
  8977. }
  8978. // AddedField returns the numeric value that was incremented/decremented on a field
  8979. // with the given name. The second boolean return value indicates that this field
  8980. // was not set, or was not defined in the schema.
  8981. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8982. switch name {
  8983. case contact.FieldStatus:
  8984. return m.AddedStatus()
  8985. case contact.FieldType:
  8986. return m.AddedType()
  8987. case contact.FieldSex:
  8988. return m.AddedSex()
  8989. case contact.FieldDontseeit:
  8990. return m.AddedDontseeit()
  8991. case contact.FieldDontseeme:
  8992. return m.AddedDontseeme()
  8993. case contact.FieldOrganizationID:
  8994. return m.AddedOrganizationID()
  8995. }
  8996. return nil, false
  8997. }
  8998. // AddField adds the value to the field with the given name. It returns an error if
  8999. // the field is not defined in the schema, or if the type mismatched the field
  9000. // type.
  9001. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9002. switch name {
  9003. case contact.FieldStatus:
  9004. v, ok := value.(int8)
  9005. if !ok {
  9006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9007. }
  9008. m.AddStatus(v)
  9009. return nil
  9010. case contact.FieldType:
  9011. v, ok := value.(int)
  9012. if !ok {
  9013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9014. }
  9015. m.AddType(v)
  9016. return nil
  9017. case contact.FieldSex:
  9018. v, ok := value.(int)
  9019. if !ok {
  9020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9021. }
  9022. m.AddSex(v)
  9023. return nil
  9024. case contact.FieldDontseeit:
  9025. v, ok := value.(int)
  9026. if !ok {
  9027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9028. }
  9029. m.AddDontseeit(v)
  9030. return nil
  9031. case contact.FieldDontseeme:
  9032. v, ok := value.(int)
  9033. if !ok {
  9034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9035. }
  9036. m.AddDontseeme(v)
  9037. return nil
  9038. case contact.FieldOrganizationID:
  9039. v, ok := value.(int64)
  9040. if !ok {
  9041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9042. }
  9043. m.AddOrganizationID(v)
  9044. return nil
  9045. }
  9046. return fmt.Errorf("unknown Contact numeric field %s", name)
  9047. }
  9048. // ClearedFields returns all nullable fields that were cleared during this
  9049. // mutation.
  9050. func (m *ContactMutation) ClearedFields() []string {
  9051. var fields []string
  9052. if m.FieldCleared(contact.FieldStatus) {
  9053. fields = append(fields, contact.FieldStatus)
  9054. }
  9055. if m.FieldCleared(contact.FieldDeletedAt) {
  9056. fields = append(fields, contact.FieldDeletedAt)
  9057. }
  9058. if m.FieldCleared(contact.FieldType) {
  9059. fields = append(fields, contact.FieldType)
  9060. }
  9061. if m.FieldCleared(contact.FieldOrganizationID) {
  9062. fields = append(fields, contact.FieldOrganizationID)
  9063. }
  9064. return fields
  9065. }
  9066. // FieldCleared returns a boolean indicating if a field with the given name was
  9067. // cleared in this mutation.
  9068. func (m *ContactMutation) FieldCleared(name string) bool {
  9069. _, ok := m.clearedFields[name]
  9070. return ok
  9071. }
  9072. // ClearField clears the value of the field with the given name. It returns an
  9073. // error if the field is not defined in the schema.
  9074. func (m *ContactMutation) ClearField(name string) error {
  9075. switch name {
  9076. case contact.FieldStatus:
  9077. m.ClearStatus()
  9078. return nil
  9079. case contact.FieldDeletedAt:
  9080. m.ClearDeletedAt()
  9081. return nil
  9082. case contact.FieldType:
  9083. m.ClearType()
  9084. return nil
  9085. case contact.FieldOrganizationID:
  9086. m.ClearOrganizationID()
  9087. return nil
  9088. }
  9089. return fmt.Errorf("unknown Contact nullable field %s", name)
  9090. }
  9091. // ResetField resets all changes in the mutation for the field with the given name.
  9092. // It returns an error if the field is not defined in the schema.
  9093. func (m *ContactMutation) ResetField(name string) error {
  9094. switch name {
  9095. case contact.FieldCreatedAt:
  9096. m.ResetCreatedAt()
  9097. return nil
  9098. case contact.FieldUpdatedAt:
  9099. m.ResetUpdatedAt()
  9100. return nil
  9101. case contact.FieldStatus:
  9102. m.ResetStatus()
  9103. return nil
  9104. case contact.FieldDeletedAt:
  9105. m.ResetDeletedAt()
  9106. return nil
  9107. case contact.FieldWxWxid:
  9108. m.ResetWxWxid()
  9109. return nil
  9110. case contact.FieldType:
  9111. m.ResetType()
  9112. return nil
  9113. case contact.FieldWxid:
  9114. m.ResetWxid()
  9115. return nil
  9116. case contact.FieldAccount:
  9117. m.ResetAccount()
  9118. return nil
  9119. case contact.FieldNickname:
  9120. m.ResetNickname()
  9121. return nil
  9122. case contact.FieldMarkname:
  9123. m.ResetMarkname()
  9124. return nil
  9125. case contact.FieldHeadimg:
  9126. m.ResetHeadimg()
  9127. return nil
  9128. case contact.FieldSex:
  9129. m.ResetSex()
  9130. return nil
  9131. case contact.FieldStarrole:
  9132. m.ResetStarrole()
  9133. return nil
  9134. case contact.FieldDontseeit:
  9135. m.ResetDontseeit()
  9136. return nil
  9137. case contact.FieldDontseeme:
  9138. m.ResetDontseeme()
  9139. return nil
  9140. case contact.FieldLag:
  9141. m.ResetLag()
  9142. return nil
  9143. case contact.FieldGid:
  9144. m.ResetGid()
  9145. return nil
  9146. case contact.FieldGname:
  9147. m.ResetGname()
  9148. return nil
  9149. case contact.FieldV3:
  9150. m.ResetV3()
  9151. return nil
  9152. case contact.FieldOrganizationID:
  9153. m.ResetOrganizationID()
  9154. return nil
  9155. }
  9156. return fmt.Errorf("unknown Contact field %s", name)
  9157. }
  9158. // AddedEdges returns all edge names that were set/added in this mutation.
  9159. func (m *ContactMutation) AddedEdges() []string {
  9160. edges := make([]string, 0, 2)
  9161. if m.contact_relationships != nil {
  9162. edges = append(edges, contact.EdgeContactRelationships)
  9163. }
  9164. if m.contact_messages != nil {
  9165. edges = append(edges, contact.EdgeContactMessages)
  9166. }
  9167. return edges
  9168. }
  9169. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9170. // name in this mutation.
  9171. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9172. switch name {
  9173. case contact.EdgeContactRelationships:
  9174. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9175. for id := range m.contact_relationships {
  9176. ids = append(ids, id)
  9177. }
  9178. return ids
  9179. case contact.EdgeContactMessages:
  9180. ids := make([]ent.Value, 0, len(m.contact_messages))
  9181. for id := range m.contact_messages {
  9182. ids = append(ids, id)
  9183. }
  9184. return ids
  9185. }
  9186. return nil
  9187. }
  9188. // RemovedEdges returns all edge names that were removed in this mutation.
  9189. func (m *ContactMutation) RemovedEdges() []string {
  9190. edges := make([]string, 0, 2)
  9191. if m.removedcontact_relationships != nil {
  9192. edges = append(edges, contact.EdgeContactRelationships)
  9193. }
  9194. if m.removedcontact_messages != nil {
  9195. edges = append(edges, contact.EdgeContactMessages)
  9196. }
  9197. return edges
  9198. }
  9199. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9200. // the given name in this mutation.
  9201. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9202. switch name {
  9203. case contact.EdgeContactRelationships:
  9204. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9205. for id := range m.removedcontact_relationships {
  9206. ids = append(ids, id)
  9207. }
  9208. return ids
  9209. case contact.EdgeContactMessages:
  9210. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9211. for id := range m.removedcontact_messages {
  9212. ids = append(ids, id)
  9213. }
  9214. return ids
  9215. }
  9216. return nil
  9217. }
  9218. // ClearedEdges returns all edge names that were cleared in this mutation.
  9219. func (m *ContactMutation) ClearedEdges() []string {
  9220. edges := make([]string, 0, 2)
  9221. if m.clearedcontact_relationships {
  9222. edges = append(edges, contact.EdgeContactRelationships)
  9223. }
  9224. if m.clearedcontact_messages {
  9225. edges = append(edges, contact.EdgeContactMessages)
  9226. }
  9227. return edges
  9228. }
  9229. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9230. // was cleared in this mutation.
  9231. func (m *ContactMutation) EdgeCleared(name string) bool {
  9232. switch name {
  9233. case contact.EdgeContactRelationships:
  9234. return m.clearedcontact_relationships
  9235. case contact.EdgeContactMessages:
  9236. return m.clearedcontact_messages
  9237. }
  9238. return false
  9239. }
  9240. // ClearEdge clears the value of the edge with the given name. It returns an error
  9241. // if that edge is not defined in the schema.
  9242. func (m *ContactMutation) ClearEdge(name string) error {
  9243. switch name {
  9244. }
  9245. return fmt.Errorf("unknown Contact unique edge %s", name)
  9246. }
  9247. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9248. // It returns an error if the edge is not defined in the schema.
  9249. func (m *ContactMutation) ResetEdge(name string) error {
  9250. switch name {
  9251. case contact.EdgeContactRelationships:
  9252. m.ResetContactRelationships()
  9253. return nil
  9254. case contact.EdgeContactMessages:
  9255. m.ResetContactMessages()
  9256. return nil
  9257. }
  9258. return fmt.Errorf("unknown Contact edge %s", name)
  9259. }
  9260. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  9261. type EmployeeMutation struct {
  9262. config
  9263. op Op
  9264. typ string
  9265. id *uint64
  9266. created_at *time.Time
  9267. updated_at *time.Time
  9268. deleted_at *time.Time
  9269. title *string
  9270. avatar *string
  9271. tags *string
  9272. hire_count *int
  9273. addhire_count *int
  9274. service_count *int
  9275. addservice_count *int
  9276. achievement_count *int
  9277. addachievement_count *int
  9278. intro *string
  9279. estimate *string
  9280. skill *string
  9281. ability_type *string
  9282. scene *string
  9283. switch_in *string
  9284. video_url *string
  9285. organization_id *uint64
  9286. addorganization_id *int64
  9287. category_id *uint64
  9288. addcategory_id *int64
  9289. api_base *string
  9290. api_key *string
  9291. ai_info *string
  9292. is_vip *int
  9293. addis_vip *int
  9294. chat_url *string
  9295. clearedFields map[string]struct{}
  9296. em_work_experiences map[uint64]struct{}
  9297. removedem_work_experiences map[uint64]struct{}
  9298. clearedem_work_experiences bool
  9299. em_tutorial map[uint64]struct{}
  9300. removedem_tutorial map[uint64]struct{}
  9301. clearedem_tutorial bool
  9302. done bool
  9303. oldValue func(context.Context) (*Employee, error)
  9304. predicates []predicate.Employee
  9305. }
  9306. var _ ent.Mutation = (*EmployeeMutation)(nil)
  9307. // employeeOption allows management of the mutation configuration using functional options.
  9308. type employeeOption func(*EmployeeMutation)
  9309. // newEmployeeMutation creates new mutation for the Employee entity.
  9310. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  9311. m := &EmployeeMutation{
  9312. config: c,
  9313. op: op,
  9314. typ: TypeEmployee,
  9315. clearedFields: make(map[string]struct{}),
  9316. }
  9317. for _, opt := range opts {
  9318. opt(m)
  9319. }
  9320. return m
  9321. }
  9322. // withEmployeeID sets the ID field of the mutation.
  9323. func withEmployeeID(id uint64) employeeOption {
  9324. return func(m *EmployeeMutation) {
  9325. var (
  9326. err error
  9327. once sync.Once
  9328. value *Employee
  9329. )
  9330. m.oldValue = func(ctx context.Context) (*Employee, error) {
  9331. once.Do(func() {
  9332. if m.done {
  9333. err = errors.New("querying old values post mutation is not allowed")
  9334. } else {
  9335. value, err = m.Client().Employee.Get(ctx, id)
  9336. }
  9337. })
  9338. return value, err
  9339. }
  9340. m.id = &id
  9341. }
  9342. }
  9343. // withEmployee sets the old Employee of the mutation.
  9344. func withEmployee(node *Employee) employeeOption {
  9345. return func(m *EmployeeMutation) {
  9346. m.oldValue = func(context.Context) (*Employee, error) {
  9347. return node, nil
  9348. }
  9349. m.id = &node.ID
  9350. }
  9351. }
  9352. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9353. // executed in a transaction (ent.Tx), a transactional client is returned.
  9354. func (m EmployeeMutation) Client() *Client {
  9355. client := &Client{config: m.config}
  9356. client.init()
  9357. return client
  9358. }
  9359. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9360. // it returns an error otherwise.
  9361. func (m EmployeeMutation) Tx() (*Tx, error) {
  9362. if _, ok := m.driver.(*txDriver); !ok {
  9363. return nil, errors.New("ent: mutation is not running in a transaction")
  9364. }
  9365. tx := &Tx{config: m.config}
  9366. tx.init()
  9367. return tx, nil
  9368. }
  9369. // SetID sets the value of the id field. Note that this
  9370. // operation is only accepted on creation of Employee entities.
  9371. func (m *EmployeeMutation) SetID(id uint64) {
  9372. m.id = &id
  9373. }
  9374. // ID returns the ID value in the mutation. Note that the ID is only available
  9375. // if it was provided to the builder or after it was returned from the database.
  9376. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  9377. if m.id == nil {
  9378. return
  9379. }
  9380. return *m.id, true
  9381. }
  9382. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9383. // That means, if the mutation is applied within a transaction with an isolation level such
  9384. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9385. // or updated by the mutation.
  9386. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  9387. switch {
  9388. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9389. id, exists := m.ID()
  9390. if exists {
  9391. return []uint64{id}, nil
  9392. }
  9393. fallthrough
  9394. case m.op.Is(OpUpdate | OpDelete):
  9395. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  9396. default:
  9397. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9398. }
  9399. }
  9400. // SetCreatedAt sets the "created_at" field.
  9401. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  9402. m.created_at = &t
  9403. }
  9404. // CreatedAt returns the value of the "created_at" field in the mutation.
  9405. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  9406. v := m.created_at
  9407. if v == nil {
  9408. return
  9409. }
  9410. return *v, true
  9411. }
  9412. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  9413. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9415. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9416. if !m.op.Is(OpUpdateOne) {
  9417. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9418. }
  9419. if m.id == nil || m.oldValue == nil {
  9420. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9421. }
  9422. oldValue, err := m.oldValue(ctx)
  9423. if err != nil {
  9424. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9425. }
  9426. return oldValue.CreatedAt, nil
  9427. }
  9428. // ResetCreatedAt resets all changes to the "created_at" field.
  9429. func (m *EmployeeMutation) ResetCreatedAt() {
  9430. m.created_at = nil
  9431. }
  9432. // SetUpdatedAt sets the "updated_at" field.
  9433. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  9434. m.updated_at = &t
  9435. }
  9436. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9437. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  9438. v := m.updated_at
  9439. if v == nil {
  9440. return
  9441. }
  9442. return *v, true
  9443. }
  9444. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  9445. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9447. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9448. if !m.op.Is(OpUpdateOne) {
  9449. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9450. }
  9451. if m.id == nil || m.oldValue == nil {
  9452. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9453. }
  9454. oldValue, err := m.oldValue(ctx)
  9455. if err != nil {
  9456. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9457. }
  9458. return oldValue.UpdatedAt, nil
  9459. }
  9460. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9461. func (m *EmployeeMutation) ResetUpdatedAt() {
  9462. m.updated_at = nil
  9463. }
  9464. // SetDeletedAt sets the "deleted_at" field.
  9465. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  9466. m.deleted_at = &t
  9467. }
  9468. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9469. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  9470. v := m.deleted_at
  9471. if v == nil {
  9472. return
  9473. }
  9474. return *v, true
  9475. }
  9476. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  9477. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9479. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9480. if !m.op.Is(OpUpdateOne) {
  9481. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9482. }
  9483. if m.id == nil || m.oldValue == nil {
  9484. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9485. }
  9486. oldValue, err := m.oldValue(ctx)
  9487. if err != nil {
  9488. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9489. }
  9490. return oldValue.DeletedAt, nil
  9491. }
  9492. // ClearDeletedAt clears the value of the "deleted_at" field.
  9493. func (m *EmployeeMutation) ClearDeletedAt() {
  9494. m.deleted_at = nil
  9495. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  9496. }
  9497. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9498. func (m *EmployeeMutation) DeletedAtCleared() bool {
  9499. _, ok := m.clearedFields[employee.FieldDeletedAt]
  9500. return ok
  9501. }
  9502. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9503. func (m *EmployeeMutation) ResetDeletedAt() {
  9504. m.deleted_at = nil
  9505. delete(m.clearedFields, employee.FieldDeletedAt)
  9506. }
  9507. // SetTitle sets the "title" field.
  9508. func (m *EmployeeMutation) SetTitle(s string) {
  9509. m.title = &s
  9510. }
  9511. // Title returns the value of the "title" field in the mutation.
  9512. func (m *EmployeeMutation) Title() (r string, exists bool) {
  9513. v := m.title
  9514. if v == nil {
  9515. return
  9516. }
  9517. return *v, true
  9518. }
  9519. // OldTitle returns the old "title" field's value of the Employee entity.
  9520. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9522. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  9523. if !m.op.Is(OpUpdateOne) {
  9524. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  9525. }
  9526. if m.id == nil || m.oldValue == nil {
  9527. return v, errors.New("OldTitle requires an ID field in the mutation")
  9528. }
  9529. oldValue, err := m.oldValue(ctx)
  9530. if err != nil {
  9531. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  9532. }
  9533. return oldValue.Title, nil
  9534. }
  9535. // ResetTitle resets all changes to the "title" field.
  9536. func (m *EmployeeMutation) ResetTitle() {
  9537. m.title = nil
  9538. }
  9539. // SetAvatar sets the "avatar" field.
  9540. func (m *EmployeeMutation) SetAvatar(s string) {
  9541. m.avatar = &s
  9542. }
  9543. // Avatar returns the value of the "avatar" field in the mutation.
  9544. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  9545. v := m.avatar
  9546. if v == nil {
  9547. return
  9548. }
  9549. return *v, true
  9550. }
  9551. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  9552. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9554. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  9555. if !m.op.Is(OpUpdateOne) {
  9556. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  9557. }
  9558. if m.id == nil || m.oldValue == nil {
  9559. return v, errors.New("OldAvatar requires an ID field in the mutation")
  9560. }
  9561. oldValue, err := m.oldValue(ctx)
  9562. if err != nil {
  9563. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  9564. }
  9565. return oldValue.Avatar, nil
  9566. }
  9567. // ResetAvatar resets all changes to the "avatar" field.
  9568. func (m *EmployeeMutation) ResetAvatar() {
  9569. m.avatar = nil
  9570. }
  9571. // SetTags sets the "tags" field.
  9572. func (m *EmployeeMutation) SetTags(s string) {
  9573. m.tags = &s
  9574. }
  9575. // Tags returns the value of the "tags" field in the mutation.
  9576. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  9577. v := m.tags
  9578. if v == nil {
  9579. return
  9580. }
  9581. return *v, true
  9582. }
  9583. // OldTags returns the old "tags" field's value of the Employee entity.
  9584. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9586. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  9587. if !m.op.Is(OpUpdateOne) {
  9588. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  9589. }
  9590. if m.id == nil || m.oldValue == nil {
  9591. return v, errors.New("OldTags requires an ID field in the mutation")
  9592. }
  9593. oldValue, err := m.oldValue(ctx)
  9594. if err != nil {
  9595. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  9596. }
  9597. return oldValue.Tags, nil
  9598. }
  9599. // ResetTags resets all changes to the "tags" field.
  9600. func (m *EmployeeMutation) ResetTags() {
  9601. m.tags = nil
  9602. }
  9603. // SetHireCount sets the "hire_count" field.
  9604. func (m *EmployeeMutation) SetHireCount(i int) {
  9605. m.hire_count = &i
  9606. m.addhire_count = nil
  9607. }
  9608. // HireCount returns the value of the "hire_count" field in the mutation.
  9609. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  9610. v := m.hire_count
  9611. if v == nil {
  9612. return
  9613. }
  9614. return *v, true
  9615. }
  9616. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  9617. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9619. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  9620. if !m.op.Is(OpUpdateOne) {
  9621. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  9622. }
  9623. if m.id == nil || m.oldValue == nil {
  9624. return v, errors.New("OldHireCount requires an ID field in the mutation")
  9625. }
  9626. oldValue, err := m.oldValue(ctx)
  9627. if err != nil {
  9628. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  9629. }
  9630. return oldValue.HireCount, nil
  9631. }
  9632. // AddHireCount adds i to the "hire_count" field.
  9633. func (m *EmployeeMutation) AddHireCount(i int) {
  9634. if m.addhire_count != nil {
  9635. *m.addhire_count += i
  9636. } else {
  9637. m.addhire_count = &i
  9638. }
  9639. }
  9640. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  9641. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  9642. v := m.addhire_count
  9643. if v == nil {
  9644. return
  9645. }
  9646. return *v, true
  9647. }
  9648. // ResetHireCount resets all changes to the "hire_count" field.
  9649. func (m *EmployeeMutation) ResetHireCount() {
  9650. m.hire_count = nil
  9651. m.addhire_count = nil
  9652. }
  9653. // SetServiceCount sets the "service_count" field.
  9654. func (m *EmployeeMutation) SetServiceCount(i int) {
  9655. m.service_count = &i
  9656. m.addservice_count = nil
  9657. }
  9658. // ServiceCount returns the value of the "service_count" field in the mutation.
  9659. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  9660. v := m.service_count
  9661. if v == nil {
  9662. return
  9663. }
  9664. return *v, true
  9665. }
  9666. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  9667. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9669. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  9670. if !m.op.Is(OpUpdateOne) {
  9671. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  9672. }
  9673. if m.id == nil || m.oldValue == nil {
  9674. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  9675. }
  9676. oldValue, err := m.oldValue(ctx)
  9677. if err != nil {
  9678. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  9679. }
  9680. return oldValue.ServiceCount, nil
  9681. }
  9682. // AddServiceCount adds i to the "service_count" field.
  9683. func (m *EmployeeMutation) AddServiceCount(i int) {
  9684. if m.addservice_count != nil {
  9685. *m.addservice_count += i
  9686. } else {
  9687. m.addservice_count = &i
  9688. }
  9689. }
  9690. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  9691. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  9692. v := m.addservice_count
  9693. if v == nil {
  9694. return
  9695. }
  9696. return *v, true
  9697. }
  9698. // ResetServiceCount resets all changes to the "service_count" field.
  9699. func (m *EmployeeMutation) ResetServiceCount() {
  9700. m.service_count = nil
  9701. m.addservice_count = nil
  9702. }
  9703. // SetAchievementCount sets the "achievement_count" field.
  9704. func (m *EmployeeMutation) SetAchievementCount(i int) {
  9705. m.achievement_count = &i
  9706. m.addachievement_count = nil
  9707. }
  9708. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  9709. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  9710. v := m.achievement_count
  9711. if v == nil {
  9712. return
  9713. }
  9714. return *v, true
  9715. }
  9716. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  9717. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9719. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  9720. if !m.op.Is(OpUpdateOne) {
  9721. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  9722. }
  9723. if m.id == nil || m.oldValue == nil {
  9724. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  9725. }
  9726. oldValue, err := m.oldValue(ctx)
  9727. if err != nil {
  9728. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  9729. }
  9730. return oldValue.AchievementCount, nil
  9731. }
  9732. // AddAchievementCount adds i to the "achievement_count" field.
  9733. func (m *EmployeeMutation) AddAchievementCount(i int) {
  9734. if m.addachievement_count != nil {
  9735. *m.addachievement_count += i
  9736. } else {
  9737. m.addachievement_count = &i
  9738. }
  9739. }
  9740. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  9741. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  9742. v := m.addachievement_count
  9743. if v == nil {
  9744. return
  9745. }
  9746. return *v, true
  9747. }
  9748. // ResetAchievementCount resets all changes to the "achievement_count" field.
  9749. func (m *EmployeeMutation) ResetAchievementCount() {
  9750. m.achievement_count = nil
  9751. m.addachievement_count = nil
  9752. }
  9753. // SetIntro sets the "intro" field.
  9754. func (m *EmployeeMutation) SetIntro(s string) {
  9755. m.intro = &s
  9756. }
  9757. // Intro returns the value of the "intro" field in the mutation.
  9758. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  9759. v := m.intro
  9760. if v == nil {
  9761. return
  9762. }
  9763. return *v, true
  9764. }
  9765. // OldIntro returns the old "intro" field's value of the Employee entity.
  9766. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9768. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9769. if !m.op.Is(OpUpdateOne) {
  9770. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9771. }
  9772. if m.id == nil || m.oldValue == nil {
  9773. return v, errors.New("OldIntro requires an ID field in the mutation")
  9774. }
  9775. oldValue, err := m.oldValue(ctx)
  9776. if err != nil {
  9777. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9778. }
  9779. return oldValue.Intro, nil
  9780. }
  9781. // ResetIntro resets all changes to the "intro" field.
  9782. func (m *EmployeeMutation) ResetIntro() {
  9783. m.intro = nil
  9784. }
  9785. // SetEstimate sets the "estimate" field.
  9786. func (m *EmployeeMutation) SetEstimate(s string) {
  9787. m.estimate = &s
  9788. }
  9789. // Estimate returns the value of the "estimate" field in the mutation.
  9790. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9791. v := m.estimate
  9792. if v == nil {
  9793. return
  9794. }
  9795. return *v, true
  9796. }
  9797. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9798. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9800. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9801. if !m.op.Is(OpUpdateOne) {
  9802. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9803. }
  9804. if m.id == nil || m.oldValue == nil {
  9805. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9806. }
  9807. oldValue, err := m.oldValue(ctx)
  9808. if err != nil {
  9809. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9810. }
  9811. return oldValue.Estimate, nil
  9812. }
  9813. // ResetEstimate resets all changes to the "estimate" field.
  9814. func (m *EmployeeMutation) ResetEstimate() {
  9815. m.estimate = nil
  9816. }
  9817. // SetSkill sets the "skill" field.
  9818. func (m *EmployeeMutation) SetSkill(s string) {
  9819. m.skill = &s
  9820. }
  9821. // Skill returns the value of the "skill" field in the mutation.
  9822. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9823. v := m.skill
  9824. if v == nil {
  9825. return
  9826. }
  9827. return *v, true
  9828. }
  9829. // OldSkill returns the old "skill" field's value of the Employee entity.
  9830. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9832. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9833. if !m.op.Is(OpUpdateOne) {
  9834. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9835. }
  9836. if m.id == nil || m.oldValue == nil {
  9837. return v, errors.New("OldSkill requires an ID field in the mutation")
  9838. }
  9839. oldValue, err := m.oldValue(ctx)
  9840. if err != nil {
  9841. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9842. }
  9843. return oldValue.Skill, nil
  9844. }
  9845. // ResetSkill resets all changes to the "skill" field.
  9846. func (m *EmployeeMutation) ResetSkill() {
  9847. m.skill = nil
  9848. }
  9849. // SetAbilityType sets the "ability_type" field.
  9850. func (m *EmployeeMutation) SetAbilityType(s string) {
  9851. m.ability_type = &s
  9852. }
  9853. // AbilityType returns the value of the "ability_type" field in the mutation.
  9854. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9855. v := m.ability_type
  9856. if v == nil {
  9857. return
  9858. }
  9859. return *v, true
  9860. }
  9861. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9862. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9864. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9865. if !m.op.Is(OpUpdateOne) {
  9866. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9867. }
  9868. if m.id == nil || m.oldValue == nil {
  9869. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9870. }
  9871. oldValue, err := m.oldValue(ctx)
  9872. if err != nil {
  9873. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9874. }
  9875. return oldValue.AbilityType, nil
  9876. }
  9877. // ResetAbilityType resets all changes to the "ability_type" field.
  9878. func (m *EmployeeMutation) ResetAbilityType() {
  9879. m.ability_type = nil
  9880. }
  9881. // SetScene sets the "scene" field.
  9882. func (m *EmployeeMutation) SetScene(s string) {
  9883. m.scene = &s
  9884. }
  9885. // Scene returns the value of the "scene" field in the mutation.
  9886. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9887. v := m.scene
  9888. if v == nil {
  9889. return
  9890. }
  9891. return *v, true
  9892. }
  9893. // OldScene returns the old "scene" field's value of the Employee entity.
  9894. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9896. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9897. if !m.op.Is(OpUpdateOne) {
  9898. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9899. }
  9900. if m.id == nil || m.oldValue == nil {
  9901. return v, errors.New("OldScene requires an ID field in the mutation")
  9902. }
  9903. oldValue, err := m.oldValue(ctx)
  9904. if err != nil {
  9905. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9906. }
  9907. return oldValue.Scene, nil
  9908. }
  9909. // ResetScene resets all changes to the "scene" field.
  9910. func (m *EmployeeMutation) ResetScene() {
  9911. m.scene = nil
  9912. }
  9913. // SetSwitchIn sets the "switch_in" field.
  9914. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9915. m.switch_in = &s
  9916. }
  9917. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9918. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9919. v := m.switch_in
  9920. if v == nil {
  9921. return
  9922. }
  9923. return *v, true
  9924. }
  9925. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9926. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9928. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9929. if !m.op.Is(OpUpdateOne) {
  9930. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9931. }
  9932. if m.id == nil || m.oldValue == nil {
  9933. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9934. }
  9935. oldValue, err := m.oldValue(ctx)
  9936. if err != nil {
  9937. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9938. }
  9939. return oldValue.SwitchIn, nil
  9940. }
  9941. // ResetSwitchIn resets all changes to the "switch_in" field.
  9942. func (m *EmployeeMutation) ResetSwitchIn() {
  9943. m.switch_in = nil
  9944. }
  9945. // SetVideoURL sets the "video_url" field.
  9946. func (m *EmployeeMutation) SetVideoURL(s string) {
  9947. m.video_url = &s
  9948. }
  9949. // VideoURL returns the value of the "video_url" field in the mutation.
  9950. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9951. v := m.video_url
  9952. if v == nil {
  9953. return
  9954. }
  9955. return *v, true
  9956. }
  9957. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9958. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9960. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9961. if !m.op.Is(OpUpdateOne) {
  9962. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9963. }
  9964. if m.id == nil || m.oldValue == nil {
  9965. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9966. }
  9967. oldValue, err := m.oldValue(ctx)
  9968. if err != nil {
  9969. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9970. }
  9971. return oldValue.VideoURL, nil
  9972. }
  9973. // ResetVideoURL resets all changes to the "video_url" field.
  9974. func (m *EmployeeMutation) ResetVideoURL() {
  9975. m.video_url = nil
  9976. }
  9977. // SetOrganizationID sets the "organization_id" field.
  9978. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9979. m.organization_id = &u
  9980. m.addorganization_id = nil
  9981. }
  9982. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9983. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9984. v := m.organization_id
  9985. if v == nil {
  9986. return
  9987. }
  9988. return *v, true
  9989. }
  9990. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9991. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9993. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9994. if !m.op.Is(OpUpdateOne) {
  9995. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9996. }
  9997. if m.id == nil || m.oldValue == nil {
  9998. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9999. }
  10000. oldValue, err := m.oldValue(ctx)
  10001. if err != nil {
  10002. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10003. }
  10004. return oldValue.OrganizationID, nil
  10005. }
  10006. // AddOrganizationID adds u to the "organization_id" field.
  10007. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  10008. if m.addorganization_id != nil {
  10009. *m.addorganization_id += u
  10010. } else {
  10011. m.addorganization_id = &u
  10012. }
  10013. }
  10014. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10015. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  10016. v := m.addorganization_id
  10017. if v == nil {
  10018. return
  10019. }
  10020. return *v, true
  10021. }
  10022. // ResetOrganizationID resets all changes to the "organization_id" field.
  10023. func (m *EmployeeMutation) ResetOrganizationID() {
  10024. m.organization_id = nil
  10025. m.addorganization_id = nil
  10026. }
  10027. // SetCategoryID sets the "category_id" field.
  10028. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  10029. m.category_id = &u
  10030. m.addcategory_id = nil
  10031. }
  10032. // CategoryID returns the value of the "category_id" field in the mutation.
  10033. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  10034. v := m.category_id
  10035. if v == nil {
  10036. return
  10037. }
  10038. return *v, true
  10039. }
  10040. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  10041. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10043. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  10044. if !m.op.Is(OpUpdateOne) {
  10045. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  10046. }
  10047. if m.id == nil || m.oldValue == nil {
  10048. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  10049. }
  10050. oldValue, err := m.oldValue(ctx)
  10051. if err != nil {
  10052. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  10053. }
  10054. return oldValue.CategoryID, nil
  10055. }
  10056. // AddCategoryID adds u to the "category_id" field.
  10057. func (m *EmployeeMutation) AddCategoryID(u int64) {
  10058. if m.addcategory_id != nil {
  10059. *m.addcategory_id += u
  10060. } else {
  10061. m.addcategory_id = &u
  10062. }
  10063. }
  10064. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  10065. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  10066. v := m.addcategory_id
  10067. if v == nil {
  10068. return
  10069. }
  10070. return *v, true
  10071. }
  10072. // ResetCategoryID resets all changes to the "category_id" field.
  10073. func (m *EmployeeMutation) ResetCategoryID() {
  10074. m.category_id = nil
  10075. m.addcategory_id = nil
  10076. }
  10077. // SetAPIBase sets the "api_base" field.
  10078. func (m *EmployeeMutation) SetAPIBase(s string) {
  10079. m.api_base = &s
  10080. }
  10081. // APIBase returns the value of the "api_base" field in the mutation.
  10082. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  10083. v := m.api_base
  10084. if v == nil {
  10085. return
  10086. }
  10087. return *v, true
  10088. }
  10089. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  10090. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10092. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  10093. if !m.op.Is(OpUpdateOne) {
  10094. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  10095. }
  10096. if m.id == nil || m.oldValue == nil {
  10097. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  10098. }
  10099. oldValue, err := m.oldValue(ctx)
  10100. if err != nil {
  10101. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  10102. }
  10103. return oldValue.APIBase, nil
  10104. }
  10105. // ResetAPIBase resets all changes to the "api_base" field.
  10106. func (m *EmployeeMutation) ResetAPIBase() {
  10107. m.api_base = nil
  10108. }
  10109. // SetAPIKey sets the "api_key" field.
  10110. func (m *EmployeeMutation) SetAPIKey(s string) {
  10111. m.api_key = &s
  10112. }
  10113. // APIKey returns the value of the "api_key" field in the mutation.
  10114. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  10115. v := m.api_key
  10116. if v == nil {
  10117. return
  10118. }
  10119. return *v, true
  10120. }
  10121. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  10122. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10124. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  10125. if !m.op.Is(OpUpdateOne) {
  10126. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  10127. }
  10128. if m.id == nil || m.oldValue == nil {
  10129. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  10130. }
  10131. oldValue, err := m.oldValue(ctx)
  10132. if err != nil {
  10133. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  10134. }
  10135. return oldValue.APIKey, nil
  10136. }
  10137. // ResetAPIKey resets all changes to the "api_key" field.
  10138. func (m *EmployeeMutation) ResetAPIKey() {
  10139. m.api_key = nil
  10140. }
  10141. // SetAiInfo sets the "ai_info" field.
  10142. func (m *EmployeeMutation) SetAiInfo(s string) {
  10143. m.ai_info = &s
  10144. }
  10145. // AiInfo returns the value of the "ai_info" field in the mutation.
  10146. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  10147. v := m.ai_info
  10148. if v == nil {
  10149. return
  10150. }
  10151. return *v, true
  10152. }
  10153. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  10154. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10156. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  10157. if !m.op.Is(OpUpdateOne) {
  10158. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  10159. }
  10160. if m.id == nil || m.oldValue == nil {
  10161. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  10162. }
  10163. oldValue, err := m.oldValue(ctx)
  10164. if err != nil {
  10165. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  10166. }
  10167. return oldValue.AiInfo, nil
  10168. }
  10169. // ClearAiInfo clears the value of the "ai_info" field.
  10170. func (m *EmployeeMutation) ClearAiInfo() {
  10171. m.ai_info = nil
  10172. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  10173. }
  10174. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  10175. func (m *EmployeeMutation) AiInfoCleared() bool {
  10176. _, ok := m.clearedFields[employee.FieldAiInfo]
  10177. return ok
  10178. }
  10179. // ResetAiInfo resets all changes to the "ai_info" field.
  10180. func (m *EmployeeMutation) ResetAiInfo() {
  10181. m.ai_info = nil
  10182. delete(m.clearedFields, employee.FieldAiInfo)
  10183. }
  10184. // SetIsVip sets the "is_vip" field.
  10185. func (m *EmployeeMutation) SetIsVip(i int) {
  10186. m.is_vip = &i
  10187. m.addis_vip = nil
  10188. }
  10189. // IsVip returns the value of the "is_vip" field in the mutation.
  10190. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  10191. v := m.is_vip
  10192. if v == nil {
  10193. return
  10194. }
  10195. return *v, true
  10196. }
  10197. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  10198. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10200. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  10201. if !m.op.Is(OpUpdateOne) {
  10202. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  10203. }
  10204. if m.id == nil || m.oldValue == nil {
  10205. return v, errors.New("OldIsVip requires an ID field in the mutation")
  10206. }
  10207. oldValue, err := m.oldValue(ctx)
  10208. if err != nil {
  10209. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  10210. }
  10211. return oldValue.IsVip, nil
  10212. }
  10213. // AddIsVip adds i to the "is_vip" field.
  10214. func (m *EmployeeMutation) AddIsVip(i int) {
  10215. if m.addis_vip != nil {
  10216. *m.addis_vip += i
  10217. } else {
  10218. m.addis_vip = &i
  10219. }
  10220. }
  10221. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  10222. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  10223. v := m.addis_vip
  10224. if v == nil {
  10225. return
  10226. }
  10227. return *v, true
  10228. }
  10229. // ResetIsVip resets all changes to the "is_vip" field.
  10230. func (m *EmployeeMutation) ResetIsVip() {
  10231. m.is_vip = nil
  10232. m.addis_vip = nil
  10233. }
  10234. // SetChatURL sets the "chat_url" field.
  10235. func (m *EmployeeMutation) SetChatURL(s string) {
  10236. m.chat_url = &s
  10237. }
  10238. // ChatURL returns the value of the "chat_url" field in the mutation.
  10239. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  10240. v := m.chat_url
  10241. if v == nil {
  10242. return
  10243. }
  10244. return *v, true
  10245. }
  10246. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  10247. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10249. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  10250. if !m.op.Is(OpUpdateOne) {
  10251. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  10252. }
  10253. if m.id == nil || m.oldValue == nil {
  10254. return v, errors.New("OldChatURL requires an ID field in the mutation")
  10255. }
  10256. oldValue, err := m.oldValue(ctx)
  10257. if err != nil {
  10258. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  10259. }
  10260. return oldValue.ChatURL, nil
  10261. }
  10262. // ResetChatURL resets all changes to the "chat_url" field.
  10263. func (m *EmployeeMutation) ResetChatURL() {
  10264. m.chat_url = nil
  10265. }
  10266. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  10267. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  10268. if m.em_work_experiences == nil {
  10269. m.em_work_experiences = make(map[uint64]struct{})
  10270. }
  10271. for i := range ids {
  10272. m.em_work_experiences[ids[i]] = struct{}{}
  10273. }
  10274. }
  10275. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  10276. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  10277. m.clearedem_work_experiences = true
  10278. }
  10279. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  10280. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  10281. return m.clearedem_work_experiences
  10282. }
  10283. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  10284. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  10285. if m.removedem_work_experiences == nil {
  10286. m.removedem_work_experiences = make(map[uint64]struct{})
  10287. }
  10288. for i := range ids {
  10289. delete(m.em_work_experiences, ids[i])
  10290. m.removedem_work_experiences[ids[i]] = struct{}{}
  10291. }
  10292. }
  10293. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  10294. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  10295. for id := range m.removedem_work_experiences {
  10296. ids = append(ids, id)
  10297. }
  10298. return
  10299. }
  10300. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  10301. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  10302. for id := range m.em_work_experiences {
  10303. ids = append(ids, id)
  10304. }
  10305. return
  10306. }
  10307. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  10308. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  10309. m.em_work_experiences = nil
  10310. m.clearedem_work_experiences = false
  10311. m.removedem_work_experiences = nil
  10312. }
  10313. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  10314. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  10315. if m.em_tutorial == nil {
  10316. m.em_tutorial = make(map[uint64]struct{})
  10317. }
  10318. for i := range ids {
  10319. m.em_tutorial[ids[i]] = struct{}{}
  10320. }
  10321. }
  10322. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  10323. func (m *EmployeeMutation) ClearEmTutorial() {
  10324. m.clearedem_tutorial = true
  10325. }
  10326. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  10327. func (m *EmployeeMutation) EmTutorialCleared() bool {
  10328. return m.clearedem_tutorial
  10329. }
  10330. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  10331. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  10332. if m.removedem_tutorial == nil {
  10333. m.removedem_tutorial = make(map[uint64]struct{})
  10334. }
  10335. for i := range ids {
  10336. delete(m.em_tutorial, ids[i])
  10337. m.removedem_tutorial[ids[i]] = struct{}{}
  10338. }
  10339. }
  10340. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  10341. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  10342. for id := range m.removedem_tutorial {
  10343. ids = append(ids, id)
  10344. }
  10345. return
  10346. }
  10347. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  10348. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  10349. for id := range m.em_tutorial {
  10350. ids = append(ids, id)
  10351. }
  10352. return
  10353. }
  10354. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  10355. func (m *EmployeeMutation) ResetEmTutorial() {
  10356. m.em_tutorial = nil
  10357. m.clearedem_tutorial = false
  10358. m.removedem_tutorial = nil
  10359. }
  10360. // Where appends a list predicates to the EmployeeMutation builder.
  10361. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  10362. m.predicates = append(m.predicates, ps...)
  10363. }
  10364. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  10365. // users can use type-assertion to append predicates that do not depend on any generated package.
  10366. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  10367. p := make([]predicate.Employee, len(ps))
  10368. for i := range ps {
  10369. p[i] = ps[i]
  10370. }
  10371. m.Where(p...)
  10372. }
  10373. // Op returns the operation name.
  10374. func (m *EmployeeMutation) Op() Op {
  10375. return m.op
  10376. }
  10377. // SetOp allows setting the mutation operation.
  10378. func (m *EmployeeMutation) SetOp(op Op) {
  10379. m.op = op
  10380. }
  10381. // Type returns the node type of this mutation (Employee).
  10382. func (m *EmployeeMutation) Type() string {
  10383. return m.typ
  10384. }
  10385. // Fields returns all fields that were changed during this mutation. Note that in
  10386. // order to get all numeric fields that were incremented/decremented, call
  10387. // AddedFields().
  10388. func (m *EmployeeMutation) Fields() []string {
  10389. fields := make([]string, 0, 23)
  10390. if m.created_at != nil {
  10391. fields = append(fields, employee.FieldCreatedAt)
  10392. }
  10393. if m.updated_at != nil {
  10394. fields = append(fields, employee.FieldUpdatedAt)
  10395. }
  10396. if m.deleted_at != nil {
  10397. fields = append(fields, employee.FieldDeletedAt)
  10398. }
  10399. if m.title != nil {
  10400. fields = append(fields, employee.FieldTitle)
  10401. }
  10402. if m.avatar != nil {
  10403. fields = append(fields, employee.FieldAvatar)
  10404. }
  10405. if m.tags != nil {
  10406. fields = append(fields, employee.FieldTags)
  10407. }
  10408. if m.hire_count != nil {
  10409. fields = append(fields, employee.FieldHireCount)
  10410. }
  10411. if m.service_count != nil {
  10412. fields = append(fields, employee.FieldServiceCount)
  10413. }
  10414. if m.achievement_count != nil {
  10415. fields = append(fields, employee.FieldAchievementCount)
  10416. }
  10417. if m.intro != nil {
  10418. fields = append(fields, employee.FieldIntro)
  10419. }
  10420. if m.estimate != nil {
  10421. fields = append(fields, employee.FieldEstimate)
  10422. }
  10423. if m.skill != nil {
  10424. fields = append(fields, employee.FieldSkill)
  10425. }
  10426. if m.ability_type != nil {
  10427. fields = append(fields, employee.FieldAbilityType)
  10428. }
  10429. if m.scene != nil {
  10430. fields = append(fields, employee.FieldScene)
  10431. }
  10432. if m.switch_in != nil {
  10433. fields = append(fields, employee.FieldSwitchIn)
  10434. }
  10435. if m.video_url != nil {
  10436. fields = append(fields, employee.FieldVideoURL)
  10437. }
  10438. if m.organization_id != nil {
  10439. fields = append(fields, employee.FieldOrganizationID)
  10440. }
  10441. if m.category_id != nil {
  10442. fields = append(fields, employee.FieldCategoryID)
  10443. }
  10444. if m.api_base != nil {
  10445. fields = append(fields, employee.FieldAPIBase)
  10446. }
  10447. if m.api_key != nil {
  10448. fields = append(fields, employee.FieldAPIKey)
  10449. }
  10450. if m.ai_info != nil {
  10451. fields = append(fields, employee.FieldAiInfo)
  10452. }
  10453. if m.is_vip != nil {
  10454. fields = append(fields, employee.FieldIsVip)
  10455. }
  10456. if m.chat_url != nil {
  10457. fields = append(fields, employee.FieldChatURL)
  10458. }
  10459. return fields
  10460. }
  10461. // Field returns the value of a field with the given name. The second boolean
  10462. // return value indicates that this field was not set, or was not defined in the
  10463. // schema.
  10464. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  10465. switch name {
  10466. case employee.FieldCreatedAt:
  10467. return m.CreatedAt()
  10468. case employee.FieldUpdatedAt:
  10469. return m.UpdatedAt()
  10470. case employee.FieldDeletedAt:
  10471. return m.DeletedAt()
  10472. case employee.FieldTitle:
  10473. return m.Title()
  10474. case employee.FieldAvatar:
  10475. return m.Avatar()
  10476. case employee.FieldTags:
  10477. return m.Tags()
  10478. case employee.FieldHireCount:
  10479. return m.HireCount()
  10480. case employee.FieldServiceCount:
  10481. return m.ServiceCount()
  10482. case employee.FieldAchievementCount:
  10483. return m.AchievementCount()
  10484. case employee.FieldIntro:
  10485. return m.Intro()
  10486. case employee.FieldEstimate:
  10487. return m.Estimate()
  10488. case employee.FieldSkill:
  10489. return m.Skill()
  10490. case employee.FieldAbilityType:
  10491. return m.AbilityType()
  10492. case employee.FieldScene:
  10493. return m.Scene()
  10494. case employee.FieldSwitchIn:
  10495. return m.SwitchIn()
  10496. case employee.FieldVideoURL:
  10497. return m.VideoURL()
  10498. case employee.FieldOrganizationID:
  10499. return m.OrganizationID()
  10500. case employee.FieldCategoryID:
  10501. return m.CategoryID()
  10502. case employee.FieldAPIBase:
  10503. return m.APIBase()
  10504. case employee.FieldAPIKey:
  10505. return m.APIKey()
  10506. case employee.FieldAiInfo:
  10507. return m.AiInfo()
  10508. case employee.FieldIsVip:
  10509. return m.IsVip()
  10510. case employee.FieldChatURL:
  10511. return m.ChatURL()
  10512. }
  10513. return nil, false
  10514. }
  10515. // OldField returns the old value of the field from the database. An error is
  10516. // returned if the mutation operation is not UpdateOne, or the query to the
  10517. // database failed.
  10518. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10519. switch name {
  10520. case employee.FieldCreatedAt:
  10521. return m.OldCreatedAt(ctx)
  10522. case employee.FieldUpdatedAt:
  10523. return m.OldUpdatedAt(ctx)
  10524. case employee.FieldDeletedAt:
  10525. return m.OldDeletedAt(ctx)
  10526. case employee.FieldTitle:
  10527. return m.OldTitle(ctx)
  10528. case employee.FieldAvatar:
  10529. return m.OldAvatar(ctx)
  10530. case employee.FieldTags:
  10531. return m.OldTags(ctx)
  10532. case employee.FieldHireCount:
  10533. return m.OldHireCount(ctx)
  10534. case employee.FieldServiceCount:
  10535. return m.OldServiceCount(ctx)
  10536. case employee.FieldAchievementCount:
  10537. return m.OldAchievementCount(ctx)
  10538. case employee.FieldIntro:
  10539. return m.OldIntro(ctx)
  10540. case employee.FieldEstimate:
  10541. return m.OldEstimate(ctx)
  10542. case employee.FieldSkill:
  10543. return m.OldSkill(ctx)
  10544. case employee.FieldAbilityType:
  10545. return m.OldAbilityType(ctx)
  10546. case employee.FieldScene:
  10547. return m.OldScene(ctx)
  10548. case employee.FieldSwitchIn:
  10549. return m.OldSwitchIn(ctx)
  10550. case employee.FieldVideoURL:
  10551. return m.OldVideoURL(ctx)
  10552. case employee.FieldOrganizationID:
  10553. return m.OldOrganizationID(ctx)
  10554. case employee.FieldCategoryID:
  10555. return m.OldCategoryID(ctx)
  10556. case employee.FieldAPIBase:
  10557. return m.OldAPIBase(ctx)
  10558. case employee.FieldAPIKey:
  10559. return m.OldAPIKey(ctx)
  10560. case employee.FieldAiInfo:
  10561. return m.OldAiInfo(ctx)
  10562. case employee.FieldIsVip:
  10563. return m.OldIsVip(ctx)
  10564. case employee.FieldChatURL:
  10565. return m.OldChatURL(ctx)
  10566. }
  10567. return nil, fmt.Errorf("unknown Employee field %s", name)
  10568. }
  10569. // SetField sets the value of a field with the given name. It returns an error if
  10570. // the field is not defined in the schema, or if the type mismatched the field
  10571. // type.
  10572. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  10573. switch name {
  10574. case employee.FieldCreatedAt:
  10575. v, ok := value.(time.Time)
  10576. if !ok {
  10577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10578. }
  10579. m.SetCreatedAt(v)
  10580. return nil
  10581. case employee.FieldUpdatedAt:
  10582. v, ok := value.(time.Time)
  10583. if !ok {
  10584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10585. }
  10586. m.SetUpdatedAt(v)
  10587. return nil
  10588. case employee.FieldDeletedAt:
  10589. v, ok := value.(time.Time)
  10590. if !ok {
  10591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10592. }
  10593. m.SetDeletedAt(v)
  10594. return nil
  10595. case employee.FieldTitle:
  10596. v, ok := value.(string)
  10597. if !ok {
  10598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10599. }
  10600. m.SetTitle(v)
  10601. return nil
  10602. case employee.FieldAvatar:
  10603. v, ok := value.(string)
  10604. if !ok {
  10605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10606. }
  10607. m.SetAvatar(v)
  10608. return nil
  10609. case employee.FieldTags:
  10610. v, ok := value.(string)
  10611. if !ok {
  10612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10613. }
  10614. m.SetTags(v)
  10615. return nil
  10616. case employee.FieldHireCount:
  10617. v, ok := value.(int)
  10618. if !ok {
  10619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10620. }
  10621. m.SetHireCount(v)
  10622. return nil
  10623. case employee.FieldServiceCount:
  10624. v, ok := value.(int)
  10625. if !ok {
  10626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10627. }
  10628. m.SetServiceCount(v)
  10629. return nil
  10630. case employee.FieldAchievementCount:
  10631. v, ok := value.(int)
  10632. if !ok {
  10633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10634. }
  10635. m.SetAchievementCount(v)
  10636. return nil
  10637. case employee.FieldIntro:
  10638. v, ok := value.(string)
  10639. if !ok {
  10640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10641. }
  10642. m.SetIntro(v)
  10643. return nil
  10644. case employee.FieldEstimate:
  10645. v, ok := value.(string)
  10646. if !ok {
  10647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10648. }
  10649. m.SetEstimate(v)
  10650. return nil
  10651. case employee.FieldSkill:
  10652. v, ok := value.(string)
  10653. if !ok {
  10654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10655. }
  10656. m.SetSkill(v)
  10657. return nil
  10658. case employee.FieldAbilityType:
  10659. v, ok := value.(string)
  10660. if !ok {
  10661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10662. }
  10663. m.SetAbilityType(v)
  10664. return nil
  10665. case employee.FieldScene:
  10666. v, ok := value.(string)
  10667. if !ok {
  10668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10669. }
  10670. m.SetScene(v)
  10671. return nil
  10672. case employee.FieldSwitchIn:
  10673. v, ok := value.(string)
  10674. if !ok {
  10675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10676. }
  10677. m.SetSwitchIn(v)
  10678. return nil
  10679. case employee.FieldVideoURL:
  10680. v, ok := value.(string)
  10681. if !ok {
  10682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10683. }
  10684. m.SetVideoURL(v)
  10685. return nil
  10686. case employee.FieldOrganizationID:
  10687. v, ok := value.(uint64)
  10688. if !ok {
  10689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10690. }
  10691. m.SetOrganizationID(v)
  10692. return nil
  10693. case employee.FieldCategoryID:
  10694. v, ok := value.(uint64)
  10695. if !ok {
  10696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10697. }
  10698. m.SetCategoryID(v)
  10699. return nil
  10700. case employee.FieldAPIBase:
  10701. v, ok := value.(string)
  10702. if !ok {
  10703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10704. }
  10705. m.SetAPIBase(v)
  10706. return nil
  10707. case employee.FieldAPIKey:
  10708. v, ok := value.(string)
  10709. if !ok {
  10710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10711. }
  10712. m.SetAPIKey(v)
  10713. return nil
  10714. case employee.FieldAiInfo:
  10715. v, ok := value.(string)
  10716. if !ok {
  10717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10718. }
  10719. m.SetAiInfo(v)
  10720. return nil
  10721. case employee.FieldIsVip:
  10722. v, ok := value.(int)
  10723. if !ok {
  10724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10725. }
  10726. m.SetIsVip(v)
  10727. return nil
  10728. case employee.FieldChatURL:
  10729. v, ok := value.(string)
  10730. if !ok {
  10731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10732. }
  10733. m.SetChatURL(v)
  10734. return nil
  10735. }
  10736. return fmt.Errorf("unknown Employee field %s", name)
  10737. }
  10738. // AddedFields returns all numeric fields that were incremented/decremented during
  10739. // this mutation.
  10740. func (m *EmployeeMutation) AddedFields() []string {
  10741. var fields []string
  10742. if m.addhire_count != nil {
  10743. fields = append(fields, employee.FieldHireCount)
  10744. }
  10745. if m.addservice_count != nil {
  10746. fields = append(fields, employee.FieldServiceCount)
  10747. }
  10748. if m.addachievement_count != nil {
  10749. fields = append(fields, employee.FieldAchievementCount)
  10750. }
  10751. if m.addorganization_id != nil {
  10752. fields = append(fields, employee.FieldOrganizationID)
  10753. }
  10754. if m.addcategory_id != nil {
  10755. fields = append(fields, employee.FieldCategoryID)
  10756. }
  10757. if m.addis_vip != nil {
  10758. fields = append(fields, employee.FieldIsVip)
  10759. }
  10760. return fields
  10761. }
  10762. // AddedField returns the numeric value that was incremented/decremented on a field
  10763. // with the given name. The second boolean return value indicates that this field
  10764. // was not set, or was not defined in the schema.
  10765. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  10766. switch name {
  10767. case employee.FieldHireCount:
  10768. return m.AddedHireCount()
  10769. case employee.FieldServiceCount:
  10770. return m.AddedServiceCount()
  10771. case employee.FieldAchievementCount:
  10772. return m.AddedAchievementCount()
  10773. case employee.FieldOrganizationID:
  10774. return m.AddedOrganizationID()
  10775. case employee.FieldCategoryID:
  10776. return m.AddedCategoryID()
  10777. case employee.FieldIsVip:
  10778. return m.AddedIsVip()
  10779. }
  10780. return nil, false
  10781. }
  10782. // AddField adds the value to the field with the given name. It returns an error if
  10783. // the field is not defined in the schema, or if the type mismatched the field
  10784. // type.
  10785. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  10786. switch name {
  10787. case employee.FieldHireCount:
  10788. v, ok := value.(int)
  10789. if !ok {
  10790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10791. }
  10792. m.AddHireCount(v)
  10793. return nil
  10794. case employee.FieldServiceCount:
  10795. v, ok := value.(int)
  10796. if !ok {
  10797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10798. }
  10799. m.AddServiceCount(v)
  10800. return nil
  10801. case employee.FieldAchievementCount:
  10802. v, ok := value.(int)
  10803. if !ok {
  10804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10805. }
  10806. m.AddAchievementCount(v)
  10807. return nil
  10808. case employee.FieldOrganizationID:
  10809. v, ok := value.(int64)
  10810. if !ok {
  10811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10812. }
  10813. m.AddOrganizationID(v)
  10814. return nil
  10815. case employee.FieldCategoryID:
  10816. v, ok := value.(int64)
  10817. if !ok {
  10818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10819. }
  10820. m.AddCategoryID(v)
  10821. return nil
  10822. case employee.FieldIsVip:
  10823. v, ok := value.(int)
  10824. if !ok {
  10825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10826. }
  10827. m.AddIsVip(v)
  10828. return nil
  10829. }
  10830. return fmt.Errorf("unknown Employee numeric field %s", name)
  10831. }
  10832. // ClearedFields returns all nullable fields that were cleared during this
  10833. // mutation.
  10834. func (m *EmployeeMutation) ClearedFields() []string {
  10835. var fields []string
  10836. if m.FieldCleared(employee.FieldDeletedAt) {
  10837. fields = append(fields, employee.FieldDeletedAt)
  10838. }
  10839. if m.FieldCleared(employee.FieldAiInfo) {
  10840. fields = append(fields, employee.FieldAiInfo)
  10841. }
  10842. return fields
  10843. }
  10844. // FieldCleared returns a boolean indicating if a field with the given name was
  10845. // cleared in this mutation.
  10846. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10847. _, ok := m.clearedFields[name]
  10848. return ok
  10849. }
  10850. // ClearField clears the value of the field with the given name. It returns an
  10851. // error if the field is not defined in the schema.
  10852. func (m *EmployeeMutation) ClearField(name string) error {
  10853. switch name {
  10854. case employee.FieldDeletedAt:
  10855. m.ClearDeletedAt()
  10856. return nil
  10857. case employee.FieldAiInfo:
  10858. m.ClearAiInfo()
  10859. return nil
  10860. }
  10861. return fmt.Errorf("unknown Employee nullable field %s", name)
  10862. }
  10863. // ResetField resets all changes in the mutation for the field with the given name.
  10864. // It returns an error if the field is not defined in the schema.
  10865. func (m *EmployeeMutation) ResetField(name string) error {
  10866. switch name {
  10867. case employee.FieldCreatedAt:
  10868. m.ResetCreatedAt()
  10869. return nil
  10870. case employee.FieldUpdatedAt:
  10871. m.ResetUpdatedAt()
  10872. return nil
  10873. case employee.FieldDeletedAt:
  10874. m.ResetDeletedAt()
  10875. return nil
  10876. case employee.FieldTitle:
  10877. m.ResetTitle()
  10878. return nil
  10879. case employee.FieldAvatar:
  10880. m.ResetAvatar()
  10881. return nil
  10882. case employee.FieldTags:
  10883. m.ResetTags()
  10884. return nil
  10885. case employee.FieldHireCount:
  10886. m.ResetHireCount()
  10887. return nil
  10888. case employee.FieldServiceCount:
  10889. m.ResetServiceCount()
  10890. return nil
  10891. case employee.FieldAchievementCount:
  10892. m.ResetAchievementCount()
  10893. return nil
  10894. case employee.FieldIntro:
  10895. m.ResetIntro()
  10896. return nil
  10897. case employee.FieldEstimate:
  10898. m.ResetEstimate()
  10899. return nil
  10900. case employee.FieldSkill:
  10901. m.ResetSkill()
  10902. return nil
  10903. case employee.FieldAbilityType:
  10904. m.ResetAbilityType()
  10905. return nil
  10906. case employee.FieldScene:
  10907. m.ResetScene()
  10908. return nil
  10909. case employee.FieldSwitchIn:
  10910. m.ResetSwitchIn()
  10911. return nil
  10912. case employee.FieldVideoURL:
  10913. m.ResetVideoURL()
  10914. return nil
  10915. case employee.FieldOrganizationID:
  10916. m.ResetOrganizationID()
  10917. return nil
  10918. case employee.FieldCategoryID:
  10919. m.ResetCategoryID()
  10920. return nil
  10921. case employee.FieldAPIBase:
  10922. m.ResetAPIBase()
  10923. return nil
  10924. case employee.FieldAPIKey:
  10925. m.ResetAPIKey()
  10926. return nil
  10927. case employee.FieldAiInfo:
  10928. m.ResetAiInfo()
  10929. return nil
  10930. case employee.FieldIsVip:
  10931. m.ResetIsVip()
  10932. return nil
  10933. case employee.FieldChatURL:
  10934. m.ResetChatURL()
  10935. return nil
  10936. }
  10937. return fmt.Errorf("unknown Employee field %s", name)
  10938. }
  10939. // AddedEdges returns all edge names that were set/added in this mutation.
  10940. func (m *EmployeeMutation) AddedEdges() []string {
  10941. edges := make([]string, 0, 2)
  10942. if m.em_work_experiences != nil {
  10943. edges = append(edges, employee.EdgeEmWorkExperiences)
  10944. }
  10945. if m.em_tutorial != nil {
  10946. edges = append(edges, employee.EdgeEmTutorial)
  10947. }
  10948. return edges
  10949. }
  10950. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10951. // name in this mutation.
  10952. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10953. switch name {
  10954. case employee.EdgeEmWorkExperiences:
  10955. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10956. for id := range m.em_work_experiences {
  10957. ids = append(ids, id)
  10958. }
  10959. return ids
  10960. case employee.EdgeEmTutorial:
  10961. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10962. for id := range m.em_tutorial {
  10963. ids = append(ids, id)
  10964. }
  10965. return ids
  10966. }
  10967. return nil
  10968. }
  10969. // RemovedEdges returns all edge names that were removed in this mutation.
  10970. func (m *EmployeeMutation) RemovedEdges() []string {
  10971. edges := make([]string, 0, 2)
  10972. if m.removedem_work_experiences != nil {
  10973. edges = append(edges, employee.EdgeEmWorkExperiences)
  10974. }
  10975. if m.removedem_tutorial != nil {
  10976. edges = append(edges, employee.EdgeEmTutorial)
  10977. }
  10978. return edges
  10979. }
  10980. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10981. // the given name in this mutation.
  10982. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10983. switch name {
  10984. case employee.EdgeEmWorkExperiences:
  10985. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10986. for id := range m.removedem_work_experiences {
  10987. ids = append(ids, id)
  10988. }
  10989. return ids
  10990. case employee.EdgeEmTutorial:
  10991. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10992. for id := range m.removedem_tutorial {
  10993. ids = append(ids, id)
  10994. }
  10995. return ids
  10996. }
  10997. return nil
  10998. }
  10999. // ClearedEdges returns all edge names that were cleared in this mutation.
  11000. func (m *EmployeeMutation) ClearedEdges() []string {
  11001. edges := make([]string, 0, 2)
  11002. if m.clearedem_work_experiences {
  11003. edges = append(edges, employee.EdgeEmWorkExperiences)
  11004. }
  11005. if m.clearedem_tutorial {
  11006. edges = append(edges, employee.EdgeEmTutorial)
  11007. }
  11008. return edges
  11009. }
  11010. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11011. // was cleared in this mutation.
  11012. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  11013. switch name {
  11014. case employee.EdgeEmWorkExperiences:
  11015. return m.clearedem_work_experiences
  11016. case employee.EdgeEmTutorial:
  11017. return m.clearedem_tutorial
  11018. }
  11019. return false
  11020. }
  11021. // ClearEdge clears the value of the edge with the given name. It returns an error
  11022. // if that edge is not defined in the schema.
  11023. func (m *EmployeeMutation) ClearEdge(name string) error {
  11024. switch name {
  11025. }
  11026. return fmt.Errorf("unknown Employee unique edge %s", name)
  11027. }
  11028. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11029. // It returns an error if the edge is not defined in the schema.
  11030. func (m *EmployeeMutation) ResetEdge(name string) error {
  11031. switch name {
  11032. case employee.EdgeEmWorkExperiences:
  11033. m.ResetEmWorkExperiences()
  11034. return nil
  11035. case employee.EdgeEmTutorial:
  11036. m.ResetEmTutorial()
  11037. return nil
  11038. }
  11039. return fmt.Errorf("unknown Employee edge %s", name)
  11040. }
  11041. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  11042. type EmployeeConfigMutation struct {
  11043. config
  11044. op Op
  11045. typ string
  11046. id *uint64
  11047. created_at *time.Time
  11048. updated_at *time.Time
  11049. deleted_at *time.Time
  11050. stype *string
  11051. title *string
  11052. photo *string
  11053. organization_id *uint64
  11054. addorganization_id *int64
  11055. clearedFields map[string]struct{}
  11056. done bool
  11057. oldValue func(context.Context) (*EmployeeConfig, error)
  11058. predicates []predicate.EmployeeConfig
  11059. }
  11060. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  11061. // employeeconfigOption allows management of the mutation configuration using functional options.
  11062. type employeeconfigOption func(*EmployeeConfigMutation)
  11063. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  11064. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  11065. m := &EmployeeConfigMutation{
  11066. config: c,
  11067. op: op,
  11068. typ: TypeEmployeeConfig,
  11069. clearedFields: make(map[string]struct{}),
  11070. }
  11071. for _, opt := range opts {
  11072. opt(m)
  11073. }
  11074. return m
  11075. }
  11076. // withEmployeeConfigID sets the ID field of the mutation.
  11077. func withEmployeeConfigID(id uint64) employeeconfigOption {
  11078. return func(m *EmployeeConfigMutation) {
  11079. var (
  11080. err error
  11081. once sync.Once
  11082. value *EmployeeConfig
  11083. )
  11084. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  11085. once.Do(func() {
  11086. if m.done {
  11087. err = errors.New("querying old values post mutation is not allowed")
  11088. } else {
  11089. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  11090. }
  11091. })
  11092. return value, err
  11093. }
  11094. m.id = &id
  11095. }
  11096. }
  11097. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  11098. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  11099. return func(m *EmployeeConfigMutation) {
  11100. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  11101. return node, nil
  11102. }
  11103. m.id = &node.ID
  11104. }
  11105. }
  11106. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11107. // executed in a transaction (ent.Tx), a transactional client is returned.
  11108. func (m EmployeeConfigMutation) Client() *Client {
  11109. client := &Client{config: m.config}
  11110. client.init()
  11111. return client
  11112. }
  11113. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11114. // it returns an error otherwise.
  11115. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  11116. if _, ok := m.driver.(*txDriver); !ok {
  11117. return nil, errors.New("ent: mutation is not running in a transaction")
  11118. }
  11119. tx := &Tx{config: m.config}
  11120. tx.init()
  11121. return tx, nil
  11122. }
  11123. // SetID sets the value of the id field. Note that this
  11124. // operation is only accepted on creation of EmployeeConfig entities.
  11125. func (m *EmployeeConfigMutation) SetID(id uint64) {
  11126. m.id = &id
  11127. }
  11128. // ID returns the ID value in the mutation. Note that the ID is only available
  11129. // if it was provided to the builder or after it was returned from the database.
  11130. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  11131. if m.id == nil {
  11132. return
  11133. }
  11134. return *m.id, true
  11135. }
  11136. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11137. // That means, if the mutation is applied within a transaction with an isolation level such
  11138. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11139. // or updated by the mutation.
  11140. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  11141. switch {
  11142. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11143. id, exists := m.ID()
  11144. if exists {
  11145. return []uint64{id}, nil
  11146. }
  11147. fallthrough
  11148. case m.op.Is(OpUpdate | OpDelete):
  11149. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  11150. default:
  11151. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11152. }
  11153. }
  11154. // SetCreatedAt sets the "created_at" field.
  11155. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  11156. m.created_at = &t
  11157. }
  11158. // CreatedAt returns the value of the "created_at" field in the mutation.
  11159. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  11160. v := m.created_at
  11161. if v == nil {
  11162. return
  11163. }
  11164. return *v, true
  11165. }
  11166. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  11167. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11169. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11170. if !m.op.Is(OpUpdateOne) {
  11171. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11172. }
  11173. if m.id == nil || m.oldValue == nil {
  11174. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11175. }
  11176. oldValue, err := m.oldValue(ctx)
  11177. if err != nil {
  11178. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11179. }
  11180. return oldValue.CreatedAt, nil
  11181. }
  11182. // ResetCreatedAt resets all changes to the "created_at" field.
  11183. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  11184. m.created_at = nil
  11185. }
  11186. // SetUpdatedAt sets the "updated_at" field.
  11187. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  11188. m.updated_at = &t
  11189. }
  11190. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11191. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  11192. v := m.updated_at
  11193. if v == nil {
  11194. return
  11195. }
  11196. return *v, true
  11197. }
  11198. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  11199. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11201. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11202. if !m.op.Is(OpUpdateOne) {
  11203. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11204. }
  11205. if m.id == nil || m.oldValue == nil {
  11206. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11207. }
  11208. oldValue, err := m.oldValue(ctx)
  11209. if err != nil {
  11210. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11211. }
  11212. return oldValue.UpdatedAt, nil
  11213. }
  11214. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11215. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  11216. m.updated_at = nil
  11217. }
  11218. // SetDeletedAt sets the "deleted_at" field.
  11219. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  11220. m.deleted_at = &t
  11221. }
  11222. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11223. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  11224. v := m.deleted_at
  11225. if v == nil {
  11226. return
  11227. }
  11228. return *v, true
  11229. }
  11230. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  11231. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11233. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11234. if !m.op.Is(OpUpdateOne) {
  11235. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11236. }
  11237. if m.id == nil || m.oldValue == nil {
  11238. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11239. }
  11240. oldValue, err := m.oldValue(ctx)
  11241. if err != nil {
  11242. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11243. }
  11244. return oldValue.DeletedAt, nil
  11245. }
  11246. // ClearDeletedAt clears the value of the "deleted_at" field.
  11247. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  11248. m.deleted_at = nil
  11249. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  11250. }
  11251. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11252. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  11253. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  11254. return ok
  11255. }
  11256. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11257. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  11258. m.deleted_at = nil
  11259. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  11260. }
  11261. // SetStype sets the "stype" field.
  11262. func (m *EmployeeConfigMutation) SetStype(s string) {
  11263. m.stype = &s
  11264. }
  11265. // Stype returns the value of the "stype" field in the mutation.
  11266. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  11267. v := m.stype
  11268. if v == nil {
  11269. return
  11270. }
  11271. return *v, true
  11272. }
  11273. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  11274. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11276. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  11277. if !m.op.Is(OpUpdateOne) {
  11278. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  11279. }
  11280. if m.id == nil || m.oldValue == nil {
  11281. return v, errors.New("OldStype requires an ID field in the mutation")
  11282. }
  11283. oldValue, err := m.oldValue(ctx)
  11284. if err != nil {
  11285. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  11286. }
  11287. return oldValue.Stype, nil
  11288. }
  11289. // ResetStype resets all changes to the "stype" field.
  11290. func (m *EmployeeConfigMutation) ResetStype() {
  11291. m.stype = nil
  11292. }
  11293. // SetTitle sets the "title" field.
  11294. func (m *EmployeeConfigMutation) SetTitle(s string) {
  11295. m.title = &s
  11296. }
  11297. // Title returns the value of the "title" field in the mutation.
  11298. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  11299. v := m.title
  11300. if v == nil {
  11301. return
  11302. }
  11303. return *v, true
  11304. }
  11305. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  11306. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11308. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  11309. if !m.op.Is(OpUpdateOne) {
  11310. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11311. }
  11312. if m.id == nil || m.oldValue == nil {
  11313. return v, errors.New("OldTitle requires an ID field in the mutation")
  11314. }
  11315. oldValue, err := m.oldValue(ctx)
  11316. if err != nil {
  11317. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11318. }
  11319. return oldValue.Title, nil
  11320. }
  11321. // ResetTitle resets all changes to the "title" field.
  11322. func (m *EmployeeConfigMutation) ResetTitle() {
  11323. m.title = nil
  11324. }
  11325. // SetPhoto sets the "photo" field.
  11326. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  11327. m.photo = &s
  11328. }
  11329. // Photo returns the value of the "photo" field in the mutation.
  11330. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  11331. v := m.photo
  11332. if v == nil {
  11333. return
  11334. }
  11335. return *v, true
  11336. }
  11337. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  11338. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11340. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  11341. if !m.op.Is(OpUpdateOne) {
  11342. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  11343. }
  11344. if m.id == nil || m.oldValue == nil {
  11345. return v, errors.New("OldPhoto requires an ID field in the mutation")
  11346. }
  11347. oldValue, err := m.oldValue(ctx)
  11348. if err != nil {
  11349. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  11350. }
  11351. return oldValue.Photo, nil
  11352. }
  11353. // ResetPhoto resets all changes to the "photo" field.
  11354. func (m *EmployeeConfigMutation) ResetPhoto() {
  11355. m.photo = nil
  11356. }
  11357. // SetOrganizationID sets the "organization_id" field.
  11358. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  11359. m.organization_id = &u
  11360. m.addorganization_id = nil
  11361. }
  11362. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11363. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  11364. v := m.organization_id
  11365. if v == nil {
  11366. return
  11367. }
  11368. return *v, true
  11369. }
  11370. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  11371. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11373. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11374. if !m.op.Is(OpUpdateOne) {
  11375. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11376. }
  11377. if m.id == nil || m.oldValue == nil {
  11378. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11379. }
  11380. oldValue, err := m.oldValue(ctx)
  11381. if err != nil {
  11382. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11383. }
  11384. return oldValue.OrganizationID, nil
  11385. }
  11386. // AddOrganizationID adds u to the "organization_id" field.
  11387. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  11388. if m.addorganization_id != nil {
  11389. *m.addorganization_id += u
  11390. } else {
  11391. m.addorganization_id = &u
  11392. }
  11393. }
  11394. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11395. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  11396. v := m.addorganization_id
  11397. if v == nil {
  11398. return
  11399. }
  11400. return *v, true
  11401. }
  11402. // ClearOrganizationID clears the value of the "organization_id" field.
  11403. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  11404. m.organization_id = nil
  11405. m.addorganization_id = nil
  11406. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  11407. }
  11408. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11409. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  11410. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  11411. return ok
  11412. }
  11413. // ResetOrganizationID resets all changes to the "organization_id" field.
  11414. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  11415. m.organization_id = nil
  11416. m.addorganization_id = nil
  11417. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  11418. }
  11419. // Where appends a list predicates to the EmployeeConfigMutation builder.
  11420. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  11421. m.predicates = append(m.predicates, ps...)
  11422. }
  11423. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  11424. // users can use type-assertion to append predicates that do not depend on any generated package.
  11425. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  11426. p := make([]predicate.EmployeeConfig, len(ps))
  11427. for i := range ps {
  11428. p[i] = ps[i]
  11429. }
  11430. m.Where(p...)
  11431. }
  11432. // Op returns the operation name.
  11433. func (m *EmployeeConfigMutation) Op() Op {
  11434. return m.op
  11435. }
  11436. // SetOp allows setting the mutation operation.
  11437. func (m *EmployeeConfigMutation) SetOp(op Op) {
  11438. m.op = op
  11439. }
  11440. // Type returns the node type of this mutation (EmployeeConfig).
  11441. func (m *EmployeeConfigMutation) Type() string {
  11442. return m.typ
  11443. }
  11444. // Fields returns all fields that were changed during this mutation. Note that in
  11445. // order to get all numeric fields that were incremented/decremented, call
  11446. // AddedFields().
  11447. func (m *EmployeeConfigMutation) Fields() []string {
  11448. fields := make([]string, 0, 7)
  11449. if m.created_at != nil {
  11450. fields = append(fields, employeeconfig.FieldCreatedAt)
  11451. }
  11452. if m.updated_at != nil {
  11453. fields = append(fields, employeeconfig.FieldUpdatedAt)
  11454. }
  11455. if m.deleted_at != nil {
  11456. fields = append(fields, employeeconfig.FieldDeletedAt)
  11457. }
  11458. if m.stype != nil {
  11459. fields = append(fields, employeeconfig.FieldStype)
  11460. }
  11461. if m.title != nil {
  11462. fields = append(fields, employeeconfig.FieldTitle)
  11463. }
  11464. if m.photo != nil {
  11465. fields = append(fields, employeeconfig.FieldPhoto)
  11466. }
  11467. if m.organization_id != nil {
  11468. fields = append(fields, employeeconfig.FieldOrganizationID)
  11469. }
  11470. return fields
  11471. }
  11472. // Field returns the value of a field with the given name. The second boolean
  11473. // return value indicates that this field was not set, or was not defined in the
  11474. // schema.
  11475. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  11476. switch name {
  11477. case employeeconfig.FieldCreatedAt:
  11478. return m.CreatedAt()
  11479. case employeeconfig.FieldUpdatedAt:
  11480. return m.UpdatedAt()
  11481. case employeeconfig.FieldDeletedAt:
  11482. return m.DeletedAt()
  11483. case employeeconfig.FieldStype:
  11484. return m.Stype()
  11485. case employeeconfig.FieldTitle:
  11486. return m.Title()
  11487. case employeeconfig.FieldPhoto:
  11488. return m.Photo()
  11489. case employeeconfig.FieldOrganizationID:
  11490. return m.OrganizationID()
  11491. }
  11492. return nil, false
  11493. }
  11494. // OldField returns the old value of the field from the database. An error is
  11495. // returned if the mutation operation is not UpdateOne, or the query to the
  11496. // database failed.
  11497. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11498. switch name {
  11499. case employeeconfig.FieldCreatedAt:
  11500. return m.OldCreatedAt(ctx)
  11501. case employeeconfig.FieldUpdatedAt:
  11502. return m.OldUpdatedAt(ctx)
  11503. case employeeconfig.FieldDeletedAt:
  11504. return m.OldDeletedAt(ctx)
  11505. case employeeconfig.FieldStype:
  11506. return m.OldStype(ctx)
  11507. case employeeconfig.FieldTitle:
  11508. return m.OldTitle(ctx)
  11509. case employeeconfig.FieldPhoto:
  11510. return m.OldPhoto(ctx)
  11511. case employeeconfig.FieldOrganizationID:
  11512. return m.OldOrganizationID(ctx)
  11513. }
  11514. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  11515. }
  11516. // SetField sets the value of a field with the given name. It returns an error if
  11517. // the field is not defined in the schema, or if the type mismatched the field
  11518. // type.
  11519. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  11520. switch name {
  11521. case employeeconfig.FieldCreatedAt:
  11522. v, ok := value.(time.Time)
  11523. if !ok {
  11524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11525. }
  11526. m.SetCreatedAt(v)
  11527. return nil
  11528. case employeeconfig.FieldUpdatedAt:
  11529. v, ok := value.(time.Time)
  11530. if !ok {
  11531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11532. }
  11533. m.SetUpdatedAt(v)
  11534. return nil
  11535. case employeeconfig.FieldDeletedAt:
  11536. v, ok := value.(time.Time)
  11537. if !ok {
  11538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11539. }
  11540. m.SetDeletedAt(v)
  11541. return nil
  11542. case employeeconfig.FieldStype:
  11543. v, ok := value.(string)
  11544. if !ok {
  11545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11546. }
  11547. m.SetStype(v)
  11548. return nil
  11549. case employeeconfig.FieldTitle:
  11550. v, ok := value.(string)
  11551. if !ok {
  11552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11553. }
  11554. m.SetTitle(v)
  11555. return nil
  11556. case employeeconfig.FieldPhoto:
  11557. v, ok := value.(string)
  11558. if !ok {
  11559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11560. }
  11561. m.SetPhoto(v)
  11562. return nil
  11563. case employeeconfig.FieldOrganizationID:
  11564. v, ok := value.(uint64)
  11565. if !ok {
  11566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11567. }
  11568. m.SetOrganizationID(v)
  11569. return nil
  11570. }
  11571. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  11572. }
  11573. // AddedFields returns all numeric fields that were incremented/decremented during
  11574. // this mutation.
  11575. func (m *EmployeeConfigMutation) AddedFields() []string {
  11576. var fields []string
  11577. if m.addorganization_id != nil {
  11578. fields = append(fields, employeeconfig.FieldOrganizationID)
  11579. }
  11580. return fields
  11581. }
  11582. // AddedField returns the numeric value that was incremented/decremented on a field
  11583. // with the given name. The second boolean return value indicates that this field
  11584. // was not set, or was not defined in the schema.
  11585. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  11586. switch name {
  11587. case employeeconfig.FieldOrganizationID:
  11588. return m.AddedOrganizationID()
  11589. }
  11590. return nil, false
  11591. }
  11592. // AddField adds the value to the field with the given name. It returns an error if
  11593. // the field is not defined in the schema, or if the type mismatched the field
  11594. // type.
  11595. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  11596. switch name {
  11597. case employeeconfig.FieldOrganizationID:
  11598. v, ok := value.(int64)
  11599. if !ok {
  11600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11601. }
  11602. m.AddOrganizationID(v)
  11603. return nil
  11604. }
  11605. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  11606. }
  11607. // ClearedFields returns all nullable fields that were cleared during this
  11608. // mutation.
  11609. func (m *EmployeeConfigMutation) ClearedFields() []string {
  11610. var fields []string
  11611. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  11612. fields = append(fields, employeeconfig.FieldDeletedAt)
  11613. }
  11614. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  11615. fields = append(fields, employeeconfig.FieldOrganizationID)
  11616. }
  11617. return fields
  11618. }
  11619. // FieldCleared returns a boolean indicating if a field with the given name was
  11620. // cleared in this mutation.
  11621. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  11622. _, ok := m.clearedFields[name]
  11623. return ok
  11624. }
  11625. // ClearField clears the value of the field with the given name. It returns an
  11626. // error if the field is not defined in the schema.
  11627. func (m *EmployeeConfigMutation) ClearField(name string) error {
  11628. switch name {
  11629. case employeeconfig.FieldDeletedAt:
  11630. m.ClearDeletedAt()
  11631. return nil
  11632. case employeeconfig.FieldOrganizationID:
  11633. m.ClearOrganizationID()
  11634. return nil
  11635. }
  11636. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  11637. }
  11638. // ResetField resets all changes in the mutation for the field with the given name.
  11639. // It returns an error if the field is not defined in the schema.
  11640. func (m *EmployeeConfigMutation) ResetField(name string) error {
  11641. switch name {
  11642. case employeeconfig.FieldCreatedAt:
  11643. m.ResetCreatedAt()
  11644. return nil
  11645. case employeeconfig.FieldUpdatedAt:
  11646. m.ResetUpdatedAt()
  11647. return nil
  11648. case employeeconfig.FieldDeletedAt:
  11649. m.ResetDeletedAt()
  11650. return nil
  11651. case employeeconfig.FieldStype:
  11652. m.ResetStype()
  11653. return nil
  11654. case employeeconfig.FieldTitle:
  11655. m.ResetTitle()
  11656. return nil
  11657. case employeeconfig.FieldPhoto:
  11658. m.ResetPhoto()
  11659. return nil
  11660. case employeeconfig.FieldOrganizationID:
  11661. m.ResetOrganizationID()
  11662. return nil
  11663. }
  11664. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  11665. }
  11666. // AddedEdges returns all edge names that were set/added in this mutation.
  11667. func (m *EmployeeConfigMutation) AddedEdges() []string {
  11668. edges := make([]string, 0, 0)
  11669. return edges
  11670. }
  11671. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11672. // name in this mutation.
  11673. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  11674. return nil
  11675. }
  11676. // RemovedEdges returns all edge names that were removed in this mutation.
  11677. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  11678. edges := make([]string, 0, 0)
  11679. return edges
  11680. }
  11681. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11682. // the given name in this mutation.
  11683. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  11684. return nil
  11685. }
  11686. // ClearedEdges returns all edge names that were cleared in this mutation.
  11687. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  11688. edges := make([]string, 0, 0)
  11689. return edges
  11690. }
  11691. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11692. // was cleared in this mutation.
  11693. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  11694. return false
  11695. }
  11696. // ClearEdge clears the value of the edge with the given name. It returns an error
  11697. // if that edge is not defined in the schema.
  11698. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  11699. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  11700. }
  11701. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11702. // It returns an error if the edge is not defined in the schema.
  11703. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  11704. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  11705. }
  11706. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  11707. type LabelMutation struct {
  11708. config
  11709. op Op
  11710. typ string
  11711. id *uint64
  11712. created_at *time.Time
  11713. updated_at *time.Time
  11714. status *uint8
  11715. addstatus *int8
  11716. _type *int
  11717. add_type *int
  11718. name *string
  11719. from *int
  11720. addfrom *int
  11721. mode *int
  11722. addmode *int
  11723. conditions *string
  11724. organization_id *uint64
  11725. addorganization_id *int64
  11726. clearedFields map[string]struct{}
  11727. label_relationships map[uint64]struct{}
  11728. removedlabel_relationships map[uint64]struct{}
  11729. clearedlabel_relationships bool
  11730. done bool
  11731. oldValue func(context.Context) (*Label, error)
  11732. predicates []predicate.Label
  11733. }
  11734. var _ ent.Mutation = (*LabelMutation)(nil)
  11735. // labelOption allows management of the mutation configuration using functional options.
  11736. type labelOption func(*LabelMutation)
  11737. // newLabelMutation creates new mutation for the Label entity.
  11738. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  11739. m := &LabelMutation{
  11740. config: c,
  11741. op: op,
  11742. typ: TypeLabel,
  11743. clearedFields: make(map[string]struct{}),
  11744. }
  11745. for _, opt := range opts {
  11746. opt(m)
  11747. }
  11748. return m
  11749. }
  11750. // withLabelID sets the ID field of the mutation.
  11751. func withLabelID(id uint64) labelOption {
  11752. return func(m *LabelMutation) {
  11753. var (
  11754. err error
  11755. once sync.Once
  11756. value *Label
  11757. )
  11758. m.oldValue = func(ctx context.Context) (*Label, error) {
  11759. once.Do(func() {
  11760. if m.done {
  11761. err = errors.New("querying old values post mutation is not allowed")
  11762. } else {
  11763. value, err = m.Client().Label.Get(ctx, id)
  11764. }
  11765. })
  11766. return value, err
  11767. }
  11768. m.id = &id
  11769. }
  11770. }
  11771. // withLabel sets the old Label of the mutation.
  11772. func withLabel(node *Label) labelOption {
  11773. return func(m *LabelMutation) {
  11774. m.oldValue = func(context.Context) (*Label, error) {
  11775. return node, nil
  11776. }
  11777. m.id = &node.ID
  11778. }
  11779. }
  11780. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11781. // executed in a transaction (ent.Tx), a transactional client is returned.
  11782. func (m LabelMutation) Client() *Client {
  11783. client := &Client{config: m.config}
  11784. client.init()
  11785. return client
  11786. }
  11787. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11788. // it returns an error otherwise.
  11789. func (m LabelMutation) Tx() (*Tx, error) {
  11790. if _, ok := m.driver.(*txDriver); !ok {
  11791. return nil, errors.New("ent: mutation is not running in a transaction")
  11792. }
  11793. tx := &Tx{config: m.config}
  11794. tx.init()
  11795. return tx, nil
  11796. }
  11797. // SetID sets the value of the id field. Note that this
  11798. // operation is only accepted on creation of Label entities.
  11799. func (m *LabelMutation) SetID(id uint64) {
  11800. m.id = &id
  11801. }
  11802. // ID returns the ID value in the mutation. Note that the ID is only available
  11803. // if it was provided to the builder or after it was returned from the database.
  11804. func (m *LabelMutation) ID() (id uint64, exists bool) {
  11805. if m.id == nil {
  11806. return
  11807. }
  11808. return *m.id, true
  11809. }
  11810. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11811. // That means, if the mutation is applied within a transaction with an isolation level such
  11812. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11813. // or updated by the mutation.
  11814. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11815. switch {
  11816. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11817. id, exists := m.ID()
  11818. if exists {
  11819. return []uint64{id}, nil
  11820. }
  11821. fallthrough
  11822. case m.op.Is(OpUpdate | OpDelete):
  11823. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11824. default:
  11825. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11826. }
  11827. }
  11828. // SetCreatedAt sets the "created_at" field.
  11829. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11830. m.created_at = &t
  11831. }
  11832. // CreatedAt returns the value of the "created_at" field in the mutation.
  11833. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11834. v := m.created_at
  11835. if v == nil {
  11836. return
  11837. }
  11838. return *v, true
  11839. }
  11840. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11841. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11843. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11844. if !m.op.Is(OpUpdateOne) {
  11845. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11846. }
  11847. if m.id == nil || m.oldValue == nil {
  11848. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11849. }
  11850. oldValue, err := m.oldValue(ctx)
  11851. if err != nil {
  11852. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11853. }
  11854. return oldValue.CreatedAt, nil
  11855. }
  11856. // ResetCreatedAt resets all changes to the "created_at" field.
  11857. func (m *LabelMutation) ResetCreatedAt() {
  11858. m.created_at = nil
  11859. }
  11860. // SetUpdatedAt sets the "updated_at" field.
  11861. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11862. m.updated_at = &t
  11863. }
  11864. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11865. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11866. v := m.updated_at
  11867. if v == nil {
  11868. return
  11869. }
  11870. return *v, true
  11871. }
  11872. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11873. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11875. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11876. if !m.op.Is(OpUpdateOne) {
  11877. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11878. }
  11879. if m.id == nil || m.oldValue == nil {
  11880. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11881. }
  11882. oldValue, err := m.oldValue(ctx)
  11883. if err != nil {
  11884. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11885. }
  11886. return oldValue.UpdatedAt, nil
  11887. }
  11888. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11889. func (m *LabelMutation) ResetUpdatedAt() {
  11890. m.updated_at = nil
  11891. }
  11892. // SetStatus sets the "status" field.
  11893. func (m *LabelMutation) SetStatus(u uint8) {
  11894. m.status = &u
  11895. m.addstatus = nil
  11896. }
  11897. // Status returns the value of the "status" field in the mutation.
  11898. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11899. v := m.status
  11900. if v == nil {
  11901. return
  11902. }
  11903. return *v, true
  11904. }
  11905. // OldStatus returns the old "status" field's value of the Label entity.
  11906. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11908. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11909. if !m.op.Is(OpUpdateOne) {
  11910. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11911. }
  11912. if m.id == nil || m.oldValue == nil {
  11913. return v, errors.New("OldStatus requires an ID field in the mutation")
  11914. }
  11915. oldValue, err := m.oldValue(ctx)
  11916. if err != nil {
  11917. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11918. }
  11919. return oldValue.Status, nil
  11920. }
  11921. // AddStatus adds u to the "status" field.
  11922. func (m *LabelMutation) AddStatus(u int8) {
  11923. if m.addstatus != nil {
  11924. *m.addstatus += u
  11925. } else {
  11926. m.addstatus = &u
  11927. }
  11928. }
  11929. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11930. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11931. v := m.addstatus
  11932. if v == nil {
  11933. return
  11934. }
  11935. return *v, true
  11936. }
  11937. // ClearStatus clears the value of the "status" field.
  11938. func (m *LabelMutation) ClearStatus() {
  11939. m.status = nil
  11940. m.addstatus = nil
  11941. m.clearedFields[label.FieldStatus] = struct{}{}
  11942. }
  11943. // StatusCleared returns if the "status" field was cleared in this mutation.
  11944. func (m *LabelMutation) StatusCleared() bool {
  11945. _, ok := m.clearedFields[label.FieldStatus]
  11946. return ok
  11947. }
  11948. // ResetStatus resets all changes to the "status" field.
  11949. func (m *LabelMutation) ResetStatus() {
  11950. m.status = nil
  11951. m.addstatus = nil
  11952. delete(m.clearedFields, label.FieldStatus)
  11953. }
  11954. // SetType sets the "type" field.
  11955. func (m *LabelMutation) SetType(i int) {
  11956. m._type = &i
  11957. m.add_type = nil
  11958. }
  11959. // GetType returns the value of the "type" field in the mutation.
  11960. func (m *LabelMutation) GetType() (r int, exists bool) {
  11961. v := m._type
  11962. if v == nil {
  11963. return
  11964. }
  11965. return *v, true
  11966. }
  11967. // OldType returns the old "type" field's value of the Label entity.
  11968. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11970. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11971. if !m.op.Is(OpUpdateOne) {
  11972. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11973. }
  11974. if m.id == nil || m.oldValue == nil {
  11975. return v, errors.New("OldType requires an ID field in the mutation")
  11976. }
  11977. oldValue, err := m.oldValue(ctx)
  11978. if err != nil {
  11979. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11980. }
  11981. return oldValue.Type, nil
  11982. }
  11983. // AddType adds i to the "type" field.
  11984. func (m *LabelMutation) AddType(i int) {
  11985. if m.add_type != nil {
  11986. *m.add_type += i
  11987. } else {
  11988. m.add_type = &i
  11989. }
  11990. }
  11991. // AddedType returns the value that was added to the "type" field in this mutation.
  11992. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11993. v := m.add_type
  11994. if v == nil {
  11995. return
  11996. }
  11997. return *v, true
  11998. }
  11999. // ResetType resets all changes to the "type" field.
  12000. func (m *LabelMutation) ResetType() {
  12001. m._type = nil
  12002. m.add_type = nil
  12003. }
  12004. // SetName sets the "name" field.
  12005. func (m *LabelMutation) SetName(s string) {
  12006. m.name = &s
  12007. }
  12008. // Name returns the value of the "name" field in the mutation.
  12009. func (m *LabelMutation) Name() (r string, exists bool) {
  12010. v := m.name
  12011. if v == nil {
  12012. return
  12013. }
  12014. return *v, true
  12015. }
  12016. // OldName returns the old "name" field's value of the Label entity.
  12017. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12019. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  12020. if !m.op.Is(OpUpdateOne) {
  12021. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12022. }
  12023. if m.id == nil || m.oldValue == nil {
  12024. return v, errors.New("OldName requires an ID field in the mutation")
  12025. }
  12026. oldValue, err := m.oldValue(ctx)
  12027. if err != nil {
  12028. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12029. }
  12030. return oldValue.Name, nil
  12031. }
  12032. // ResetName resets all changes to the "name" field.
  12033. func (m *LabelMutation) ResetName() {
  12034. m.name = nil
  12035. }
  12036. // SetFrom sets the "from" field.
  12037. func (m *LabelMutation) SetFrom(i int) {
  12038. m.from = &i
  12039. m.addfrom = nil
  12040. }
  12041. // From returns the value of the "from" field in the mutation.
  12042. func (m *LabelMutation) From() (r int, exists bool) {
  12043. v := m.from
  12044. if v == nil {
  12045. return
  12046. }
  12047. return *v, true
  12048. }
  12049. // OldFrom returns the old "from" field's value of the Label entity.
  12050. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12052. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  12053. if !m.op.Is(OpUpdateOne) {
  12054. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  12055. }
  12056. if m.id == nil || m.oldValue == nil {
  12057. return v, errors.New("OldFrom requires an ID field in the mutation")
  12058. }
  12059. oldValue, err := m.oldValue(ctx)
  12060. if err != nil {
  12061. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  12062. }
  12063. return oldValue.From, nil
  12064. }
  12065. // AddFrom adds i to the "from" field.
  12066. func (m *LabelMutation) AddFrom(i int) {
  12067. if m.addfrom != nil {
  12068. *m.addfrom += i
  12069. } else {
  12070. m.addfrom = &i
  12071. }
  12072. }
  12073. // AddedFrom returns the value that was added to the "from" field in this mutation.
  12074. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  12075. v := m.addfrom
  12076. if v == nil {
  12077. return
  12078. }
  12079. return *v, true
  12080. }
  12081. // ResetFrom resets all changes to the "from" field.
  12082. func (m *LabelMutation) ResetFrom() {
  12083. m.from = nil
  12084. m.addfrom = nil
  12085. }
  12086. // SetMode sets the "mode" field.
  12087. func (m *LabelMutation) SetMode(i int) {
  12088. m.mode = &i
  12089. m.addmode = nil
  12090. }
  12091. // Mode returns the value of the "mode" field in the mutation.
  12092. func (m *LabelMutation) Mode() (r int, exists bool) {
  12093. v := m.mode
  12094. if v == nil {
  12095. return
  12096. }
  12097. return *v, true
  12098. }
  12099. // OldMode returns the old "mode" field's value of the Label entity.
  12100. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12102. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  12103. if !m.op.Is(OpUpdateOne) {
  12104. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  12105. }
  12106. if m.id == nil || m.oldValue == nil {
  12107. return v, errors.New("OldMode requires an ID field in the mutation")
  12108. }
  12109. oldValue, err := m.oldValue(ctx)
  12110. if err != nil {
  12111. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  12112. }
  12113. return oldValue.Mode, nil
  12114. }
  12115. // AddMode adds i to the "mode" field.
  12116. func (m *LabelMutation) AddMode(i int) {
  12117. if m.addmode != nil {
  12118. *m.addmode += i
  12119. } else {
  12120. m.addmode = &i
  12121. }
  12122. }
  12123. // AddedMode returns the value that was added to the "mode" field in this mutation.
  12124. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  12125. v := m.addmode
  12126. if v == nil {
  12127. return
  12128. }
  12129. return *v, true
  12130. }
  12131. // ResetMode resets all changes to the "mode" field.
  12132. func (m *LabelMutation) ResetMode() {
  12133. m.mode = nil
  12134. m.addmode = nil
  12135. }
  12136. // SetConditions sets the "conditions" field.
  12137. func (m *LabelMutation) SetConditions(s string) {
  12138. m.conditions = &s
  12139. }
  12140. // Conditions returns the value of the "conditions" field in the mutation.
  12141. func (m *LabelMutation) Conditions() (r string, exists bool) {
  12142. v := m.conditions
  12143. if v == nil {
  12144. return
  12145. }
  12146. return *v, true
  12147. }
  12148. // OldConditions returns the old "conditions" field's value of the Label entity.
  12149. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12151. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  12152. if !m.op.Is(OpUpdateOne) {
  12153. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  12154. }
  12155. if m.id == nil || m.oldValue == nil {
  12156. return v, errors.New("OldConditions requires an ID field in the mutation")
  12157. }
  12158. oldValue, err := m.oldValue(ctx)
  12159. if err != nil {
  12160. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  12161. }
  12162. return oldValue.Conditions, nil
  12163. }
  12164. // ClearConditions clears the value of the "conditions" field.
  12165. func (m *LabelMutation) ClearConditions() {
  12166. m.conditions = nil
  12167. m.clearedFields[label.FieldConditions] = struct{}{}
  12168. }
  12169. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  12170. func (m *LabelMutation) ConditionsCleared() bool {
  12171. _, ok := m.clearedFields[label.FieldConditions]
  12172. return ok
  12173. }
  12174. // ResetConditions resets all changes to the "conditions" field.
  12175. func (m *LabelMutation) ResetConditions() {
  12176. m.conditions = nil
  12177. delete(m.clearedFields, label.FieldConditions)
  12178. }
  12179. // SetOrganizationID sets the "organization_id" field.
  12180. func (m *LabelMutation) SetOrganizationID(u uint64) {
  12181. m.organization_id = &u
  12182. m.addorganization_id = nil
  12183. }
  12184. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12185. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  12186. v := m.organization_id
  12187. if v == nil {
  12188. return
  12189. }
  12190. return *v, true
  12191. }
  12192. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  12193. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12195. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12196. if !m.op.Is(OpUpdateOne) {
  12197. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12198. }
  12199. if m.id == nil || m.oldValue == nil {
  12200. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12201. }
  12202. oldValue, err := m.oldValue(ctx)
  12203. if err != nil {
  12204. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12205. }
  12206. return oldValue.OrganizationID, nil
  12207. }
  12208. // AddOrganizationID adds u to the "organization_id" field.
  12209. func (m *LabelMutation) AddOrganizationID(u int64) {
  12210. if m.addorganization_id != nil {
  12211. *m.addorganization_id += u
  12212. } else {
  12213. m.addorganization_id = &u
  12214. }
  12215. }
  12216. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12217. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  12218. v := m.addorganization_id
  12219. if v == nil {
  12220. return
  12221. }
  12222. return *v, true
  12223. }
  12224. // ClearOrganizationID clears the value of the "organization_id" field.
  12225. func (m *LabelMutation) ClearOrganizationID() {
  12226. m.organization_id = nil
  12227. m.addorganization_id = nil
  12228. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  12229. }
  12230. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12231. func (m *LabelMutation) OrganizationIDCleared() bool {
  12232. _, ok := m.clearedFields[label.FieldOrganizationID]
  12233. return ok
  12234. }
  12235. // ResetOrganizationID resets all changes to the "organization_id" field.
  12236. func (m *LabelMutation) ResetOrganizationID() {
  12237. m.organization_id = nil
  12238. m.addorganization_id = nil
  12239. delete(m.clearedFields, label.FieldOrganizationID)
  12240. }
  12241. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  12242. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  12243. if m.label_relationships == nil {
  12244. m.label_relationships = make(map[uint64]struct{})
  12245. }
  12246. for i := range ids {
  12247. m.label_relationships[ids[i]] = struct{}{}
  12248. }
  12249. }
  12250. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  12251. func (m *LabelMutation) ClearLabelRelationships() {
  12252. m.clearedlabel_relationships = true
  12253. }
  12254. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  12255. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  12256. return m.clearedlabel_relationships
  12257. }
  12258. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  12259. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  12260. if m.removedlabel_relationships == nil {
  12261. m.removedlabel_relationships = make(map[uint64]struct{})
  12262. }
  12263. for i := range ids {
  12264. delete(m.label_relationships, ids[i])
  12265. m.removedlabel_relationships[ids[i]] = struct{}{}
  12266. }
  12267. }
  12268. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  12269. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  12270. for id := range m.removedlabel_relationships {
  12271. ids = append(ids, id)
  12272. }
  12273. return
  12274. }
  12275. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  12276. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  12277. for id := range m.label_relationships {
  12278. ids = append(ids, id)
  12279. }
  12280. return
  12281. }
  12282. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  12283. func (m *LabelMutation) ResetLabelRelationships() {
  12284. m.label_relationships = nil
  12285. m.clearedlabel_relationships = false
  12286. m.removedlabel_relationships = nil
  12287. }
  12288. // Where appends a list predicates to the LabelMutation builder.
  12289. func (m *LabelMutation) Where(ps ...predicate.Label) {
  12290. m.predicates = append(m.predicates, ps...)
  12291. }
  12292. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  12293. // users can use type-assertion to append predicates that do not depend on any generated package.
  12294. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  12295. p := make([]predicate.Label, len(ps))
  12296. for i := range ps {
  12297. p[i] = ps[i]
  12298. }
  12299. m.Where(p...)
  12300. }
  12301. // Op returns the operation name.
  12302. func (m *LabelMutation) Op() Op {
  12303. return m.op
  12304. }
  12305. // SetOp allows setting the mutation operation.
  12306. func (m *LabelMutation) SetOp(op Op) {
  12307. m.op = op
  12308. }
  12309. // Type returns the node type of this mutation (Label).
  12310. func (m *LabelMutation) Type() string {
  12311. return m.typ
  12312. }
  12313. // Fields returns all fields that were changed during this mutation. Note that in
  12314. // order to get all numeric fields that were incremented/decremented, call
  12315. // AddedFields().
  12316. func (m *LabelMutation) Fields() []string {
  12317. fields := make([]string, 0, 9)
  12318. if m.created_at != nil {
  12319. fields = append(fields, label.FieldCreatedAt)
  12320. }
  12321. if m.updated_at != nil {
  12322. fields = append(fields, label.FieldUpdatedAt)
  12323. }
  12324. if m.status != nil {
  12325. fields = append(fields, label.FieldStatus)
  12326. }
  12327. if m._type != nil {
  12328. fields = append(fields, label.FieldType)
  12329. }
  12330. if m.name != nil {
  12331. fields = append(fields, label.FieldName)
  12332. }
  12333. if m.from != nil {
  12334. fields = append(fields, label.FieldFrom)
  12335. }
  12336. if m.mode != nil {
  12337. fields = append(fields, label.FieldMode)
  12338. }
  12339. if m.conditions != nil {
  12340. fields = append(fields, label.FieldConditions)
  12341. }
  12342. if m.organization_id != nil {
  12343. fields = append(fields, label.FieldOrganizationID)
  12344. }
  12345. return fields
  12346. }
  12347. // Field returns the value of a field with the given name. The second boolean
  12348. // return value indicates that this field was not set, or was not defined in the
  12349. // schema.
  12350. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  12351. switch name {
  12352. case label.FieldCreatedAt:
  12353. return m.CreatedAt()
  12354. case label.FieldUpdatedAt:
  12355. return m.UpdatedAt()
  12356. case label.FieldStatus:
  12357. return m.Status()
  12358. case label.FieldType:
  12359. return m.GetType()
  12360. case label.FieldName:
  12361. return m.Name()
  12362. case label.FieldFrom:
  12363. return m.From()
  12364. case label.FieldMode:
  12365. return m.Mode()
  12366. case label.FieldConditions:
  12367. return m.Conditions()
  12368. case label.FieldOrganizationID:
  12369. return m.OrganizationID()
  12370. }
  12371. return nil, false
  12372. }
  12373. // OldField returns the old value of the field from the database. An error is
  12374. // returned if the mutation operation is not UpdateOne, or the query to the
  12375. // database failed.
  12376. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12377. switch name {
  12378. case label.FieldCreatedAt:
  12379. return m.OldCreatedAt(ctx)
  12380. case label.FieldUpdatedAt:
  12381. return m.OldUpdatedAt(ctx)
  12382. case label.FieldStatus:
  12383. return m.OldStatus(ctx)
  12384. case label.FieldType:
  12385. return m.OldType(ctx)
  12386. case label.FieldName:
  12387. return m.OldName(ctx)
  12388. case label.FieldFrom:
  12389. return m.OldFrom(ctx)
  12390. case label.FieldMode:
  12391. return m.OldMode(ctx)
  12392. case label.FieldConditions:
  12393. return m.OldConditions(ctx)
  12394. case label.FieldOrganizationID:
  12395. return m.OldOrganizationID(ctx)
  12396. }
  12397. return nil, fmt.Errorf("unknown Label field %s", name)
  12398. }
  12399. // SetField sets the value of a field with the given name. It returns an error if
  12400. // the field is not defined in the schema, or if the type mismatched the field
  12401. // type.
  12402. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  12403. switch name {
  12404. case label.FieldCreatedAt:
  12405. v, ok := value.(time.Time)
  12406. if !ok {
  12407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12408. }
  12409. m.SetCreatedAt(v)
  12410. return nil
  12411. case label.FieldUpdatedAt:
  12412. v, ok := value.(time.Time)
  12413. if !ok {
  12414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12415. }
  12416. m.SetUpdatedAt(v)
  12417. return nil
  12418. case label.FieldStatus:
  12419. v, ok := value.(uint8)
  12420. if !ok {
  12421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12422. }
  12423. m.SetStatus(v)
  12424. return nil
  12425. case label.FieldType:
  12426. v, ok := value.(int)
  12427. if !ok {
  12428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12429. }
  12430. m.SetType(v)
  12431. return nil
  12432. case label.FieldName:
  12433. v, ok := value.(string)
  12434. if !ok {
  12435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12436. }
  12437. m.SetName(v)
  12438. return nil
  12439. case label.FieldFrom:
  12440. v, ok := value.(int)
  12441. if !ok {
  12442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12443. }
  12444. m.SetFrom(v)
  12445. return nil
  12446. case label.FieldMode:
  12447. v, ok := value.(int)
  12448. if !ok {
  12449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12450. }
  12451. m.SetMode(v)
  12452. return nil
  12453. case label.FieldConditions:
  12454. v, ok := value.(string)
  12455. if !ok {
  12456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12457. }
  12458. m.SetConditions(v)
  12459. return nil
  12460. case label.FieldOrganizationID:
  12461. v, ok := value.(uint64)
  12462. if !ok {
  12463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12464. }
  12465. m.SetOrganizationID(v)
  12466. return nil
  12467. }
  12468. return fmt.Errorf("unknown Label field %s", name)
  12469. }
  12470. // AddedFields returns all numeric fields that were incremented/decremented during
  12471. // this mutation.
  12472. func (m *LabelMutation) AddedFields() []string {
  12473. var fields []string
  12474. if m.addstatus != nil {
  12475. fields = append(fields, label.FieldStatus)
  12476. }
  12477. if m.add_type != nil {
  12478. fields = append(fields, label.FieldType)
  12479. }
  12480. if m.addfrom != nil {
  12481. fields = append(fields, label.FieldFrom)
  12482. }
  12483. if m.addmode != nil {
  12484. fields = append(fields, label.FieldMode)
  12485. }
  12486. if m.addorganization_id != nil {
  12487. fields = append(fields, label.FieldOrganizationID)
  12488. }
  12489. return fields
  12490. }
  12491. // AddedField returns the numeric value that was incremented/decremented on a field
  12492. // with the given name. The second boolean return value indicates that this field
  12493. // was not set, or was not defined in the schema.
  12494. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  12495. switch name {
  12496. case label.FieldStatus:
  12497. return m.AddedStatus()
  12498. case label.FieldType:
  12499. return m.AddedType()
  12500. case label.FieldFrom:
  12501. return m.AddedFrom()
  12502. case label.FieldMode:
  12503. return m.AddedMode()
  12504. case label.FieldOrganizationID:
  12505. return m.AddedOrganizationID()
  12506. }
  12507. return nil, false
  12508. }
  12509. // AddField adds the value to the field with the given name. It returns an error if
  12510. // the field is not defined in the schema, or if the type mismatched the field
  12511. // type.
  12512. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  12513. switch name {
  12514. case label.FieldStatus:
  12515. v, ok := value.(int8)
  12516. if !ok {
  12517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12518. }
  12519. m.AddStatus(v)
  12520. return nil
  12521. case label.FieldType:
  12522. v, ok := value.(int)
  12523. if !ok {
  12524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12525. }
  12526. m.AddType(v)
  12527. return nil
  12528. case label.FieldFrom:
  12529. v, ok := value.(int)
  12530. if !ok {
  12531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12532. }
  12533. m.AddFrom(v)
  12534. return nil
  12535. case label.FieldMode:
  12536. v, ok := value.(int)
  12537. if !ok {
  12538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12539. }
  12540. m.AddMode(v)
  12541. return nil
  12542. case label.FieldOrganizationID:
  12543. v, ok := value.(int64)
  12544. if !ok {
  12545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12546. }
  12547. m.AddOrganizationID(v)
  12548. return nil
  12549. }
  12550. return fmt.Errorf("unknown Label numeric field %s", name)
  12551. }
  12552. // ClearedFields returns all nullable fields that were cleared during this
  12553. // mutation.
  12554. func (m *LabelMutation) ClearedFields() []string {
  12555. var fields []string
  12556. if m.FieldCleared(label.FieldStatus) {
  12557. fields = append(fields, label.FieldStatus)
  12558. }
  12559. if m.FieldCleared(label.FieldConditions) {
  12560. fields = append(fields, label.FieldConditions)
  12561. }
  12562. if m.FieldCleared(label.FieldOrganizationID) {
  12563. fields = append(fields, label.FieldOrganizationID)
  12564. }
  12565. return fields
  12566. }
  12567. // FieldCleared returns a boolean indicating if a field with the given name was
  12568. // cleared in this mutation.
  12569. func (m *LabelMutation) FieldCleared(name string) bool {
  12570. _, ok := m.clearedFields[name]
  12571. return ok
  12572. }
  12573. // ClearField clears the value of the field with the given name. It returns an
  12574. // error if the field is not defined in the schema.
  12575. func (m *LabelMutation) ClearField(name string) error {
  12576. switch name {
  12577. case label.FieldStatus:
  12578. m.ClearStatus()
  12579. return nil
  12580. case label.FieldConditions:
  12581. m.ClearConditions()
  12582. return nil
  12583. case label.FieldOrganizationID:
  12584. m.ClearOrganizationID()
  12585. return nil
  12586. }
  12587. return fmt.Errorf("unknown Label nullable field %s", name)
  12588. }
  12589. // ResetField resets all changes in the mutation for the field with the given name.
  12590. // It returns an error if the field is not defined in the schema.
  12591. func (m *LabelMutation) ResetField(name string) error {
  12592. switch name {
  12593. case label.FieldCreatedAt:
  12594. m.ResetCreatedAt()
  12595. return nil
  12596. case label.FieldUpdatedAt:
  12597. m.ResetUpdatedAt()
  12598. return nil
  12599. case label.FieldStatus:
  12600. m.ResetStatus()
  12601. return nil
  12602. case label.FieldType:
  12603. m.ResetType()
  12604. return nil
  12605. case label.FieldName:
  12606. m.ResetName()
  12607. return nil
  12608. case label.FieldFrom:
  12609. m.ResetFrom()
  12610. return nil
  12611. case label.FieldMode:
  12612. m.ResetMode()
  12613. return nil
  12614. case label.FieldConditions:
  12615. m.ResetConditions()
  12616. return nil
  12617. case label.FieldOrganizationID:
  12618. m.ResetOrganizationID()
  12619. return nil
  12620. }
  12621. return fmt.Errorf("unknown Label field %s", name)
  12622. }
  12623. // AddedEdges returns all edge names that were set/added in this mutation.
  12624. func (m *LabelMutation) AddedEdges() []string {
  12625. edges := make([]string, 0, 1)
  12626. if m.label_relationships != nil {
  12627. edges = append(edges, label.EdgeLabelRelationships)
  12628. }
  12629. return edges
  12630. }
  12631. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12632. // name in this mutation.
  12633. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  12634. switch name {
  12635. case label.EdgeLabelRelationships:
  12636. ids := make([]ent.Value, 0, len(m.label_relationships))
  12637. for id := range m.label_relationships {
  12638. ids = append(ids, id)
  12639. }
  12640. return ids
  12641. }
  12642. return nil
  12643. }
  12644. // RemovedEdges returns all edge names that were removed in this mutation.
  12645. func (m *LabelMutation) RemovedEdges() []string {
  12646. edges := make([]string, 0, 1)
  12647. if m.removedlabel_relationships != nil {
  12648. edges = append(edges, label.EdgeLabelRelationships)
  12649. }
  12650. return edges
  12651. }
  12652. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12653. // the given name in this mutation.
  12654. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  12655. switch name {
  12656. case label.EdgeLabelRelationships:
  12657. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  12658. for id := range m.removedlabel_relationships {
  12659. ids = append(ids, id)
  12660. }
  12661. return ids
  12662. }
  12663. return nil
  12664. }
  12665. // ClearedEdges returns all edge names that were cleared in this mutation.
  12666. func (m *LabelMutation) ClearedEdges() []string {
  12667. edges := make([]string, 0, 1)
  12668. if m.clearedlabel_relationships {
  12669. edges = append(edges, label.EdgeLabelRelationships)
  12670. }
  12671. return edges
  12672. }
  12673. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12674. // was cleared in this mutation.
  12675. func (m *LabelMutation) EdgeCleared(name string) bool {
  12676. switch name {
  12677. case label.EdgeLabelRelationships:
  12678. return m.clearedlabel_relationships
  12679. }
  12680. return false
  12681. }
  12682. // ClearEdge clears the value of the edge with the given name. It returns an error
  12683. // if that edge is not defined in the schema.
  12684. func (m *LabelMutation) ClearEdge(name string) error {
  12685. switch name {
  12686. }
  12687. return fmt.Errorf("unknown Label unique edge %s", name)
  12688. }
  12689. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12690. // It returns an error if the edge is not defined in the schema.
  12691. func (m *LabelMutation) ResetEdge(name string) error {
  12692. switch name {
  12693. case label.EdgeLabelRelationships:
  12694. m.ResetLabelRelationships()
  12695. return nil
  12696. }
  12697. return fmt.Errorf("unknown Label edge %s", name)
  12698. }
  12699. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  12700. type LabelRelationshipMutation struct {
  12701. config
  12702. op Op
  12703. typ string
  12704. id *uint64
  12705. created_at *time.Time
  12706. updated_at *time.Time
  12707. status *uint8
  12708. addstatus *int8
  12709. deleted_at *time.Time
  12710. organization_id *uint64
  12711. addorganization_id *int64
  12712. clearedFields map[string]struct{}
  12713. contacts *uint64
  12714. clearedcontacts bool
  12715. labels *uint64
  12716. clearedlabels bool
  12717. done bool
  12718. oldValue func(context.Context) (*LabelRelationship, error)
  12719. predicates []predicate.LabelRelationship
  12720. }
  12721. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  12722. // labelrelationshipOption allows management of the mutation configuration using functional options.
  12723. type labelrelationshipOption func(*LabelRelationshipMutation)
  12724. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  12725. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  12726. m := &LabelRelationshipMutation{
  12727. config: c,
  12728. op: op,
  12729. typ: TypeLabelRelationship,
  12730. clearedFields: make(map[string]struct{}),
  12731. }
  12732. for _, opt := range opts {
  12733. opt(m)
  12734. }
  12735. return m
  12736. }
  12737. // withLabelRelationshipID sets the ID field of the mutation.
  12738. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  12739. return func(m *LabelRelationshipMutation) {
  12740. var (
  12741. err error
  12742. once sync.Once
  12743. value *LabelRelationship
  12744. )
  12745. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  12746. once.Do(func() {
  12747. if m.done {
  12748. err = errors.New("querying old values post mutation is not allowed")
  12749. } else {
  12750. value, err = m.Client().LabelRelationship.Get(ctx, id)
  12751. }
  12752. })
  12753. return value, err
  12754. }
  12755. m.id = &id
  12756. }
  12757. }
  12758. // withLabelRelationship sets the old LabelRelationship of the mutation.
  12759. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  12760. return func(m *LabelRelationshipMutation) {
  12761. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12762. return node, nil
  12763. }
  12764. m.id = &node.ID
  12765. }
  12766. }
  12767. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12768. // executed in a transaction (ent.Tx), a transactional client is returned.
  12769. func (m LabelRelationshipMutation) Client() *Client {
  12770. client := &Client{config: m.config}
  12771. client.init()
  12772. return client
  12773. }
  12774. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12775. // it returns an error otherwise.
  12776. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12777. if _, ok := m.driver.(*txDriver); !ok {
  12778. return nil, errors.New("ent: mutation is not running in a transaction")
  12779. }
  12780. tx := &Tx{config: m.config}
  12781. tx.init()
  12782. return tx, nil
  12783. }
  12784. // SetID sets the value of the id field. Note that this
  12785. // operation is only accepted on creation of LabelRelationship entities.
  12786. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12787. m.id = &id
  12788. }
  12789. // ID returns the ID value in the mutation. Note that the ID is only available
  12790. // if it was provided to the builder or after it was returned from the database.
  12791. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12792. if m.id == nil {
  12793. return
  12794. }
  12795. return *m.id, true
  12796. }
  12797. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12798. // That means, if the mutation is applied within a transaction with an isolation level such
  12799. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12800. // or updated by the mutation.
  12801. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12802. switch {
  12803. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12804. id, exists := m.ID()
  12805. if exists {
  12806. return []uint64{id}, nil
  12807. }
  12808. fallthrough
  12809. case m.op.Is(OpUpdate | OpDelete):
  12810. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12811. default:
  12812. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12813. }
  12814. }
  12815. // SetCreatedAt sets the "created_at" field.
  12816. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12817. m.created_at = &t
  12818. }
  12819. // CreatedAt returns the value of the "created_at" field in the mutation.
  12820. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12821. v := m.created_at
  12822. if v == nil {
  12823. return
  12824. }
  12825. return *v, true
  12826. }
  12827. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12828. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12830. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12831. if !m.op.Is(OpUpdateOne) {
  12832. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12833. }
  12834. if m.id == nil || m.oldValue == nil {
  12835. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12836. }
  12837. oldValue, err := m.oldValue(ctx)
  12838. if err != nil {
  12839. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12840. }
  12841. return oldValue.CreatedAt, nil
  12842. }
  12843. // ResetCreatedAt resets all changes to the "created_at" field.
  12844. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12845. m.created_at = nil
  12846. }
  12847. // SetUpdatedAt sets the "updated_at" field.
  12848. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12849. m.updated_at = &t
  12850. }
  12851. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12852. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12853. v := m.updated_at
  12854. if v == nil {
  12855. return
  12856. }
  12857. return *v, true
  12858. }
  12859. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12860. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12862. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12863. if !m.op.Is(OpUpdateOne) {
  12864. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12865. }
  12866. if m.id == nil || m.oldValue == nil {
  12867. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12868. }
  12869. oldValue, err := m.oldValue(ctx)
  12870. if err != nil {
  12871. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12872. }
  12873. return oldValue.UpdatedAt, nil
  12874. }
  12875. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12876. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12877. m.updated_at = nil
  12878. }
  12879. // SetStatus sets the "status" field.
  12880. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12881. m.status = &u
  12882. m.addstatus = nil
  12883. }
  12884. // Status returns the value of the "status" field in the mutation.
  12885. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12886. v := m.status
  12887. if v == nil {
  12888. return
  12889. }
  12890. return *v, true
  12891. }
  12892. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12893. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12895. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12896. if !m.op.Is(OpUpdateOne) {
  12897. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12898. }
  12899. if m.id == nil || m.oldValue == nil {
  12900. return v, errors.New("OldStatus requires an ID field in the mutation")
  12901. }
  12902. oldValue, err := m.oldValue(ctx)
  12903. if err != nil {
  12904. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12905. }
  12906. return oldValue.Status, nil
  12907. }
  12908. // AddStatus adds u to the "status" field.
  12909. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12910. if m.addstatus != nil {
  12911. *m.addstatus += u
  12912. } else {
  12913. m.addstatus = &u
  12914. }
  12915. }
  12916. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12917. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12918. v := m.addstatus
  12919. if v == nil {
  12920. return
  12921. }
  12922. return *v, true
  12923. }
  12924. // ClearStatus clears the value of the "status" field.
  12925. func (m *LabelRelationshipMutation) ClearStatus() {
  12926. m.status = nil
  12927. m.addstatus = nil
  12928. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12929. }
  12930. // StatusCleared returns if the "status" field was cleared in this mutation.
  12931. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12932. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12933. return ok
  12934. }
  12935. // ResetStatus resets all changes to the "status" field.
  12936. func (m *LabelRelationshipMutation) ResetStatus() {
  12937. m.status = nil
  12938. m.addstatus = nil
  12939. delete(m.clearedFields, labelrelationship.FieldStatus)
  12940. }
  12941. // SetDeletedAt sets the "deleted_at" field.
  12942. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12943. m.deleted_at = &t
  12944. }
  12945. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12946. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12947. v := m.deleted_at
  12948. if v == nil {
  12949. return
  12950. }
  12951. return *v, true
  12952. }
  12953. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12954. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12956. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12957. if !m.op.Is(OpUpdateOne) {
  12958. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12959. }
  12960. if m.id == nil || m.oldValue == nil {
  12961. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12962. }
  12963. oldValue, err := m.oldValue(ctx)
  12964. if err != nil {
  12965. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12966. }
  12967. return oldValue.DeletedAt, nil
  12968. }
  12969. // ClearDeletedAt clears the value of the "deleted_at" field.
  12970. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12971. m.deleted_at = nil
  12972. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12973. }
  12974. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12975. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12976. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12977. return ok
  12978. }
  12979. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12980. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12981. m.deleted_at = nil
  12982. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12983. }
  12984. // SetLabelID sets the "label_id" field.
  12985. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12986. m.labels = &u
  12987. }
  12988. // LabelID returns the value of the "label_id" field in the mutation.
  12989. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12990. v := m.labels
  12991. if v == nil {
  12992. return
  12993. }
  12994. return *v, true
  12995. }
  12996. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12997. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12999. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  13000. if !m.op.Is(OpUpdateOne) {
  13001. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  13002. }
  13003. if m.id == nil || m.oldValue == nil {
  13004. return v, errors.New("OldLabelID requires an ID field in the mutation")
  13005. }
  13006. oldValue, err := m.oldValue(ctx)
  13007. if err != nil {
  13008. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  13009. }
  13010. return oldValue.LabelID, nil
  13011. }
  13012. // ResetLabelID resets all changes to the "label_id" field.
  13013. func (m *LabelRelationshipMutation) ResetLabelID() {
  13014. m.labels = nil
  13015. }
  13016. // SetContactID sets the "contact_id" field.
  13017. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  13018. m.contacts = &u
  13019. }
  13020. // ContactID returns the value of the "contact_id" field in the mutation.
  13021. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  13022. v := m.contacts
  13023. if v == nil {
  13024. return
  13025. }
  13026. return *v, true
  13027. }
  13028. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  13029. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  13030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13031. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13032. if !m.op.Is(OpUpdateOne) {
  13033. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13034. }
  13035. if m.id == nil || m.oldValue == nil {
  13036. return v, errors.New("OldContactID requires an ID field in the mutation")
  13037. }
  13038. oldValue, err := m.oldValue(ctx)
  13039. if err != nil {
  13040. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13041. }
  13042. return oldValue.ContactID, nil
  13043. }
  13044. // ResetContactID resets all changes to the "contact_id" field.
  13045. func (m *LabelRelationshipMutation) ResetContactID() {
  13046. m.contacts = nil
  13047. }
  13048. // SetOrganizationID sets the "organization_id" field.
  13049. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  13050. m.organization_id = &u
  13051. m.addorganization_id = nil
  13052. }
  13053. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13054. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  13055. v := m.organization_id
  13056. if v == nil {
  13057. return
  13058. }
  13059. return *v, true
  13060. }
  13061. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  13062. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  13063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13064. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13065. if !m.op.Is(OpUpdateOne) {
  13066. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13067. }
  13068. if m.id == nil || m.oldValue == nil {
  13069. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13070. }
  13071. oldValue, err := m.oldValue(ctx)
  13072. if err != nil {
  13073. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13074. }
  13075. return oldValue.OrganizationID, nil
  13076. }
  13077. // AddOrganizationID adds u to the "organization_id" field.
  13078. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  13079. if m.addorganization_id != nil {
  13080. *m.addorganization_id += u
  13081. } else {
  13082. m.addorganization_id = &u
  13083. }
  13084. }
  13085. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13086. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  13087. v := m.addorganization_id
  13088. if v == nil {
  13089. return
  13090. }
  13091. return *v, true
  13092. }
  13093. // ClearOrganizationID clears the value of the "organization_id" field.
  13094. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  13095. m.organization_id = nil
  13096. m.addorganization_id = nil
  13097. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  13098. }
  13099. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13100. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  13101. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  13102. return ok
  13103. }
  13104. // ResetOrganizationID resets all changes to the "organization_id" field.
  13105. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  13106. m.organization_id = nil
  13107. m.addorganization_id = nil
  13108. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  13109. }
  13110. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  13111. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  13112. m.contacts = &id
  13113. }
  13114. // ClearContacts clears the "contacts" edge to the Contact entity.
  13115. func (m *LabelRelationshipMutation) ClearContacts() {
  13116. m.clearedcontacts = true
  13117. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  13118. }
  13119. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  13120. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  13121. return m.clearedcontacts
  13122. }
  13123. // ContactsID returns the "contacts" edge ID in the mutation.
  13124. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  13125. if m.contacts != nil {
  13126. return *m.contacts, true
  13127. }
  13128. return
  13129. }
  13130. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  13131. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13132. // ContactsID instead. It exists only for internal usage by the builders.
  13133. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  13134. if id := m.contacts; id != nil {
  13135. ids = append(ids, *id)
  13136. }
  13137. return
  13138. }
  13139. // ResetContacts resets all changes to the "contacts" edge.
  13140. func (m *LabelRelationshipMutation) ResetContacts() {
  13141. m.contacts = nil
  13142. m.clearedcontacts = false
  13143. }
  13144. // SetLabelsID sets the "labels" edge to the Label entity by id.
  13145. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  13146. m.labels = &id
  13147. }
  13148. // ClearLabels clears the "labels" edge to the Label entity.
  13149. func (m *LabelRelationshipMutation) ClearLabels() {
  13150. m.clearedlabels = true
  13151. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  13152. }
  13153. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  13154. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  13155. return m.clearedlabels
  13156. }
  13157. // LabelsID returns the "labels" edge ID in the mutation.
  13158. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  13159. if m.labels != nil {
  13160. return *m.labels, true
  13161. }
  13162. return
  13163. }
  13164. // LabelsIDs returns the "labels" edge IDs in the mutation.
  13165. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13166. // LabelsID instead. It exists only for internal usage by the builders.
  13167. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  13168. if id := m.labels; id != nil {
  13169. ids = append(ids, *id)
  13170. }
  13171. return
  13172. }
  13173. // ResetLabels resets all changes to the "labels" edge.
  13174. func (m *LabelRelationshipMutation) ResetLabels() {
  13175. m.labels = nil
  13176. m.clearedlabels = false
  13177. }
  13178. // Where appends a list predicates to the LabelRelationshipMutation builder.
  13179. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  13180. m.predicates = append(m.predicates, ps...)
  13181. }
  13182. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  13183. // users can use type-assertion to append predicates that do not depend on any generated package.
  13184. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  13185. p := make([]predicate.LabelRelationship, len(ps))
  13186. for i := range ps {
  13187. p[i] = ps[i]
  13188. }
  13189. m.Where(p...)
  13190. }
  13191. // Op returns the operation name.
  13192. func (m *LabelRelationshipMutation) Op() Op {
  13193. return m.op
  13194. }
  13195. // SetOp allows setting the mutation operation.
  13196. func (m *LabelRelationshipMutation) SetOp(op Op) {
  13197. m.op = op
  13198. }
  13199. // Type returns the node type of this mutation (LabelRelationship).
  13200. func (m *LabelRelationshipMutation) Type() string {
  13201. return m.typ
  13202. }
  13203. // Fields returns all fields that were changed during this mutation. Note that in
  13204. // order to get all numeric fields that were incremented/decremented, call
  13205. // AddedFields().
  13206. func (m *LabelRelationshipMutation) Fields() []string {
  13207. fields := make([]string, 0, 7)
  13208. if m.created_at != nil {
  13209. fields = append(fields, labelrelationship.FieldCreatedAt)
  13210. }
  13211. if m.updated_at != nil {
  13212. fields = append(fields, labelrelationship.FieldUpdatedAt)
  13213. }
  13214. if m.status != nil {
  13215. fields = append(fields, labelrelationship.FieldStatus)
  13216. }
  13217. if m.deleted_at != nil {
  13218. fields = append(fields, labelrelationship.FieldDeletedAt)
  13219. }
  13220. if m.labels != nil {
  13221. fields = append(fields, labelrelationship.FieldLabelID)
  13222. }
  13223. if m.contacts != nil {
  13224. fields = append(fields, labelrelationship.FieldContactID)
  13225. }
  13226. if m.organization_id != nil {
  13227. fields = append(fields, labelrelationship.FieldOrganizationID)
  13228. }
  13229. return fields
  13230. }
  13231. // Field returns the value of a field with the given name. The second boolean
  13232. // return value indicates that this field was not set, or was not defined in the
  13233. // schema.
  13234. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  13235. switch name {
  13236. case labelrelationship.FieldCreatedAt:
  13237. return m.CreatedAt()
  13238. case labelrelationship.FieldUpdatedAt:
  13239. return m.UpdatedAt()
  13240. case labelrelationship.FieldStatus:
  13241. return m.Status()
  13242. case labelrelationship.FieldDeletedAt:
  13243. return m.DeletedAt()
  13244. case labelrelationship.FieldLabelID:
  13245. return m.LabelID()
  13246. case labelrelationship.FieldContactID:
  13247. return m.ContactID()
  13248. case labelrelationship.FieldOrganizationID:
  13249. return m.OrganizationID()
  13250. }
  13251. return nil, false
  13252. }
  13253. // OldField returns the old value of the field from the database. An error is
  13254. // returned if the mutation operation is not UpdateOne, or the query to the
  13255. // database failed.
  13256. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13257. switch name {
  13258. case labelrelationship.FieldCreatedAt:
  13259. return m.OldCreatedAt(ctx)
  13260. case labelrelationship.FieldUpdatedAt:
  13261. return m.OldUpdatedAt(ctx)
  13262. case labelrelationship.FieldStatus:
  13263. return m.OldStatus(ctx)
  13264. case labelrelationship.FieldDeletedAt:
  13265. return m.OldDeletedAt(ctx)
  13266. case labelrelationship.FieldLabelID:
  13267. return m.OldLabelID(ctx)
  13268. case labelrelationship.FieldContactID:
  13269. return m.OldContactID(ctx)
  13270. case labelrelationship.FieldOrganizationID:
  13271. return m.OldOrganizationID(ctx)
  13272. }
  13273. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  13274. }
  13275. // SetField sets the value of a field with the given name. It returns an error if
  13276. // the field is not defined in the schema, or if the type mismatched the field
  13277. // type.
  13278. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  13279. switch name {
  13280. case labelrelationship.FieldCreatedAt:
  13281. v, ok := value.(time.Time)
  13282. if !ok {
  13283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13284. }
  13285. m.SetCreatedAt(v)
  13286. return nil
  13287. case labelrelationship.FieldUpdatedAt:
  13288. v, ok := value.(time.Time)
  13289. if !ok {
  13290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13291. }
  13292. m.SetUpdatedAt(v)
  13293. return nil
  13294. case labelrelationship.FieldStatus:
  13295. v, ok := value.(uint8)
  13296. if !ok {
  13297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13298. }
  13299. m.SetStatus(v)
  13300. return nil
  13301. case labelrelationship.FieldDeletedAt:
  13302. v, ok := value.(time.Time)
  13303. if !ok {
  13304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13305. }
  13306. m.SetDeletedAt(v)
  13307. return nil
  13308. case labelrelationship.FieldLabelID:
  13309. v, ok := value.(uint64)
  13310. if !ok {
  13311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13312. }
  13313. m.SetLabelID(v)
  13314. return nil
  13315. case labelrelationship.FieldContactID:
  13316. v, ok := value.(uint64)
  13317. if !ok {
  13318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13319. }
  13320. m.SetContactID(v)
  13321. return nil
  13322. case labelrelationship.FieldOrganizationID:
  13323. v, ok := value.(uint64)
  13324. if !ok {
  13325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13326. }
  13327. m.SetOrganizationID(v)
  13328. return nil
  13329. }
  13330. return fmt.Errorf("unknown LabelRelationship field %s", name)
  13331. }
  13332. // AddedFields returns all numeric fields that were incremented/decremented during
  13333. // this mutation.
  13334. func (m *LabelRelationshipMutation) AddedFields() []string {
  13335. var fields []string
  13336. if m.addstatus != nil {
  13337. fields = append(fields, labelrelationship.FieldStatus)
  13338. }
  13339. if m.addorganization_id != nil {
  13340. fields = append(fields, labelrelationship.FieldOrganizationID)
  13341. }
  13342. return fields
  13343. }
  13344. // AddedField returns the numeric value that was incremented/decremented on a field
  13345. // with the given name. The second boolean return value indicates that this field
  13346. // was not set, or was not defined in the schema.
  13347. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  13348. switch name {
  13349. case labelrelationship.FieldStatus:
  13350. return m.AddedStatus()
  13351. case labelrelationship.FieldOrganizationID:
  13352. return m.AddedOrganizationID()
  13353. }
  13354. return nil, false
  13355. }
  13356. // AddField adds the value to the field with the given name. It returns an error if
  13357. // the field is not defined in the schema, or if the type mismatched the field
  13358. // type.
  13359. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  13360. switch name {
  13361. case labelrelationship.FieldStatus:
  13362. v, ok := value.(int8)
  13363. if !ok {
  13364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13365. }
  13366. m.AddStatus(v)
  13367. return nil
  13368. case labelrelationship.FieldOrganizationID:
  13369. v, ok := value.(int64)
  13370. if !ok {
  13371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13372. }
  13373. m.AddOrganizationID(v)
  13374. return nil
  13375. }
  13376. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  13377. }
  13378. // ClearedFields returns all nullable fields that were cleared during this
  13379. // mutation.
  13380. func (m *LabelRelationshipMutation) ClearedFields() []string {
  13381. var fields []string
  13382. if m.FieldCleared(labelrelationship.FieldStatus) {
  13383. fields = append(fields, labelrelationship.FieldStatus)
  13384. }
  13385. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  13386. fields = append(fields, labelrelationship.FieldDeletedAt)
  13387. }
  13388. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  13389. fields = append(fields, labelrelationship.FieldOrganizationID)
  13390. }
  13391. return fields
  13392. }
  13393. // FieldCleared returns a boolean indicating if a field with the given name was
  13394. // cleared in this mutation.
  13395. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  13396. _, ok := m.clearedFields[name]
  13397. return ok
  13398. }
  13399. // ClearField clears the value of the field with the given name. It returns an
  13400. // error if the field is not defined in the schema.
  13401. func (m *LabelRelationshipMutation) ClearField(name string) error {
  13402. switch name {
  13403. case labelrelationship.FieldStatus:
  13404. m.ClearStatus()
  13405. return nil
  13406. case labelrelationship.FieldDeletedAt:
  13407. m.ClearDeletedAt()
  13408. return nil
  13409. case labelrelationship.FieldOrganizationID:
  13410. m.ClearOrganizationID()
  13411. return nil
  13412. }
  13413. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  13414. }
  13415. // ResetField resets all changes in the mutation for the field with the given name.
  13416. // It returns an error if the field is not defined in the schema.
  13417. func (m *LabelRelationshipMutation) ResetField(name string) error {
  13418. switch name {
  13419. case labelrelationship.FieldCreatedAt:
  13420. m.ResetCreatedAt()
  13421. return nil
  13422. case labelrelationship.FieldUpdatedAt:
  13423. m.ResetUpdatedAt()
  13424. return nil
  13425. case labelrelationship.FieldStatus:
  13426. m.ResetStatus()
  13427. return nil
  13428. case labelrelationship.FieldDeletedAt:
  13429. m.ResetDeletedAt()
  13430. return nil
  13431. case labelrelationship.FieldLabelID:
  13432. m.ResetLabelID()
  13433. return nil
  13434. case labelrelationship.FieldContactID:
  13435. m.ResetContactID()
  13436. return nil
  13437. case labelrelationship.FieldOrganizationID:
  13438. m.ResetOrganizationID()
  13439. return nil
  13440. }
  13441. return fmt.Errorf("unknown LabelRelationship field %s", name)
  13442. }
  13443. // AddedEdges returns all edge names that were set/added in this mutation.
  13444. func (m *LabelRelationshipMutation) AddedEdges() []string {
  13445. edges := make([]string, 0, 2)
  13446. if m.contacts != nil {
  13447. edges = append(edges, labelrelationship.EdgeContacts)
  13448. }
  13449. if m.labels != nil {
  13450. edges = append(edges, labelrelationship.EdgeLabels)
  13451. }
  13452. return edges
  13453. }
  13454. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13455. // name in this mutation.
  13456. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  13457. switch name {
  13458. case labelrelationship.EdgeContacts:
  13459. if id := m.contacts; id != nil {
  13460. return []ent.Value{*id}
  13461. }
  13462. case labelrelationship.EdgeLabels:
  13463. if id := m.labels; id != nil {
  13464. return []ent.Value{*id}
  13465. }
  13466. }
  13467. return nil
  13468. }
  13469. // RemovedEdges returns all edge names that were removed in this mutation.
  13470. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  13471. edges := make([]string, 0, 2)
  13472. return edges
  13473. }
  13474. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13475. // the given name in this mutation.
  13476. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  13477. return nil
  13478. }
  13479. // ClearedEdges returns all edge names that were cleared in this mutation.
  13480. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  13481. edges := make([]string, 0, 2)
  13482. if m.clearedcontacts {
  13483. edges = append(edges, labelrelationship.EdgeContacts)
  13484. }
  13485. if m.clearedlabels {
  13486. edges = append(edges, labelrelationship.EdgeLabels)
  13487. }
  13488. return edges
  13489. }
  13490. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13491. // was cleared in this mutation.
  13492. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  13493. switch name {
  13494. case labelrelationship.EdgeContacts:
  13495. return m.clearedcontacts
  13496. case labelrelationship.EdgeLabels:
  13497. return m.clearedlabels
  13498. }
  13499. return false
  13500. }
  13501. // ClearEdge clears the value of the edge with the given name. It returns an error
  13502. // if that edge is not defined in the schema.
  13503. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  13504. switch name {
  13505. case labelrelationship.EdgeContacts:
  13506. m.ClearContacts()
  13507. return nil
  13508. case labelrelationship.EdgeLabels:
  13509. m.ClearLabels()
  13510. return nil
  13511. }
  13512. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  13513. }
  13514. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13515. // It returns an error if the edge is not defined in the schema.
  13516. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  13517. switch name {
  13518. case labelrelationship.EdgeContacts:
  13519. m.ResetContacts()
  13520. return nil
  13521. case labelrelationship.EdgeLabels:
  13522. m.ResetLabels()
  13523. return nil
  13524. }
  13525. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  13526. }
  13527. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  13528. type MessageMutation struct {
  13529. config
  13530. op Op
  13531. typ string
  13532. id *int
  13533. wx_wxid *string
  13534. wxid *string
  13535. content *string
  13536. clearedFields map[string]struct{}
  13537. done bool
  13538. oldValue func(context.Context) (*Message, error)
  13539. predicates []predicate.Message
  13540. }
  13541. var _ ent.Mutation = (*MessageMutation)(nil)
  13542. // messageOption allows management of the mutation configuration using functional options.
  13543. type messageOption func(*MessageMutation)
  13544. // newMessageMutation creates new mutation for the Message entity.
  13545. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  13546. m := &MessageMutation{
  13547. config: c,
  13548. op: op,
  13549. typ: TypeMessage,
  13550. clearedFields: make(map[string]struct{}),
  13551. }
  13552. for _, opt := range opts {
  13553. opt(m)
  13554. }
  13555. return m
  13556. }
  13557. // withMessageID sets the ID field of the mutation.
  13558. func withMessageID(id int) messageOption {
  13559. return func(m *MessageMutation) {
  13560. var (
  13561. err error
  13562. once sync.Once
  13563. value *Message
  13564. )
  13565. m.oldValue = func(ctx context.Context) (*Message, error) {
  13566. once.Do(func() {
  13567. if m.done {
  13568. err = errors.New("querying old values post mutation is not allowed")
  13569. } else {
  13570. value, err = m.Client().Message.Get(ctx, id)
  13571. }
  13572. })
  13573. return value, err
  13574. }
  13575. m.id = &id
  13576. }
  13577. }
  13578. // withMessage sets the old Message of the mutation.
  13579. func withMessage(node *Message) messageOption {
  13580. return func(m *MessageMutation) {
  13581. m.oldValue = func(context.Context) (*Message, error) {
  13582. return node, nil
  13583. }
  13584. m.id = &node.ID
  13585. }
  13586. }
  13587. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13588. // executed in a transaction (ent.Tx), a transactional client is returned.
  13589. func (m MessageMutation) Client() *Client {
  13590. client := &Client{config: m.config}
  13591. client.init()
  13592. return client
  13593. }
  13594. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13595. // it returns an error otherwise.
  13596. func (m MessageMutation) Tx() (*Tx, error) {
  13597. if _, ok := m.driver.(*txDriver); !ok {
  13598. return nil, errors.New("ent: mutation is not running in a transaction")
  13599. }
  13600. tx := &Tx{config: m.config}
  13601. tx.init()
  13602. return tx, nil
  13603. }
  13604. // ID returns the ID value in the mutation. Note that the ID is only available
  13605. // if it was provided to the builder or after it was returned from the database.
  13606. func (m *MessageMutation) ID() (id int, exists bool) {
  13607. if m.id == nil {
  13608. return
  13609. }
  13610. return *m.id, true
  13611. }
  13612. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13613. // That means, if the mutation is applied within a transaction with an isolation level such
  13614. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13615. // or updated by the mutation.
  13616. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  13617. switch {
  13618. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13619. id, exists := m.ID()
  13620. if exists {
  13621. return []int{id}, nil
  13622. }
  13623. fallthrough
  13624. case m.op.Is(OpUpdate | OpDelete):
  13625. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  13626. default:
  13627. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13628. }
  13629. }
  13630. // SetWxWxid sets the "wx_wxid" field.
  13631. func (m *MessageMutation) SetWxWxid(s string) {
  13632. m.wx_wxid = &s
  13633. }
  13634. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  13635. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  13636. v := m.wx_wxid
  13637. if v == nil {
  13638. return
  13639. }
  13640. return *v, true
  13641. }
  13642. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  13643. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13645. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  13646. if !m.op.Is(OpUpdateOne) {
  13647. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  13648. }
  13649. if m.id == nil || m.oldValue == nil {
  13650. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  13651. }
  13652. oldValue, err := m.oldValue(ctx)
  13653. if err != nil {
  13654. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  13655. }
  13656. return oldValue.WxWxid, nil
  13657. }
  13658. // ClearWxWxid clears the value of the "wx_wxid" field.
  13659. func (m *MessageMutation) ClearWxWxid() {
  13660. m.wx_wxid = nil
  13661. m.clearedFields[message.FieldWxWxid] = struct{}{}
  13662. }
  13663. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  13664. func (m *MessageMutation) WxWxidCleared() bool {
  13665. _, ok := m.clearedFields[message.FieldWxWxid]
  13666. return ok
  13667. }
  13668. // ResetWxWxid resets all changes to the "wx_wxid" field.
  13669. func (m *MessageMutation) ResetWxWxid() {
  13670. m.wx_wxid = nil
  13671. delete(m.clearedFields, message.FieldWxWxid)
  13672. }
  13673. // SetWxid sets the "wxid" field.
  13674. func (m *MessageMutation) SetWxid(s string) {
  13675. m.wxid = &s
  13676. }
  13677. // Wxid returns the value of the "wxid" field in the mutation.
  13678. func (m *MessageMutation) Wxid() (r string, exists bool) {
  13679. v := m.wxid
  13680. if v == nil {
  13681. return
  13682. }
  13683. return *v, true
  13684. }
  13685. // OldWxid returns the old "wxid" field's value of the Message entity.
  13686. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13688. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  13689. if !m.op.Is(OpUpdateOne) {
  13690. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  13691. }
  13692. if m.id == nil || m.oldValue == nil {
  13693. return v, errors.New("OldWxid requires an ID field in the mutation")
  13694. }
  13695. oldValue, err := m.oldValue(ctx)
  13696. if err != nil {
  13697. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  13698. }
  13699. return oldValue.Wxid, nil
  13700. }
  13701. // ResetWxid resets all changes to the "wxid" field.
  13702. func (m *MessageMutation) ResetWxid() {
  13703. m.wxid = nil
  13704. }
  13705. // SetContent sets the "content" field.
  13706. func (m *MessageMutation) SetContent(s string) {
  13707. m.content = &s
  13708. }
  13709. // Content returns the value of the "content" field in the mutation.
  13710. func (m *MessageMutation) Content() (r string, exists bool) {
  13711. v := m.content
  13712. if v == nil {
  13713. return
  13714. }
  13715. return *v, true
  13716. }
  13717. // OldContent returns the old "content" field's value of the Message entity.
  13718. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13720. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  13721. if !m.op.Is(OpUpdateOne) {
  13722. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13723. }
  13724. if m.id == nil || m.oldValue == nil {
  13725. return v, errors.New("OldContent requires an ID field in the mutation")
  13726. }
  13727. oldValue, err := m.oldValue(ctx)
  13728. if err != nil {
  13729. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13730. }
  13731. return oldValue.Content, nil
  13732. }
  13733. // ResetContent resets all changes to the "content" field.
  13734. func (m *MessageMutation) ResetContent() {
  13735. m.content = nil
  13736. }
  13737. // Where appends a list predicates to the MessageMutation builder.
  13738. func (m *MessageMutation) Where(ps ...predicate.Message) {
  13739. m.predicates = append(m.predicates, ps...)
  13740. }
  13741. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  13742. // users can use type-assertion to append predicates that do not depend on any generated package.
  13743. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  13744. p := make([]predicate.Message, len(ps))
  13745. for i := range ps {
  13746. p[i] = ps[i]
  13747. }
  13748. m.Where(p...)
  13749. }
  13750. // Op returns the operation name.
  13751. func (m *MessageMutation) Op() Op {
  13752. return m.op
  13753. }
  13754. // SetOp allows setting the mutation operation.
  13755. func (m *MessageMutation) SetOp(op Op) {
  13756. m.op = op
  13757. }
  13758. // Type returns the node type of this mutation (Message).
  13759. func (m *MessageMutation) Type() string {
  13760. return m.typ
  13761. }
  13762. // Fields returns all fields that were changed during this mutation. Note that in
  13763. // order to get all numeric fields that were incremented/decremented, call
  13764. // AddedFields().
  13765. func (m *MessageMutation) Fields() []string {
  13766. fields := make([]string, 0, 3)
  13767. if m.wx_wxid != nil {
  13768. fields = append(fields, message.FieldWxWxid)
  13769. }
  13770. if m.wxid != nil {
  13771. fields = append(fields, message.FieldWxid)
  13772. }
  13773. if m.content != nil {
  13774. fields = append(fields, message.FieldContent)
  13775. }
  13776. return fields
  13777. }
  13778. // Field returns the value of a field with the given name. The second boolean
  13779. // return value indicates that this field was not set, or was not defined in the
  13780. // schema.
  13781. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  13782. switch name {
  13783. case message.FieldWxWxid:
  13784. return m.WxWxid()
  13785. case message.FieldWxid:
  13786. return m.Wxid()
  13787. case message.FieldContent:
  13788. return m.Content()
  13789. }
  13790. return nil, false
  13791. }
  13792. // OldField returns the old value of the field from the database. An error is
  13793. // returned if the mutation operation is not UpdateOne, or the query to the
  13794. // database failed.
  13795. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13796. switch name {
  13797. case message.FieldWxWxid:
  13798. return m.OldWxWxid(ctx)
  13799. case message.FieldWxid:
  13800. return m.OldWxid(ctx)
  13801. case message.FieldContent:
  13802. return m.OldContent(ctx)
  13803. }
  13804. return nil, fmt.Errorf("unknown Message field %s", name)
  13805. }
  13806. // SetField sets the value of a field with the given name. It returns an error if
  13807. // the field is not defined in the schema, or if the type mismatched the field
  13808. // type.
  13809. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  13810. switch name {
  13811. case message.FieldWxWxid:
  13812. v, ok := value.(string)
  13813. if !ok {
  13814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13815. }
  13816. m.SetWxWxid(v)
  13817. return nil
  13818. case message.FieldWxid:
  13819. v, ok := value.(string)
  13820. if !ok {
  13821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13822. }
  13823. m.SetWxid(v)
  13824. return nil
  13825. case message.FieldContent:
  13826. v, ok := value.(string)
  13827. if !ok {
  13828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13829. }
  13830. m.SetContent(v)
  13831. return nil
  13832. }
  13833. return fmt.Errorf("unknown Message field %s", name)
  13834. }
  13835. // AddedFields returns all numeric fields that were incremented/decremented during
  13836. // this mutation.
  13837. func (m *MessageMutation) AddedFields() []string {
  13838. return nil
  13839. }
  13840. // AddedField returns the numeric value that was incremented/decremented on a field
  13841. // with the given name. The second boolean return value indicates that this field
  13842. // was not set, or was not defined in the schema.
  13843. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  13844. return nil, false
  13845. }
  13846. // AddField adds the value to the field with the given name. It returns an error if
  13847. // the field is not defined in the schema, or if the type mismatched the field
  13848. // type.
  13849. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  13850. switch name {
  13851. }
  13852. return fmt.Errorf("unknown Message numeric field %s", name)
  13853. }
  13854. // ClearedFields returns all nullable fields that were cleared during this
  13855. // mutation.
  13856. func (m *MessageMutation) ClearedFields() []string {
  13857. var fields []string
  13858. if m.FieldCleared(message.FieldWxWxid) {
  13859. fields = append(fields, message.FieldWxWxid)
  13860. }
  13861. return fields
  13862. }
  13863. // FieldCleared returns a boolean indicating if a field with the given name was
  13864. // cleared in this mutation.
  13865. func (m *MessageMutation) FieldCleared(name string) bool {
  13866. _, ok := m.clearedFields[name]
  13867. return ok
  13868. }
  13869. // ClearField clears the value of the field with the given name. It returns an
  13870. // error if the field is not defined in the schema.
  13871. func (m *MessageMutation) ClearField(name string) error {
  13872. switch name {
  13873. case message.FieldWxWxid:
  13874. m.ClearWxWxid()
  13875. return nil
  13876. }
  13877. return fmt.Errorf("unknown Message nullable field %s", name)
  13878. }
  13879. // ResetField resets all changes in the mutation for the field with the given name.
  13880. // It returns an error if the field is not defined in the schema.
  13881. func (m *MessageMutation) ResetField(name string) error {
  13882. switch name {
  13883. case message.FieldWxWxid:
  13884. m.ResetWxWxid()
  13885. return nil
  13886. case message.FieldWxid:
  13887. m.ResetWxid()
  13888. return nil
  13889. case message.FieldContent:
  13890. m.ResetContent()
  13891. return nil
  13892. }
  13893. return fmt.Errorf("unknown Message field %s", name)
  13894. }
  13895. // AddedEdges returns all edge names that were set/added in this mutation.
  13896. func (m *MessageMutation) AddedEdges() []string {
  13897. edges := make([]string, 0, 0)
  13898. return edges
  13899. }
  13900. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13901. // name in this mutation.
  13902. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  13903. return nil
  13904. }
  13905. // RemovedEdges returns all edge names that were removed in this mutation.
  13906. func (m *MessageMutation) RemovedEdges() []string {
  13907. edges := make([]string, 0, 0)
  13908. return edges
  13909. }
  13910. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13911. // the given name in this mutation.
  13912. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  13913. return nil
  13914. }
  13915. // ClearedEdges returns all edge names that were cleared in this mutation.
  13916. func (m *MessageMutation) ClearedEdges() []string {
  13917. edges := make([]string, 0, 0)
  13918. return edges
  13919. }
  13920. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13921. // was cleared in this mutation.
  13922. func (m *MessageMutation) EdgeCleared(name string) bool {
  13923. return false
  13924. }
  13925. // ClearEdge clears the value of the edge with the given name. It returns an error
  13926. // if that edge is not defined in the schema.
  13927. func (m *MessageMutation) ClearEdge(name string) error {
  13928. return fmt.Errorf("unknown Message unique edge %s", name)
  13929. }
  13930. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13931. // It returns an error if the edge is not defined in the schema.
  13932. func (m *MessageMutation) ResetEdge(name string) error {
  13933. return fmt.Errorf("unknown Message edge %s", name)
  13934. }
  13935. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  13936. type MessageRecordsMutation struct {
  13937. config
  13938. op Op
  13939. typ string
  13940. id *uint64
  13941. created_at *time.Time
  13942. updated_at *time.Time
  13943. status *uint8
  13944. addstatus *int8
  13945. bot_wxid *string
  13946. contact_type *int
  13947. addcontact_type *int
  13948. contact_wxid *string
  13949. content_type *int
  13950. addcontent_type *int
  13951. content *string
  13952. meta *custom_types.Meta
  13953. error_detail *string
  13954. send_time *time.Time
  13955. source_type *int
  13956. addsource_type *int
  13957. organization_id *uint64
  13958. addorganization_id *int64
  13959. clearedFields map[string]struct{}
  13960. sop_stage *uint64
  13961. clearedsop_stage bool
  13962. sop_node *uint64
  13963. clearedsop_node bool
  13964. message_contact *uint64
  13965. clearedmessage_contact bool
  13966. done bool
  13967. oldValue func(context.Context) (*MessageRecords, error)
  13968. predicates []predicate.MessageRecords
  13969. }
  13970. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  13971. // messagerecordsOption allows management of the mutation configuration using functional options.
  13972. type messagerecordsOption func(*MessageRecordsMutation)
  13973. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  13974. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  13975. m := &MessageRecordsMutation{
  13976. config: c,
  13977. op: op,
  13978. typ: TypeMessageRecords,
  13979. clearedFields: make(map[string]struct{}),
  13980. }
  13981. for _, opt := range opts {
  13982. opt(m)
  13983. }
  13984. return m
  13985. }
  13986. // withMessageRecordsID sets the ID field of the mutation.
  13987. func withMessageRecordsID(id uint64) messagerecordsOption {
  13988. return func(m *MessageRecordsMutation) {
  13989. var (
  13990. err error
  13991. once sync.Once
  13992. value *MessageRecords
  13993. )
  13994. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  13995. once.Do(func() {
  13996. if m.done {
  13997. err = errors.New("querying old values post mutation is not allowed")
  13998. } else {
  13999. value, err = m.Client().MessageRecords.Get(ctx, id)
  14000. }
  14001. })
  14002. return value, err
  14003. }
  14004. m.id = &id
  14005. }
  14006. }
  14007. // withMessageRecords sets the old MessageRecords of the mutation.
  14008. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  14009. return func(m *MessageRecordsMutation) {
  14010. m.oldValue = func(context.Context) (*MessageRecords, error) {
  14011. return node, nil
  14012. }
  14013. m.id = &node.ID
  14014. }
  14015. }
  14016. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14017. // executed in a transaction (ent.Tx), a transactional client is returned.
  14018. func (m MessageRecordsMutation) Client() *Client {
  14019. client := &Client{config: m.config}
  14020. client.init()
  14021. return client
  14022. }
  14023. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14024. // it returns an error otherwise.
  14025. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  14026. if _, ok := m.driver.(*txDriver); !ok {
  14027. return nil, errors.New("ent: mutation is not running in a transaction")
  14028. }
  14029. tx := &Tx{config: m.config}
  14030. tx.init()
  14031. return tx, nil
  14032. }
  14033. // SetID sets the value of the id field. Note that this
  14034. // operation is only accepted on creation of MessageRecords entities.
  14035. func (m *MessageRecordsMutation) SetID(id uint64) {
  14036. m.id = &id
  14037. }
  14038. // ID returns the ID value in the mutation. Note that the ID is only available
  14039. // if it was provided to the builder or after it was returned from the database.
  14040. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  14041. if m.id == nil {
  14042. return
  14043. }
  14044. return *m.id, true
  14045. }
  14046. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14047. // That means, if the mutation is applied within a transaction with an isolation level such
  14048. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14049. // or updated by the mutation.
  14050. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  14051. switch {
  14052. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14053. id, exists := m.ID()
  14054. if exists {
  14055. return []uint64{id}, nil
  14056. }
  14057. fallthrough
  14058. case m.op.Is(OpUpdate | OpDelete):
  14059. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  14060. default:
  14061. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14062. }
  14063. }
  14064. // SetCreatedAt sets the "created_at" field.
  14065. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  14066. m.created_at = &t
  14067. }
  14068. // CreatedAt returns the value of the "created_at" field in the mutation.
  14069. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  14070. v := m.created_at
  14071. if v == nil {
  14072. return
  14073. }
  14074. return *v, true
  14075. }
  14076. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  14077. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14079. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14080. if !m.op.Is(OpUpdateOne) {
  14081. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14082. }
  14083. if m.id == nil || m.oldValue == nil {
  14084. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14085. }
  14086. oldValue, err := m.oldValue(ctx)
  14087. if err != nil {
  14088. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14089. }
  14090. return oldValue.CreatedAt, nil
  14091. }
  14092. // ResetCreatedAt resets all changes to the "created_at" field.
  14093. func (m *MessageRecordsMutation) ResetCreatedAt() {
  14094. m.created_at = nil
  14095. }
  14096. // SetUpdatedAt sets the "updated_at" field.
  14097. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  14098. m.updated_at = &t
  14099. }
  14100. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14101. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  14102. v := m.updated_at
  14103. if v == nil {
  14104. return
  14105. }
  14106. return *v, true
  14107. }
  14108. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  14109. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14111. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14112. if !m.op.Is(OpUpdateOne) {
  14113. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14114. }
  14115. if m.id == nil || m.oldValue == nil {
  14116. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14117. }
  14118. oldValue, err := m.oldValue(ctx)
  14119. if err != nil {
  14120. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14121. }
  14122. return oldValue.UpdatedAt, nil
  14123. }
  14124. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14125. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  14126. m.updated_at = nil
  14127. }
  14128. // SetStatus sets the "status" field.
  14129. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  14130. m.status = &u
  14131. m.addstatus = nil
  14132. }
  14133. // Status returns the value of the "status" field in the mutation.
  14134. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  14135. v := m.status
  14136. if v == nil {
  14137. return
  14138. }
  14139. return *v, true
  14140. }
  14141. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  14142. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14144. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14145. if !m.op.Is(OpUpdateOne) {
  14146. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14147. }
  14148. if m.id == nil || m.oldValue == nil {
  14149. return v, errors.New("OldStatus requires an ID field in the mutation")
  14150. }
  14151. oldValue, err := m.oldValue(ctx)
  14152. if err != nil {
  14153. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14154. }
  14155. return oldValue.Status, nil
  14156. }
  14157. // AddStatus adds u to the "status" field.
  14158. func (m *MessageRecordsMutation) AddStatus(u int8) {
  14159. if m.addstatus != nil {
  14160. *m.addstatus += u
  14161. } else {
  14162. m.addstatus = &u
  14163. }
  14164. }
  14165. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14166. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  14167. v := m.addstatus
  14168. if v == nil {
  14169. return
  14170. }
  14171. return *v, true
  14172. }
  14173. // ClearStatus clears the value of the "status" field.
  14174. func (m *MessageRecordsMutation) ClearStatus() {
  14175. m.status = nil
  14176. m.addstatus = nil
  14177. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  14178. }
  14179. // StatusCleared returns if the "status" field was cleared in this mutation.
  14180. func (m *MessageRecordsMutation) StatusCleared() bool {
  14181. _, ok := m.clearedFields[messagerecords.FieldStatus]
  14182. return ok
  14183. }
  14184. // ResetStatus resets all changes to the "status" field.
  14185. func (m *MessageRecordsMutation) ResetStatus() {
  14186. m.status = nil
  14187. m.addstatus = nil
  14188. delete(m.clearedFields, messagerecords.FieldStatus)
  14189. }
  14190. // SetBotWxid sets the "bot_wxid" field.
  14191. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  14192. m.bot_wxid = &s
  14193. }
  14194. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  14195. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  14196. v := m.bot_wxid
  14197. if v == nil {
  14198. return
  14199. }
  14200. return *v, true
  14201. }
  14202. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  14203. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14205. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  14206. if !m.op.Is(OpUpdateOne) {
  14207. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  14208. }
  14209. if m.id == nil || m.oldValue == nil {
  14210. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  14211. }
  14212. oldValue, err := m.oldValue(ctx)
  14213. if err != nil {
  14214. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  14215. }
  14216. return oldValue.BotWxid, nil
  14217. }
  14218. // ResetBotWxid resets all changes to the "bot_wxid" field.
  14219. func (m *MessageRecordsMutation) ResetBotWxid() {
  14220. m.bot_wxid = nil
  14221. }
  14222. // SetContactID sets the "contact_id" field.
  14223. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  14224. m.message_contact = &u
  14225. }
  14226. // ContactID returns the value of the "contact_id" field in the mutation.
  14227. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  14228. v := m.message_contact
  14229. if v == nil {
  14230. return
  14231. }
  14232. return *v, true
  14233. }
  14234. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  14235. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14237. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14238. if !m.op.Is(OpUpdateOne) {
  14239. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14240. }
  14241. if m.id == nil || m.oldValue == nil {
  14242. return v, errors.New("OldContactID requires an ID field in the mutation")
  14243. }
  14244. oldValue, err := m.oldValue(ctx)
  14245. if err != nil {
  14246. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14247. }
  14248. return oldValue.ContactID, nil
  14249. }
  14250. // ClearContactID clears the value of the "contact_id" field.
  14251. func (m *MessageRecordsMutation) ClearContactID() {
  14252. m.message_contact = nil
  14253. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14254. }
  14255. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  14256. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  14257. _, ok := m.clearedFields[messagerecords.FieldContactID]
  14258. return ok
  14259. }
  14260. // ResetContactID resets all changes to the "contact_id" field.
  14261. func (m *MessageRecordsMutation) ResetContactID() {
  14262. m.message_contact = nil
  14263. delete(m.clearedFields, messagerecords.FieldContactID)
  14264. }
  14265. // SetContactType sets the "contact_type" field.
  14266. func (m *MessageRecordsMutation) SetContactType(i int) {
  14267. m.contact_type = &i
  14268. m.addcontact_type = nil
  14269. }
  14270. // ContactType returns the value of the "contact_type" field in the mutation.
  14271. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  14272. v := m.contact_type
  14273. if v == nil {
  14274. return
  14275. }
  14276. return *v, true
  14277. }
  14278. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  14279. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14281. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  14282. if !m.op.Is(OpUpdateOne) {
  14283. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  14284. }
  14285. if m.id == nil || m.oldValue == nil {
  14286. return v, errors.New("OldContactType requires an ID field in the mutation")
  14287. }
  14288. oldValue, err := m.oldValue(ctx)
  14289. if err != nil {
  14290. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  14291. }
  14292. return oldValue.ContactType, nil
  14293. }
  14294. // AddContactType adds i to the "contact_type" field.
  14295. func (m *MessageRecordsMutation) AddContactType(i int) {
  14296. if m.addcontact_type != nil {
  14297. *m.addcontact_type += i
  14298. } else {
  14299. m.addcontact_type = &i
  14300. }
  14301. }
  14302. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  14303. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  14304. v := m.addcontact_type
  14305. if v == nil {
  14306. return
  14307. }
  14308. return *v, true
  14309. }
  14310. // ResetContactType resets all changes to the "contact_type" field.
  14311. func (m *MessageRecordsMutation) ResetContactType() {
  14312. m.contact_type = nil
  14313. m.addcontact_type = nil
  14314. }
  14315. // SetContactWxid sets the "contact_wxid" field.
  14316. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  14317. m.contact_wxid = &s
  14318. }
  14319. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  14320. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  14321. v := m.contact_wxid
  14322. if v == nil {
  14323. return
  14324. }
  14325. return *v, true
  14326. }
  14327. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  14328. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14330. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  14331. if !m.op.Is(OpUpdateOne) {
  14332. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  14333. }
  14334. if m.id == nil || m.oldValue == nil {
  14335. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  14336. }
  14337. oldValue, err := m.oldValue(ctx)
  14338. if err != nil {
  14339. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  14340. }
  14341. return oldValue.ContactWxid, nil
  14342. }
  14343. // ResetContactWxid resets all changes to the "contact_wxid" field.
  14344. func (m *MessageRecordsMutation) ResetContactWxid() {
  14345. m.contact_wxid = nil
  14346. }
  14347. // SetContentType sets the "content_type" field.
  14348. func (m *MessageRecordsMutation) SetContentType(i int) {
  14349. m.content_type = &i
  14350. m.addcontent_type = nil
  14351. }
  14352. // ContentType returns the value of the "content_type" field in the mutation.
  14353. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  14354. v := m.content_type
  14355. if v == nil {
  14356. return
  14357. }
  14358. return *v, true
  14359. }
  14360. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  14361. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14363. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  14364. if !m.op.Is(OpUpdateOne) {
  14365. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  14366. }
  14367. if m.id == nil || m.oldValue == nil {
  14368. return v, errors.New("OldContentType requires an ID field in the mutation")
  14369. }
  14370. oldValue, err := m.oldValue(ctx)
  14371. if err != nil {
  14372. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  14373. }
  14374. return oldValue.ContentType, nil
  14375. }
  14376. // AddContentType adds i to the "content_type" field.
  14377. func (m *MessageRecordsMutation) AddContentType(i int) {
  14378. if m.addcontent_type != nil {
  14379. *m.addcontent_type += i
  14380. } else {
  14381. m.addcontent_type = &i
  14382. }
  14383. }
  14384. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  14385. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  14386. v := m.addcontent_type
  14387. if v == nil {
  14388. return
  14389. }
  14390. return *v, true
  14391. }
  14392. // ResetContentType resets all changes to the "content_type" field.
  14393. func (m *MessageRecordsMutation) ResetContentType() {
  14394. m.content_type = nil
  14395. m.addcontent_type = nil
  14396. }
  14397. // SetContent sets the "content" field.
  14398. func (m *MessageRecordsMutation) SetContent(s string) {
  14399. m.content = &s
  14400. }
  14401. // Content returns the value of the "content" field in the mutation.
  14402. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  14403. v := m.content
  14404. if v == nil {
  14405. return
  14406. }
  14407. return *v, true
  14408. }
  14409. // OldContent returns the old "content" field's value of the MessageRecords entity.
  14410. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14412. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  14413. if !m.op.Is(OpUpdateOne) {
  14414. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  14415. }
  14416. if m.id == nil || m.oldValue == nil {
  14417. return v, errors.New("OldContent requires an ID field in the mutation")
  14418. }
  14419. oldValue, err := m.oldValue(ctx)
  14420. if err != nil {
  14421. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  14422. }
  14423. return oldValue.Content, nil
  14424. }
  14425. // ResetContent resets all changes to the "content" field.
  14426. func (m *MessageRecordsMutation) ResetContent() {
  14427. m.content = nil
  14428. }
  14429. // SetMeta sets the "meta" field.
  14430. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  14431. m.meta = &ct
  14432. }
  14433. // Meta returns the value of the "meta" field in the mutation.
  14434. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  14435. v := m.meta
  14436. if v == nil {
  14437. return
  14438. }
  14439. return *v, true
  14440. }
  14441. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  14442. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14444. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  14445. if !m.op.Is(OpUpdateOne) {
  14446. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  14447. }
  14448. if m.id == nil || m.oldValue == nil {
  14449. return v, errors.New("OldMeta requires an ID field in the mutation")
  14450. }
  14451. oldValue, err := m.oldValue(ctx)
  14452. if err != nil {
  14453. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  14454. }
  14455. return oldValue.Meta, nil
  14456. }
  14457. // ClearMeta clears the value of the "meta" field.
  14458. func (m *MessageRecordsMutation) ClearMeta() {
  14459. m.meta = nil
  14460. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  14461. }
  14462. // MetaCleared returns if the "meta" field was cleared in this mutation.
  14463. func (m *MessageRecordsMutation) MetaCleared() bool {
  14464. _, ok := m.clearedFields[messagerecords.FieldMeta]
  14465. return ok
  14466. }
  14467. // ResetMeta resets all changes to the "meta" field.
  14468. func (m *MessageRecordsMutation) ResetMeta() {
  14469. m.meta = nil
  14470. delete(m.clearedFields, messagerecords.FieldMeta)
  14471. }
  14472. // SetErrorDetail sets the "error_detail" field.
  14473. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  14474. m.error_detail = &s
  14475. }
  14476. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  14477. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  14478. v := m.error_detail
  14479. if v == nil {
  14480. return
  14481. }
  14482. return *v, true
  14483. }
  14484. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  14485. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14487. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  14488. if !m.op.Is(OpUpdateOne) {
  14489. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  14490. }
  14491. if m.id == nil || m.oldValue == nil {
  14492. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  14493. }
  14494. oldValue, err := m.oldValue(ctx)
  14495. if err != nil {
  14496. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  14497. }
  14498. return oldValue.ErrorDetail, nil
  14499. }
  14500. // ResetErrorDetail resets all changes to the "error_detail" field.
  14501. func (m *MessageRecordsMutation) ResetErrorDetail() {
  14502. m.error_detail = nil
  14503. }
  14504. // SetSendTime sets the "send_time" field.
  14505. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  14506. m.send_time = &t
  14507. }
  14508. // SendTime returns the value of the "send_time" field in the mutation.
  14509. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  14510. v := m.send_time
  14511. if v == nil {
  14512. return
  14513. }
  14514. return *v, true
  14515. }
  14516. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  14517. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14519. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  14520. if !m.op.Is(OpUpdateOne) {
  14521. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  14522. }
  14523. if m.id == nil || m.oldValue == nil {
  14524. return v, errors.New("OldSendTime requires an ID field in the mutation")
  14525. }
  14526. oldValue, err := m.oldValue(ctx)
  14527. if err != nil {
  14528. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  14529. }
  14530. return oldValue.SendTime, nil
  14531. }
  14532. // ClearSendTime clears the value of the "send_time" field.
  14533. func (m *MessageRecordsMutation) ClearSendTime() {
  14534. m.send_time = nil
  14535. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  14536. }
  14537. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  14538. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  14539. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  14540. return ok
  14541. }
  14542. // ResetSendTime resets all changes to the "send_time" field.
  14543. func (m *MessageRecordsMutation) ResetSendTime() {
  14544. m.send_time = nil
  14545. delete(m.clearedFields, messagerecords.FieldSendTime)
  14546. }
  14547. // SetSourceType sets the "source_type" field.
  14548. func (m *MessageRecordsMutation) SetSourceType(i int) {
  14549. m.source_type = &i
  14550. m.addsource_type = nil
  14551. }
  14552. // SourceType returns the value of the "source_type" field in the mutation.
  14553. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  14554. v := m.source_type
  14555. if v == nil {
  14556. return
  14557. }
  14558. return *v, true
  14559. }
  14560. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  14561. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14563. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  14564. if !m.op.Is(OpUpdateOne) {
  14565. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  14566. }
  14567. if m.id == nil || m.oldValue == nil {
  14568. return v, errors.New("OldSourceType requires an ID field in the mutation")
  14569. }
  14570. oldValue, err := m.oldValue(ctx)
  14571. if err != nil {
  14572. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  14573. }
  14574. return oldValue.SourceType, nil
  14575. }
  14576. // AddSourceType adds i to the "source_type" field.
  14577. func (m *MessageRecordsMutation) AddSourceType(i int) {
  14578. if m.addsource_type != nil {
  14579. *m.addsource_type += i
  14580. } else {
  14581. m.addsource_type = &i
  14582. }
  14583. }
  14584. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  14585. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  14586. v := m.addsource_type
  14587. if v == nil {
  14588. return
  14589. }
  14590. return *v, true
  14591. }
  14592. // ResetSourceType resets all changes to the "source_type" field.
  14593. func (m *MessageRecordsMutation) ResetSourceType() {
  14594. m.source_type = nil
  14595. m.addsource_type = nil
  14596. }
  14597. // SetSourceID sets the "source_id" field.
  14598. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  14599. m.sop_stage = &u
  14600. }
  14601. // SourceID returns the value of the "source_id" field in the mutation.
  14602. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  14603. v := m.sop_stage
  14604. if v == nil {
  14605. return
  14606. }
  14607. return *v, true
  14608. }
  14609. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  14610. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14612. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  14613. if !m.op.Is(OpUpdateOne) {
  14614. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  14615. }
  14616. if m.id == nil || m.oldValue == nil {
  14617. return v, errors.New("OldSourceID requires an ID field in the mutation")
  14618. }
  14619. oldValue, err := m.oldValue(ctx)
  14620. if err != nil {
  14621. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  14622. }
  14623. return oldValue.SourceID, nil
  14624. }
  14625. // ClearSourceID clears the value of the "source_id" field.
  14626. func (m *MessageRecordsMutation) ClearSourceID() {
  14627. m.sop_stage = nil
  14628. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14629. }
  14630. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  14631. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  14632. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  14633. return ok
  14634. }
  14635. // ResetSourceID resets all changes to the "source_id" field.
  14636. func (m *MessageRecordsMutation) ResetSourceID() {
  14637. m.sop_stage = nil
  14638. delete(m.clearedFields, messagerecords.FieldSourceID)
  14639. }
  14640. // SetSubSourceID sets the "sub_source_id" field.
  14641. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  14642. m.sop_node = &u
  14643. }
  14644. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  14645. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  14646. v := m.sop_node
  14647. if v == nil {
  14648. return
  14649. }
  14650. return *v, true
  14651. }
  14652. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  14653. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14655. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  14656. if !m.op.Is(OpUpdateOne) {
  14657. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  14658. }
  14659. if m.id == nil || m.oldValue == nil {
  14660. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  14661. }
  14662. oldValue, err := m.oldValue(ctx)
  14663. if err != nil {
  14664. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  14665. }
  14666. return oldValue.SubSourceID, nil
  14667. }
  14668. // ClearSubSourceID clears the value of the "sub_source_id" field.
  14669. func (m *MessageRecordsMutation) ClearSubSourceID() {
  14670. m.sop_node = nil
  14671. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14672. }
  14673. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  14674. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  14675. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  14676. return ok
  14677. }
  14678. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  14679. func (m *MessageRecordsMutation) ResetSubSourceID() {
  14680. m.sop_node = nil
  14681. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  14682. }
  14683. // SetOrganizationID sets the "organization_id" field.
  14684. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  14685. m.organization_id = &u
  14686. m.addorganization_id = nil
  14687. }
  14688. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14689. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  14690. v := m.organization_id
  14691. if v == nil {
  14692. return
  14693. }
  14694. return *v, true
  14695. }
  14696. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  14697. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14699. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14700. if !m.op.Is(OpUpdateOne) {
  14701. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14702. }
  14703. if m.id == nil || m.oldValue == nil {
  14704. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14705. }
  14706. oldValue, err := m.oldValue(ctx)
  14707. if err != nil {
  14708. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14709. }
  14710. return oldValue.OrganizationID, nil
  14711. }
  14712. // AddOrganizationID adds u to the "organization_id" field.
  14713. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  14714. if m.addorganization_id != nil {
  14715. *m.addorganization_id += u
  14716. } else {
  14717. m.addorganization_id = &u
  14718. }
  14719. }
  14720. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14721. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  14722. v := m.addorganization_id
  14723. if v == nil {
  14724. return
  14725. }
  14726. return *v, true
  14727. }
  14728. // ClearOrganizationID clears the value of the "organization_id" field.
  14729. func (m *MessageRecordsMutation) ClearOrganizationID() {
  14730. m.organization_id = nil
  14731. m.addorganization_id = nil
  14732. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  14733. }
  14734. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14735. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  14736. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  14737. return ok
  14738. }
  14739. // ResetOrganizationID resets all changes to the "organization_id" field.
  14740. func (m *MessageRecordsMutation) ResetOrganizationID() {
  14741. m.organization_id = nil
  14742. m.addorganization_id = nil
  14743. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  14744. }
  14745. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  14746. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  14747. m.sop_stage = &id
  14748. }
  14749. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  14750. func (m *MessageRecordsMutation) ClearSopStage() {
  14751. m.clearedsop_stage = true
  14752. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14753. }
  14754. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  14755. func (m *MessageRecordsMutation) SopStageCleared() bool {
  14756. return m.SourceIDCleared() || m.clearedsop_stage
  14757. }
  14758. // SopStageID returns the "sop_stage" edge ID in the mutation.
  14759. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  14760. if m.sop_stage != nil {
  14761. return *m.sop_stage, true
  14762. }
  14763. return
  14764. }
  14765. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  14766. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14767. // SopStageID instead. It exists only for internal usage by the builders.
  14768. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  14769. if id := m.sop_stage; id != nil {
  14770. ids = append(ids, *id)
  14771. }
  14772. return
  14773. }
  14774. // ResetSopStage resets all changes to the "sop_stage" edge.
  14775. func (m *MessageRecordsMutation) ResetSopStage() {
  14776. m.sop_stage = nil
  14777. m.clearedsop_stage = false
  14778. }
  14779. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  14780. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  14781. m.sop_node = &id
  14782. }
  14783. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  14784. func (m *MessageRecordsMutation) ClearSopNode() {
  14785. m.clearedsop_node = true
  14786. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14787. }
  14788. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  14789. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  14790. return m.SubSourceIDCleared() || m.clearedsop_node
  14791. }
  14792. // SopNodeID returns the "sop_node" edge ID in the mutation.
  14793. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  14794. if m.sop_node != nil {
  14795. return *m.sop_node, true
  14796. }
  14797. return
  14798. }
  14799. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  14800. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14801. // SopNodeID instead. It exists only for internal usage by the builders.
  14802. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  14803. if id := m.sop_node; id != nil {
  14804. ids = append(ids, *id)
  14805. }
  14806. return
  14807. }
  14808. // ResetSopNode resets all changes to the "sop_node" edge.
  14809. func (m *MessageRecordsMutation) ResetSopNode() {
  14810. m.sop_node = nil
  14811. m.clearedsop_node = false
  14812. }
  14813. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  14814. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  14815. m.message_contact = &id
  14816. }
  14817. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  14818. func (m *MessageRecordsMutation) ClearMessageContact() {
  14819. m.clearedmessage_contact = true
  14820. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14821. }
  14822. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  14823. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  14824. return m.ContactIDCleared() || m.clearedmessage_contact
  14825. }
  14826. // MessageContactID returns the "message_contact" edge ID in the mutation.
  14827. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  14828. if m.message_contact != nil {
  14829. return *m.message_contact, true
  14830. }
  14831. return
  14832. }
  14833. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  14834. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14835. // MessageContactID instead. It exists only for internal usage by the builders.
  14836. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  14837. if id := m.message_contact; id != nil {
  14838. ids = append(ids, *id)
  14839. }
  14840. return
  14841. }
  14842. // ResetMessageContact resets all changes to the "message_contact" edge.
  14843. func (m *MessageRecordsMutation) ResetMessageContact() {
  14844. m.message_contact = nil
  14845. m.clearedmessage_contact = false
  14846. }
  14847. // Where appends a list predicates to the MessageRecordsMutation builder.
  14848. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  14849. m.predicates = append(m.predicates, ps...)
  14850. }
  14851. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  14852. // users can use type-assertion to append predicates that do not depend on any generated package.
  14853. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  14854. p := make([]predicate.MessageRecords, len(ps))
  14855. for i := range ps {
  14856. p[i] = ps[i]
  14857. }
  14858. m.Where(p...)
  14859. }
  14860. // Op returns the operation name.
  14861. func (m *MessageRecordsMutation) Op() Op {
  14862. return m.op
  14863. }
  14864. // SetOp allows setting the mutation operation.
  14865. func (m *MessageRecordsMutation) SetOp(op Op) {
  14866. m.op = op
  14867. }
  14868. // Type returns the node type of this mutation (MessageRecords).
  14869. func (m *MessageRecordsMutation) Type() string {
  14870. return m.typ
  14871. }
  14872. // Fields returns all fields that were changed during this mutation. Note that in
  14873. // order to get all numeric fields that were incremented/decremented, call
  14874. // AddedFields().
  14875. func (m *MessageRecordsMutation) Fields() []string {
  14876. fields := make([]string, 0, 16)
  14877. if m.created_at != nil {
  14878. fields = append(fields, messagerecords.FieldCreatedAt)
  14879. }
  14880. if m.updated_at != nil {
  14881. fields = append(fields, messagerecords.FieldUpdatedAt)
  14882. }
  14883. if m.status != nil {
  14884. fields = append(fields, messagerecords.FieldStatus)
  14885. }
  14886. if m.bot_wxid != nil {
  14887. fields = append(fields, messagerecords.FieldBotWxid)
  14888. }
  14889. if m.message_contact != nil {
  14890. fields = append(fields, messagerecords.FieldContactID)
  14891. }
  14892. if m.contact_type != nil {
  14893. fields = append(fields, messagerecords.FieldContactType)
  14894. }
  14895. if m.contact_wxid != nil {
  14896. fields = append(fields, messagerecords.FieldContactWxid)
  14897. }
  14898. if m.content_type != nil {
  14899. fields = append(fields, messagerecords.FieldContentType)
  14900. }
  14901. if m.content != nil {
  14902. fields = append(fields, messagerecords.FieldContent)
  14903. }
  14904. if m.meta != nil {
  14905. fields = append(fields, messagerecords.FieldMeta)
  14906. }
  14907. if m.error_detail != nil {
  14908. fields = append(fields, messagerecords.FieldErrorDetail)
  14909. }
  14910. if m.send_time != nil {
  14911. fields = append(fields, messagerecords.FieldSendTime)
  14912. }
  14913. if m.source_type != nil {
  14914. fields = append(fields, messagerecords.FieldSourceType)
  14915. }
  14916. if m.sop_stage != nil {
  14917. fields = append(fields, messagerecords.FieldSourceID)
  14918. }
  14919. if m.sop_node != nil {
  14920. fields = append(fields, messagerecords.FieldSubSourceID)
  14921. }
  14922. if m.organization_id != nil {
  14923. fields = append(fields, messagerecords.FieldOrganizationID)
  14924. }
  14925. return fields
  14926. }
  14927. // Field returns the value of a field with the given name. The second boolean
  14928. // return value indicates that this field was not set, or was not defined in the
  14929. // schema.
  14930. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  14931. switch name {
  14932. case messagerecords.FieldCreatedAt:
  14933. return m.CreatedAt()
  14934. case messagerecords.FieldUpdatedAt:
  14935. return m.UpdatedAt()
  14936. case messagerecords.FieldStatus:
  14937. return m.Status()
  14938. case messagerecords.FieldBotWxid:
  14939. return m.BotWxid()
  14940. case messagerecords.FieldContactID:
  14941. return m.ContactID()
  14942. case messagerecords.FieldContactType:
  14943. return m.ContactType()
  14944. case messagerecords.FieldContactWxid:
  14945. return m.ContactWxid()
  14946. case messagerecords.FieldContentType:
  14947. return m.ContentType()
  14948. case messagerecords.FieldContent:
  14949. return m.Content()
  14950. case messagerecords.FieldMeta:
  14951. return m.Meta()
  14952. case messagerecords.FieldErrorDetail:
  14953. return m.ErrorDetail()
  14954. case messagerecords.FieldSendTime:
  14955. return m.SendTime()
  14956. case messagerecords.FieldSourceType:
  14957. return m.SourceType()
  14958. case messagerecords.FieldSourceID:
  14959. return m.SourceID()
  14960. case messagerecords.FieldSubSourceID:
  14961. return m.SubSourceID()
  14962. case messagerecords.FieldOrganizationID:
  14963. return m.OrganizationID()
  14964. }
  14965. return nil, false
  14966. }
  14967. // OldField returns the old value of the field from the database. An error is
  14968. // returned if the mutation operation is not UpdateOne, or the query to the
  14969. // database failed.
  14970. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14971. switch name {
  14972. case messagerecords.FieldCreatedAt:
  14973. return m.OldCreatedAt(ctx)
  14974. case messagerecords.FieldUpdatedAt:
  14975. return m.OldUpdatedAt(ctx)
  14976. case messagerecords.FieldStatus:
  14977. return m.OldStatus(ctx)
  14978. case messagerecords.FieldBotWxid:
  14979. return m.OldBotWxid(ctx)
  14980. case messagerecords.FieldContactID:
  14981. return m.OldContactID(ctx)
  14982. case messagerecords.FieldContactType:
  14983. return m.OldContactType(ctx)
  14984. case messagerecords.FieldContactWxid:
  14985. return m.OldContactWxid(ctx)
  14986. case messagerecords.FieldContentType:
  14987. return m.OldContentType(ctx)
  14988. case messagerecords.FieldContent:
  14989. return m.OldContent(ctx)
  14990. case messagerecords.FieldMeta:
  14991. return m.OldMeta(ctx)
  14992. case messagerecords.FieldErrorDetail:
  14993. return m.OldErrorDetail(ctx)
  14994. case messagerecords.FieldSendTime:
  14995. return m.OldSendTime(ctx)
  14996. case messagerecords.FieldSourceType:
  14997. return m.OldSourceType(ctx)
  14998. case messagerecords.FieldSourceID:
  14999. return m.OldSourceID(ctx)
  15000. case messagerecords.FieldSubSourceID:
  15001. return m.OldSubSourceID(ctx)
  15002. case messagerecords.FieldOrganizationID:
  15003. return m.OldOrganizationID(ctx)
  15004. }
  15005. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  15006. }
  15007. // SetField sets the value of a field with the given name. It returns an error if
  15008. // the field is not defined in the schema, or if the type mismatched the field
  15009. // type.
  15010. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  15011. switch name {
  15012. case messagerecords.FieldCreatedAt:
  15013. v, ok := value.(time.Time)
  15014. if !ok {
  15015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15016. }
  15017. m.SetCreatedAt(v)
  15018. return nil
  15019. case messagerecords.FieldUpdatedAt:
  15020. v, ok := value.(time.Time)
  15021. if !ok {
  15022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15023. }
  15024. m.SetUpdatedAt(v)
  15025. return nil
  15026. case messagerecords.FieldStatus:
  15027. v, ok := value.(uint8)
  15028. if !ok {
  15029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15030. }
  15031. m.SetStatus(v)
  15032. return nil
  15033. case messagerecords.FieldBotWxid:
  15034. v, ok := value.(string)
  15035. if !ok {
  15036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15037. }
  15038. m.SetBotWxid(v)
  15039. return nil
  15040. case messagerecords.FieldContactID:
  15041. v, ok := value.(uint64)
  15042. if !ok {
  15043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15044. }
  15045. m.SetContactID(v)
  15046. return nil
  15047. case messagerecords.FieldContactType:
  15048. v, ok := value.(int)
  15049. if !ok {
  15050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15051. }
  15052. m.SetContactType(v)
  15053. return nil
  15054. case messagerecords.FieldContactWxid:
  15055. v, ok := value.(string)
  15056. if !ok {
  15057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15058. }
  15059. m.SetContactWxid(v)
  15060. return nil
  15061. case messagerecords.FieldContentType:
  15062. v, ok := value.(int)
  15063. if !ok {
  15064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15065. }
  15066. m.SetContentType(v)
  15067. return nil
  15068. case messagerecords.FieldContent:
  15069. v, ok := value.(string)
  15070. if !ok {
  15071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15072. }
  15073. m.SetContent(v)
  15074. return nil
  15075. case messagerecords.FieldMeta:
  15076. v, ok := value.(custom_types.Meta)
  15077. if !ok {
  15078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15079. }
  15080. m.SetMeta(v)
  15081. return nil
  15082. case messagerecords.FieldErrorDetail:
  15083. v, ok := value.(string)
  15084. if !ok {
  15085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15086. }
  15087. m.SetErrorDetail(v)
  15088. return nil
  15089. case messagerecords.FieldSendTime:
  15090. v, ok := value.(time.Time)
  15091. if !ok {
  15092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15093. }
  15094. m.SetSendTime(v)
  15095. return nil
  15096. case messagerecords.FieldSourceType:
  15097. v, ok := value.(int)
  15098. if !ok {
  15099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15100. }
  15101. m.SetSourceType(v)
  15102. return nil
  15103. case messagerecords.FieldSourceID:
  15104. v, ok := value.(uint64)
  15105. if !ok {
  15106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15107. }
  15108. m.SetSourceID(v)
  15109. return nil
  15110. case messagerecords.FieldSubSourceID:
  15111. v, ok := value.(uint64)
  15112. if !ok {
  15113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15114. }
  15115. m.SetSubSourceID(v)
  15116. return nil
  15117. case messagerecords.FieldOrganizationID:
  15118. v, ok := value.(uint64)
  15119. if !ok {
  15120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15121. }
  15122. m.SetOrganizationID(v)
  15123. return nil
  15124. }
  15125. return fmt.Errorf("unknown MessageRecords field %s", name)
  15126. }
  15127. // AddedFields returns all numeric fields that were incremented/decremented during
  15128. // this mutation.
  15129. func (m *MessageRecordsMutation) AddedFields() []string {
  15130. var fields []string
  15131. if m.addstatus != nil {
  15132. fields = append(fields, messagerecords.FieldStatus)
  15133. }
  15134. if m.addcontact_type != nil {
  15135. fields = append(fields, messagerecords.FieldContactType)
  15136. }
  15137. if m.addcontent_type != nil {
  15138. fields = append(fields, messagerecords.FieldContentType)
  15139. }
  15140. if m.addsource_type != nil {
  15141. fields = append(fields, messagerecords.FieldSourceType)
  15142. }
  15143. if m.addorganization_id != nil {
  15144. fields = append(fields, messagerecords.FieldOrganizationID)
  15145. }
  15146. return fields
  15147. }
  15148. // AddedField returns the numeric value that was incremented/decremented on a field
  15149. // with the given name. The second boolean return value indicates that this field
  15150. // was not set, or was not defined in the schema.
  15151. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  15152. switch name {
  15153. case messagerecords.FieldStatus:
  15154. return m.AddedStatus()
  15155. case messagerecords.FieldContactType:
  15156. return m.AddedContactType()
  15157. case messagerecords.FieldContentType:
  15158. return m.AddedContentType()
  15159. case messagerecords.FieldSourceType:
  15160. return m.AddedSourceType()
  15161. case messagerecords.FieldOrganizationID:
  15162. return m.AddedOrganizationID()
  15163. }
  15164. return nil, false
  15165. }
  15166. // AddField adds the value to the field with the given name. It returns an error if
  15167. // the field is not defined in the schema, or if the type mismatched the field
  15168. // type.
  15169. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  15170. switch name {
  15171. case messagerecords.FieldStatus:
  15172. v, ok := value.(int8)
  15173. if !ok {
  15174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15175. }
  15176. m.AddStatus(v)
  15177. return nil
  15178. case messagerecords.FieldContactType:
  15179. v, ok := value.(int)
  15180. if !ok {
  15181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15182. }
  15183. m.AddContactType(v)
  15184. return nil
  15185. case messagerecords.FieldContentType:
  15186. v, ok := value.(int)
  15187. if !ok {
  15188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15189. }
  15190. m.AddContentType(v)
  15191. return nil
  15192. case messagerecords.FieldSourceType:
  15193. v, ok := value.(int)
  15194. if !ok {
  15195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15196. }
  15197. m.AddSourceType(v)
  15198. return nil
  15199. case messagerecords.FieldOrganizationID:
  15200. v, ok := value.(int64)
  15201. if !ok {
  15202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15203. }
  15204. m.AddOrganizationID(v)
  15205. return nil
  15206. }
  15207. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  15208. }
  15209. // ClearedFields returns all nullable fields that were cleared during this
  15210. // mutation.
  15211. func (m *MessageRecordsMutation) ClearedFields() []string {
  15212. var fields []string
  15213. if m.FieldCleared(messagerecords.FieldStatus) {
  15214. fields = append(fields, messagerecords.FieldStatus)
  15215. }
  15216. if m.FieldCleared(messagerecords.FieldContactID) {
  15217. fields = append(fields, messagerecords.FieldContactID)
  15218. }
  15219. if m.FieldCleared(messagerecords.FieldMeta) {
  15220. fields = append(fields, messagerecords.FieldMeta)
  15221. }
  15222. if m.FieldCleared(messagerecords.FieldSendTime) {
  15223. fields = append(fields, messagerecords.FieldSendTime)
  15224. }
  15225. if m.FieldCleared(messagerecords.FieldSourceID) {
  15226. fields = append(fields, messagerecords.FieldSourceID)
  15227. }
  15228. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  15229. fields = append(fields, messagerecords.FieldSubSourceID)
  15230. }
  15231. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  15232. fields = append(fields, messagerecords.FieldOrganizationID)
  15233. }
  15234. return fields
  15235. }
  15236. // FieldCleared returns a boolean indicating if a field with the given name was
  15237. // cleared in this mutation.
  15238. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  15239. _, ok := m.clearedFields[name]
  15240. return ok
  15241. }
  15242. // ClearField clears the value of the field with the given name. It returns an
  15243. // error if the field is not defined in the schema.
  15244. func (m *MessageRecordsMutation) ClearField(name string) error {
  15245. switch name {
  15246. case messagerecords.FieldStatus:
  15247. m.ClearStatus()
  15248. return nil
  15249. case messagerecords.FieldContactID:
  15250. m.ClearContactID()
  15251. return nil
  15252. case messagerecords.FieldMeta:
  15253. m.ClearMeta()
  15254. return nil
  15255. case messagerecords.FieldSendTime:
  15256. m.ClearSendTime()
  15257. return nil
  15258. case messagerecords.FieldSourceID:
  15259. m.ClearSourceID()
  15260. return nil
  15261. case messagerecords.FieldSubSourceID:
  15262. m.ClearSubSourceID()
  15263. return nil
  15264. case messagerecords.FieldOrganizationID:
  15265. m.ClearOrganizationID()
  15266. return nil
  15267. }
  15268. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  15269. }
  15270. // ResetField resets all changes in the mutation for the field with the given name.
  15271. // It returns an error if the field is not defined in the schema.
  15272. func (m *MessageRecordsMutation) ResetField(name string) error {
  15273. switch name {
  15274. case messagerecords.FieldCreatedAt:
  15275. m.ResetCreatedAt()
  15276. return nil
  15277. case messagerecords.FieldUpdatedAt:
  15278. m.ResetUpdatedAt()
  15279. return nil
  15280. case messagerecords.FieldStatus:
  15281. m.ResetStatus()
  15282. return nil
  15283. case messagerecords.FieldBotWxid:
  15284. m.ResetBotWxid()
  15285. return nil
  15286. case messagerecords.FieldContactID:
  15287. m.ResetContactID()
  15288. return nil
  15289. case messagerecords.FieldContactType:
  15290. m.ResetContactType()
  15291. return nil
  15292. case messagerecords.FieldContactWxid:
  15293. m.ResetContactWxid()
  15294. return nil
  15295. case messagerecords.FieldContentType:
  15296. m.ResetContentType()
  15297. return nil
  15298. case messagerecords.FieldContent:
  15299. m.ResetContent()
  15300. return nil
  15301. case messagerecords.FieldMeta:
  15302. m.ResetMeta()
  15303. return nil
  15304. case messagerecords.FieldErrorDetail:
  15305. m.ResetErrorDetail()
  15306. return nil
  15307. case messagerecords.FieldSendTime:
  15308. m.ResetSendTime()
  15309. return nil
  15310. case messagerecords.FieldSourceType:
  15311. m.ResetSourceType()
  15312. return nil
  15313. case messagerecords.FieldSourceID:
  15314. m.ResetSourceID()
  15315. return nil
  15316. case messagerecords.FieldSubSourceID:
  15317. m.ResetSubSourceID()
  15318. return nil
  15319. case messagerecords.FieldOrganizationID:
  15320. m.ResetOrganizationID()
  15321. return nil
  15322. }
  15323. return fmt.Errorf("unknown MessageRecords field %s", name)
  15324. }
  15325. // AddedEdges returns all edge names that were set/added in this mutation.
  15326. func (m *MessageRecordsMutation) AddedEdges() []string {
  15327. edges := make([]string, 0, 3)
  15328. if m.sop_stage != nil {
  15329. edges = append(edges, messagerecords.EdgeSopStage)
  15330. }
  15331. if m.sop_node != nil {
  15332. edges = append(edges, messagerecords.EdgeSopNode)
  15333. }
  15334. if m.message_contact != nil {
  15335. edges = append(edges, messagerecords.EdgeMessageContact)
  15336. }
  15337. return edges
  15338. }
  15339. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15340. // name in this mutation.
  15341. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  15342. switch name {
  15343. case messagerecords.EdgeSopStage:
  15344. if id := m.sop_stage; id != nil {
  15345. return []ent.Value{*id}
  15346. }
  15347. case messagerecords.EdgeSopNode:
  15348. if id := m.sop_node; id != nil {
  15349. return []ent.Value{*id}
  15350. }
  15351. case messagerecords.EdgeMessageContact:
  15352. if id := m.message_contact; id != nil {
  15353. return []ent.Value{*id}
  15354. }
  15355. }
  15356. return nil
  15357. }
  15358. // RemovedEdges returns all edge names that were removed in this mutation.
  15359. func (m *MessageRecordsMutation) RemovedEdges() []string {
  15360. edges := make([]string, 0, 3)
  15361. return edges
  15362. }
  15363. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15364. // the given name in this mutation.
  15365. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  15366. return nil
  15367. }
  15368. // ClearedEdges returns all edge names that were cleared in this mutation.
  15369. func (m *MessageRecordsMutation) ClearedEdges() []string {
  15370. edges := make([]string, 0, 3)
  15371. if m.clearedsop_stage {
  15372. edges = append(edges, messagerecords.EdgeSopStage)
  15373. }
  15374. if m.clearedsop_node {
  15375. edges = append(edges, messagerecords.EdgeSopNode)
  15376. }
  15377. if m.clearedmessage_contact {
  15378. edges = append(edges, messagerecords.EdgeMessageContact)
  15379. }
  15380. return edges
  15381. }
  15382. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15383. // was cleared in this mutation.
  15384. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  15385. switch name {
  15386. case messagerecords.EdgeSopStage:
  15387. return m.clearedsop_stage
  15388. case messagerecords.EdgeSopNode:
  15389. return m.clearedsop_node
  15390. case messagerecords.EdgeMessageContact:
  15391. return m.clearedmessage_contact
  15392. }
  15393. return false
  15394. }
  15395. // ClearEdge clears the value of the edge with the given name. It returns an error
  15396. // if that edge is not defined in the schema.
  15397. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  15398. switch name {
  15399. case messagerecords.EdgeSopStage:
  15400. m.ClearSopStage()
  15401. return nil
  15402. case messagerecords.EdgeSopNode:
  15403. m.ClearSopNode()
  15404. return nil
  15405. case messagerecords.EdgeMessageContact:
  15406. m.ClearMessageContact()
  15407. return nil
  15408. }
  15409. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  15410. }
  15411. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15412. // It returns an error if the edge is not defined in the schema.
  15413. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  15414. switch name {
  15415. case messagerecords.EdgeSopStage:
  15416. m.ResetSopStage()
  15417. return nil
  15418. case messagerecords.EdgeSopNode:
  15419. m.ResetSopNode()
  15420. return nil
  15421. case messagerecords.EdgeMessageContact:
  15422. m.ResetMessageContact()
  15423. return nil
  15424. }
  15425. return fmt.Errorf("unknown MessageRecords edge %s", name)
  15426. }
  15427. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  15428. type MsgMutation struct {
  15429. config
  15430. op Op
  15431. typ string
  15432. id *uint64
  15433. created_at *time.Time
  15434. updated_at *time.Time
  15435. deleted_at *time.Time
  15436. status *uint8
  15437. addstatus *int8
  15438. fromwxid *string
  15439. toid *string
  15440. msgtype *int32
  15441. addmsgtype *int32
  15442. msg *string
  15443. batch_no *string
  15444. clearedFields map[string]struct{}
  15445. done bool
  15446. oldValue func(context.Context) (*Msg, error)
  15447. predicates []predicate.Msg
  15448. }
  15449. var _ ent.Mutation = (*MsgMutation)(nil)
  15450. // msgOption allows management of the mutation configuration using functional options.
  15451. type msgOption func(*MsgMutation)
  15452. // newMsgMutation creates new mutation for the Msg entity.
  15453. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  15454. m := &MsgMutation{
  15455. config: c,
  15456. op: op,
  15457. typ: TypeMsg,
  15458. clearedFields: make(map[string]struct{}),
  15459. }
  15460. for _, opt := range opts {
  15461. opt(m)
  15462. }
  15463. return m
  15464. }
  15465. // withMsgID sets the ID field of the mutation.
  15466. func withMsgID(id uint64) msgOption {
  15467. return func(m *MsgMutation) {
  15468. var (
  15469. err error
  15470. once sync.Once
  15471. value *Msg
  15472. )
  15473. m.oldValue = func(ctx context.Context) (*Msg, error) {
  15474. once.Do(func() {
  15475. if m.done {
  15476. err = errors.New("querying old values post mutation is not allowed")
  15477. } else {
  15478. value, err = m.Client().Msg.Get(ctx, id)
  15479. }
  15480. })
  15481. return value, err
  15482. }
  15483. m.id = &id
  15484. }
  15485. }
  15486. // withMsg sets the old Msg of the mutation.
  15487. func withMsg(node *Msg) msgOption {
  15488. return func(m *MsgMutation) {
  15489. m.oldValue = func(context.Context) (*Msg, error) {
  15490. return node, nil
  15491. }
  15492. m.id = &node.ID
  15493. }
  15494. }
  15495. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15496. // executed in a transaction (ent.Tx), a transactional client is returned.
  15497. func (m MsgMutation) Client() *Client {
  15498. client := &Client{config: m.config}
  15499. client.init()
  15500. return client
  15501. }
  15502. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15503. // it returns an error otherwise.
  15504. func (m MsgMutation) Tx() (*Tx, error) {
  15505. if _, ok := m.driver.(*txDriver); !ok {
  15506. return nil, errors.New("ent: mutation is not running in a transaction")
  15507. }
  15508. tx := &Tx{config: m.config}
  15509. tx.init()
  15510. return tx, nil
  15511. }
  15512. // SetID sets the value of the id field. Note that this
  15513. // operation is only accepted on creation of Msg entities.
  15514. func (m *MsgMutation) SetID(id uint64) {
  15515. m.id = &id
  15516. }
  15517. // ID returns the ID value in the mutation. Note that the ID is only available
  15518. // if it was provided to the builder or after it was returned from the database.
  15519. func (m *MsgMutation) ID() (id uint64, exists bool) {
  15520. if m.id == nil {
  15521. return
  15522. }
  15523. return *m.id, true
  15524. }
  15525. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15526. // That means, if the mutation is applied within a transaction with an isolation level such
  15527. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15528. // or updated by the mutation.
  15529. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  15530. switch {
  15531. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15532. id, exists := m.ID()
  15533. if exists {
  15534. return []uint64{id}, nil
  15535. }
  15536. fallthrough
  15537. case m.op.Is(OpUpdate | OpDelete):
  15538. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  15539. default:
  15540. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15541. }
  15542. }
  15543. // SetCreatedAt sets the "created_at" field.
  15544. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  15545. m.created_at = &t
  15546. }
  15547. // CreatedAt returns the value of the "created_at" field in the mutation.
  15548. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  15549. v := m.created_at
  15550. if v == nil {
  15551. return
  15552. }
  15553. return *v, true
  15554. }
  15555. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  15556. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15558. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15559. if !m.op.Is(OpUpdateOne) {
  15560. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15561. }
  15562. if m.id == nil || m.oldValue == nil {
  15563. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15564. }
  15565. oldValue, err := m.oldValue(ctx)
  15566. if err != nil {
  15567. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15568. }
  15569. return oldValue.CreatedAt, nil
  15570. }
  15571. // ResetCreatedAt resets all changes to the "created_at" field.
  15572. func (m *MsgMutation) ResetCreatedAt() {
  15573. m.created_at = nil
  15574. }
  15575. // SetUpdatedAt sets the "updated_at" field.
  15576. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  15577. m.updated_at = &t
  15578. }
  15579. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15580. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  15581. v := m.updated_at
  15582. if v == nil {
  15583. return
  15584. }
  15585. return *v, true
  15586. }
  15587. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  15588. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15590. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15591. if !m.op.Is(OpUpdateOne) {
  15592. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15593. }
  15594. if m.id == nil || m.oldValue == nil {
  15595. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15596. }
  15597. oldValue, err := m.oldValue(ctx)
  15598. if err != nil {
  15599. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15600. }
  15601. return oldValue.UpdatedAt, nil
  15602. }
  15603. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15604. func (m *MsgMutation) ResetUpdatedAt() {
  15605. m.updated_at = nil
  15606. }
  15607. // SetDeletedAt sets the "deleted_at" field.
  15608. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  15609. m.deleted_at = &t
  15610. }
  15611. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15612. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  15613. v := m.deleted_at
  15614. if v == nil {
  15615. return
  15616. }
  15617. return *v, true
  15618. }
  15619. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  15620. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15622. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15623. if !m.op.Is(OpUpdateOne) {
  15624. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15625. }
  15626. if m.id == nil || m.oldValue == nil {
  15627. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15628. }
  15629. oldValue, err := m.oldValue(ctx)
  15630. if err != nil {
  15631. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15632. }
  15633. return oldValue.DeletedAt, nil
  15634. }
  15635. // ClearDeletedAt clears the value of the "deleted_at" field.
  15636. func (m *MsgMutation) ClearDeletedAt() {
  15637. m.deleted_at = nil
  15638. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  15639. }
  15640. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15641. func (m *MsgMutation) DeletedAtCleared() bool {
  15642. _, ok := m.clearedFields[msg.FieldDeletedAt]
  15643. return ok
  15644. }
  15645. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15646. func (m *MsgMutation) ResetDeletedAt() {
  15647. m.deleted_at = nil
  15648. delete(m.clearedFields, msg.FieldDeletedAt)
  15649. }
  15650. // SetStatus sets the "status" field.
  15651. func (m *MsgMutation) SetStatus(u uint8) {
  15652. m.status = &u
  15653. m.addstatus = nil
  15654. }
  15655. // Status returns the value of the "status" field in the mutation.
  15656. func (m *MsgMutation) Status() (r uint8, exists bool) {
  15657. v := m.status
  15658. if v == nil {
  15659. return
  15660. }
  15661. return *v, true
  15662. }
  15663. // OldStatus returns the old "status" field's value of the Msg entity.
  15664. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15666. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15667. if !m.op.Is(OpUpdateOne) {
  15668. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15669. }
  15670. if m.id == nil || m.oldValue == nil {
  15671. return v, errors.New("OldStatus requires an ID field in the mutation")
  15672. }
  15673. oldValue, err := m.oldValue(ctx)
  15674. if err != nil {
  15675. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15676. }
  15677. return oldValue.Status, nil
  15678. }
  15679. // AddStatus adds u to the "status" field.
  15680. func (m *MsgMutation) AddStatus(u int8) {
  15681. if m.addstatus != nil {
  15682. *m.addstatus += u
  15683. } else {
  15684. m.addstatus = &u
  15685. }
  15686. }
  15687. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15688. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  15689. v := m.addstatus
  15690. if v == nil {
  15691. return
  15692. }
  15693. return *v, true
  15694. }
  15695. // ClearStatus clears the value of the "status" field.
  15696. func (m *MsgMutation) ClearStatus() {
  15697. m.status = nil
  15698. m.addstatus = nil
  15699. m.clearedFields[msg.FieldStatus] = struct{}{}
  15700. }
  15701. // StatusCleared returns if the "status" field was cleared in this mutation.
  15702. func (m *MsgMutation) StatusCleared() bool {
  15703. _, ok := m.clearedFields[msg.FieldStatus]
  15704. return ok
  15705. }
  15706. // ResetStatus resets all changes to the "status" field.
  15707. func (m *MsgMutation) ResetStatus() {
  15708. m.status = nil
  15709. m.addstatus = nil
  15710. delete(m.clearedFields, msg.FieldStatus)
  15711. }
  15712. // SetFromwxid sets the "fromwxid" field.
  15713. func (m *MsgMutation) SetFromwxid(s string) {
  15714. m.fromwxid = &s
  15715. }
  15716. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  15717. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  15718. v := m.fromwxid
  15719. if v == nil {
  15720. return
  15721. }
  15722. return *v, true
  15723. }
  15724. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  15725. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15727. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  15728. if !m.op.Is(OpUpdateOne) {
  15729. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  15730. }
  15731. if m.id == nil || m.oldValue == nil {
  15732. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  15733. }
  15734. oldValue, err := m.oldValue(ctx)
  15735. if err != nil {
  15736. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  15737. }
  15738. return oldValue.Fromwxid, nil
  15739. }
  15740. // ClearFromwxid clears the value of the "fromwxid" field.
  15741. func (m *MsgMutation) ClearFromwxid() {
  15742. m.fromwxid = nil
  15743. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  15744. }
  15745. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  15746. func (m *MsgMutation) FromwxidCleared() bool {
  15747. _, ok := m.clearedFields[msg.FieldFromwxid]
  15748. return ok
  15749. }
  15750. // ResetFromwxid resets all changes to the "fromwxid" field.
  15751. func (m *MsgMutation) ResetFromwxid() {
  15752. m.fromwxid = nil
  15753. delete(m.clearedFields, msg.FieldFromwxid)
  15754. }
  15755. // SetToid sets the "toid" field.
  15756. func (m *MsgMutation) SetToid(s string) {
  15757. m.toid = &s
  15758. }
  15759. // Toid returns the value of the "toid" field in the mutation.
  15760. func (m *MsgMutation) Toid() (r string, exists bool) {
  15761. v := m.toid
  15762. if v == nil {
  15763. return
  15764. }
  15765. return *v, true
  15766. }
  15767. // OldToid returns the old "toid" field's value of the Msg entity.
  15768. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15770. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  15771. if !m.op.Is(OpUpdateOne) {
  15772. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  15773. }
  15774. if m.id == nil || m.oldValue == nil {
  15775. return v, errors.New("OldToid requires an ID field in the mutation")
  15776. }
  15777. oldValue, err := m.oldValue(ctx)
  15778. if err != nil {
  15779. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  15780. }
  15781. return oldValue.Toid, nil
  15782. }
  15783. // ClearToid clears the value of the "toid" field.
  15784. func (m *MsgMutation) ClearToid() {
  15785. m.toid = nil
  15786. m.clearedFields[msg.FieldToid] = struct{}{}
  15787. }
  15788. // ToidCleared returns if the "toid" field was cleared in this mutation.
  15789. func (m *MsgMutation) ToidCleared() bool {
  15790. _, ok := m.clearedFields[msg.FieldToid]
  15791. return ok
  15792. }
  15793. // ResetToid resets all changes to the "toid" field.
  15794. func (m *MsgMutation) ResetToid() {
  15795. m.toid = nil
  15796. delete(m.clearedFields, msg.FieldToid)
  15797. }
  15798. // SetMsgtype sets the "msgtype" field.
  15799. func (m *MsgMutation) SetMsgtype(i int32) {
  15800. m.msgtype = &i
  15801. m.addmsgtype = nil
  15802. }
  15803. // Msgtype returns the value of the "msgtype" field in the mutation.
  15804. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  15805. v := m.msgtype
  15806. if v == nil {
  15807. return
  15808. }
  15809. return *v, true
  15810. }
  15811. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  15812. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15814. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  15815. if !m.op.Is(OpUpdateOne) {
  15816. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  15817. }
  15818. if m.id == nil || m.oldValue == nil {
  15819. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  15820. }
  15821. oldValue, err := m.oldValue(ctx)
  15822. if err != nil {
  15823. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  15824. }
  15825. return oldValue.Msgtype, nil
  15826. }
  15827. // AddMsgtype adds i to the "msgtype" field.
  15828. func (m *MsgMutation) AddMsgtype(i int32) {
  15829. if m.addmsgtype != nil {
  15830. *m.addmsgtype += i
  15831. } else {
  15832. m.addmsgtype = &i
  15833. }
  15834. }
  15835. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  15836. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  15837. v := m.addmsgtype
  15838. if v == nil {
  15839. return
  15840. }
  15841. return *v, true
  15842. }
  15843. // ClearMsgtype clears the value of the "msgtype" field.
  15844. func (m *MsgMutation) ClearMsgtype() {
  15845. m.msgtype = nil
  15846. m.addmsgtype = nil
  15847. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  15848. }
  15849. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  15850. func (m *MsgMutation) MsgtypeCleared() bool {
  15851. _, ok := m.clearedFields[msg.FieldMsgtype]
  15852. return ok
  15853. }
  15854. // ResetMsgtype resets all changes to the "msgtype" field.
  15855. func (m *MsgMutation) ResetMsgtype() {
  15856. m.msgtype = nil
  15857. m.addmsgtype = nil
  15858. delete(m.clearedFields, msg.FieldMsgtype)
  15859. }
  15860. // SetMsg sets the "msg" field.
  15861. func (m *MsgMutation) SetMsg(s string) {
  15862. m.msg = &s
  15863. }
  15864. // Msg returns the value of the "msg" field in the mutation.
  15865. func (m *MsgMutation) Msg() (r string, exists bool) {
  15866. v := m.msg
  15867. if v == nil {
  15868. return
  15869. }
  15870. return *v, true
  15871. }
  15872. // OldMsg returns the old "msg" field's value of the Msg entity.
  15873. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15875. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  15876. if !m.op.Is(OpUpdateOne) {
  15877. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  15878. }
  15879. if m.id == nil || m.oldValue == nil {
  15880. return v, errors.New("OldMsg requires an ID field in the mutation")
  15881. }
  15882. oldValue, err := m.oldValue(ctx)
  15883. if err != nil {
  15884. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  15885. }
  15886. return oldValue.Msg, nil
  15887. }
  15888. // ClearMsg clears the value of the "msg" field.
  15889. func (m *MsgMutation) ClearMsg() {
  15890. m.msg = nil
  15891. m.clearedFields[msg.FieldMsg] = struct{}{}
  15892. }
  15893. // MsgCleared returns if the "msg" field was cleared in this mutation.
  15894. func (m *MsgMutation) MsgCleared() bool {
  15895. _, ok := m.clearedFields[msg.FieldMsg]
  15896. return ok
  15897. }
  15898. // ResetMsg resets all changes to the "msg" field.
  15899. func (m *MsgMutation) ResetMsg() {
  15900. m.msg = nil
  15901. delete(m.clearedFields, msg.FieldMsg)
  15902. }
  15903. // SetBatchNo sets the "batch_no" field.
  15904. func (m *MsgMutation) SetBatchNo(s string) {
  15905. m.batch_no = &s
  15906. }
  15907. // BatchNo returns the value of the "batch_no" field in the mutation.
  15908. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  15909. v := m.batch_no
  15910. if v == nil {
  15911. return
  15912. }
  15913. return *v, true
  15914. }
  15915. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  15916. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15918. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  15919. if !m.op.Is(OpUpdateOne) {
  15920. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  15921. }
  15922. if m.id == nil || m.oldValue == nil {
  15923. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  15924. }
  15925. oldValue, err := m.oldValue(ctx)
  15926. if err != nil {
  15927. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  15928. }
  15929. return oldValue.BatchNo, nil
  15930. }
  15931. // ClearBatchNo clears the value of the "batch_no" field.
  15932. func (m *MsgMutation) ClearBatchNo() {
  15933. m.batch_no = nil
  15934. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  15935. }
  15936. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  15937. func (m *MsgMutation) BatchNoCleared() bool {
  15938. _, ok := m.clearedFields[msg.FieldBatchNo]
  15939. return ok
  15940. }
  15941. // ResetBatchNo resets all changes to the "batch_no" field.
  15942. func (m *MsgMutation) ResetBatchNo() {
  15943. m.batch_no = nil
  15944. delete(m.clearedFields, msg.FieldBatchNo)
  15945. }
  15946. // Where appends a list predicates to the MsgMutation builder.
  15947. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  15948. m.predicates = append(m.predicates, ps...)
  15949. }
  15950. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  15951. // users can use type-assertion to append predicates that do not depend on any generated package.
  15952. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  15953. p := make([]predicate.Msg, len(ps))
  15954. for i := range ps {
  15955. p[i] = ps[i]
  15956. }
  15957. m.Where(p...)
  15958. }
  15959. // Op returns the operation name.
  15960. func (m *MsgMutation) Op() Op {
  15961. return m.op
  15962. }
  15963. // SetOp allows setting the mutation operation.
  15964. func (m *MsgMutation) SetOp(op Op) {
  15965. m.op = op
  15966. }
  15967. // Type returns the node type of this mutation (Msg).
  15968. func (m *MsgMutation) Type() string {
  15969. return m.typ
  15970. }
  15971. // Fields returns all fields that were changed during this mutation. Note that in
  15972. // order to get all numeric fields that were incremented/decremented, call
  15973. // AddedFields().
  15974. func (m *MsgMutation) Fields() []string {
  15975. fields := make([]string, 0, 9)
  15976. if m.created_at != nil {
  15977. fields = append(fields, msg.FieldCreatedAt)
  15978. }
  15979. if m.updated_at != nil {
  15980. fields = append(fields, msg.FieldUpdatedAt)
  15981. }
  15982. if m.deleted_at != nil {
  15983. fields = append(fields, msg.FieldDeletedAt)
  15984. }
  15985. if m.status != nil {
  15986. fields = append(fields, msg.FieldStatus)
  15987. }
  15988. if m.fromwxid != nil {
  15989. fields = append(fields, msg.FieldFromwxid)
  15990. }
  15991. if m.toid != nil {
  15992. fields = append(fields, msg.FieldToid)
  15993. }
  15994. if m.msgtype != nil {
  15995. fields = append(fields, msg.FieldMsgtype)
  15996. }
  15997. if m.msg != nil {
  15998. fields = append(fields, msg.FieldMsg)
  15999. }
  16000. if m.batch_no != nil {
  16001. fields = append(fields, msg.FieldBatchNo)
  16002. }
  16003. return fields
  16004. }
  16005. // Field returns the value of a field with the given name. The second boolean
  16006. // return value indicates that this field was not set, or was not defined in the
  16007. // schema.
  16008. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  16009. switch name {
  16010. case msg.FieldCreatedAt:
  16011. return m.CreatedAt()
  16012. case msg.FieldUpdatedAt:
  16013. return m.UpdatedAt()
  16014. case msg.FieldDeletedAt:
  16015. return m.DeletedAt()
  16016. case msg.FieldStatus:
  16017. return m.Status()
  16018. case msg.FieldFromwxid:
  16019. return m.Fromwxid()
  16020. case msg.FieldToid:
  16021. return m.Toid()
  16022. case msg.FieldMsgtype:
  16023. return m.Msgtype()
  16024. case msg.FieldMsg:
  16025. return m.Msg()
  16026. case msg.FieldBatchNo:
  16027. return m.BatchNo()
  16028. }
  16029. return nil, false
  16030. }
  16031. // OldField returns the old value of the field from the database. An error is
  16032. // returned if the mutation operation is not UpdateOne, or the query to the
  16033. // database failed.
  16034. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16035. switch name {
  16036. case msg.FieldCreatedAt:
  16037. return m.OldCreatedAt(ctx)
  16038. case msg.FieldUpdatedAt:
  16039. return m.OldUpdatedAt(ctx)
  16040. case msg.FieldDeletedAt:
  16041. return m.OldDeletedAt(ctx)
  16042. case msg.FieldStatus:
  16043. return m.OldStatus(ctx)
  16044. case msg.FieldFromwxid:
  16045. return m.OldFromwxid(ctx)
  16046. case msg.FieldToid:
  16047. return m.OldToid(ctx)
  16048. case msg.FieldMsgtype:
  16049. return m.OldMsgtype(ctx)
  16050. case msg.FieldMsg:
  16051. return m.OldMsg(ctx)
  16052. case msg.FieldBatchNo:
  16053. return m.OldBatchNo(ctx)
  16054. }
  16055. return nil, fmt.Errorf("unknown Msg field %s", name)
  16056. }
  16057. // SetField sets the value of a field with the given name. It returns an error if
  16058. // the field is not defined in the schema, or if the type mismatched the field
  16059. // type.
  16060. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  16061. switch name {
  16062. case msg.FieldCreatedAt:
  16063. v, ok := value.(time.Time)
  16064. if !ok {
  16065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16066. }
  16067. m.SetCreatedAt(v)
  16068. return nil
  16069. case msg.FieldUpdatedAt:
  16070. v, ok := value.(time.Time)
  16071. if !ok {
  16072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16073. }
  16074. m.SetUpdatedAt(v)
  16075. return nil
  16076. case msg.FieldDeletedAt:
  16077. v, ok := value.(time.Time)
  16078. if !ok {
  16079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16080. }
  16081. m.SetDeletedAt(v)
  16082. return nil
  16083. case msg.FieldStatus:
  16084. v, ok := value.(uint8)
  16085. if !ok {
  16086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16087. }
  16088. m.SetStatus(v)
  16089. return nil
  16090. case msg.FieldFromwxid:
  16091. v, ok := value.(string)
  16092. if !ok {
  16093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16094. }
  16095. m.SetFromwxid(v)
  16096. return nil
  16097. case msg.FieldToid:
  16098. v, ok := value.(string)
  16099. if !ok {
  16100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16101. }
  16102. m.SetToid(v)
  16103. return nil
  16104. case msg.FieldMsgtype:
  16105. v, ok := value.(int32)
  16106. if !ok {
  16107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16108. }
  16109. m.SetMsgtype(v)
  16110. return nil
  16111. case msg.FieldMsg:
  16112. v, ok := value.(string)
  16113. if !ok {
  16114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16115. }
  16116. m.SetMsg(v)
  16117. return nil
  16118. case msg.FieldBatchNo:
  16119. v, ok := value.(string)
  16120. if !ok {
  16121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16122. }
  16123. m.SetBatchNo(v)
  16124. return nil
  16125. }
  16126. return fmt.Errorf("unknown Msg field %s", name)
  16127. }
  16128. // AddedFields returns all numeric fields that were incremented/decremented during
  16129. // this mutation.
  16130. func (m *MsgMutation) AddedFields() []string {
  16131. var fields []string
  16132. if m.addstatus != nil {
  16133. fields = append(fields, msg.FieldStatus)
  16134. }
  16135. if m.addmsgtype != nil {
  16136. fields = append(fields, msg.FieldMsgtype)
  16137. }
  16138. return fields
  16139. }
  16140. // AddedField returns the numeric value that was incremented/decremented on a field
  16141. // with the given name. The second boolean return value indicates that this field
  16142. // was not set, or was not defined in the schema.
  16143. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  16144. switch name {
  16145. case msg.FieldStatus:
  16146. return m.AddedStatus()
  16147. case msg.FieldMsgtype:
  16148. return m.AddedMsgtype()
  16149. }
  16150. return nil, false
  16151. }
  16152. // AddField adds the value to the field with the given name. It returns an error if
  16153. // the field is not defined in the schema, or if the type mismatched the field
  16154. // type.
  16155. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  16156. switch name {
  16157. case msg.FieldStatus:
  16158. v, ok := value.(int8)
  16159. if !ok {
  16160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16161. }
  16162. m.AddStatus(v)
  16163. return nil
  16164. case msg.FieldMsgtype:
  16165. v, ok := value.(int32)
  16166. if !ok {
  16167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16168. }
  16169. m.AddMsgtype(v)
  16170. return nil
  16171. }
  16172. return fmt.Errorf("unknown Msg numeric field %s", name)
  16173. }
  16174. // ClearedFields returns all nullable fields that were cleared during this
  16175. // mutation.
  16176. func (m *MsgMutation) ClearedFields() []string {
  16177. var fields []string
  16178. if m.FieldCleared(msg.FieldDeletedAt) {
  16179. fields = append(fields, msg.FieldDeletedAt)
  16180. }
  16181. if m.FieldCleared(msg.FieldStatus) {
  16182. fields = append(fields, msg.FieldStatus)
  16183. }
  16184. if m.FieldCleared(msg.FieldFromwxid) {
  16185. fields = append(fields, msg.FieldFromwxid)
  16186. }
  16187. if m.FieldCleared(msg.FieldToid) {
  16188. fields = append(fields, msg.FieldToid)
  16189. }
  16190. if m.FieldCleared(msg.FieldMsgtype) {
  16191. fields = append(fields, msg.FieldMsgtype)
  16192. }
  16193. if m.FieldCleared(msg.FieldMsg) {
  16194. fields = append(fields, msg.FieldMsg)
  16195. }
  16196. if m.FieldCleared(msg.FieldBatchNo) {
  16197. fields = append(fields, msg.FieldBatchNo)
  16198. }
  16199. return fields
  16200. }
  16201. // FieldCleared returns a boolean indicating if a field with the given name was
  16202. // cleared in this mutation.
  16203. func (m *MsgMutation) FieldCleared(name string) bool {
  16204. _, ok := m.clearedFields[name]
  16205. return ok
  16206. }
  16207. // ClearField clears the value of the field with the given name. It returns an
  16208. // error if the field is not defined in the schema.
  16209. func (m *MsgMutation) ClearField(name string) error {
  16210. switch name {
  16211. case msg.FieldDeletedAt:
  16212. m.ClearDeletedAt()
  16213. return nil
  16214. case msg.FieldStatus:
  16215. m.ClearStatus()
  16216. return nil
  16217. case msg.FieldFromwxid:
  16218. m.ClearFromwxid()
  16219. return nil
  16220. case msg.FieldToid:
  16221. m.ClearToid()
  16222. return nil
  16223. case msg.FieldMsgtype:
  16224. m.ClearMsgtype()
  16225. return nil
  16226. case msg.FieldMsg:
  16227. m.ClearMsg()
  16228. return nil
  16229. case msg.FieldBatchNo:
  16230. m.ClearBatchNo()
  16231. return nil
  16232. }
  16233. return fmt.Errorf("unknown Msg nullable field %s", name)
  16234. }
  16235. // ResetField resets all changes in the mutation for the field with the given name.
  16236. // It returns an error if the field is not defined in the schema.
  16237. func (m *MsgMutation) ResetField(name string) error {
  16238. switch name {
  16239. case msg.FieldCreatedAt:
  16240. m.ResetCreatedAt()
  16241. return nil
  16242. case msg.FieldUpdatedAt:
  16243. m.ResetUpdatedAt()
  16244. return nil
  16245. case msg.FieldDeletedAt:
  16246. m.ResetDeletedAt()
  16247. return nil
  16248. case msg.FieldStatus:
  16249. m.ResetStatus()
  16250. return nil
  16251. case msg.FieldFromwxid:
  16252. m.ResetFromwxid()
  16253. return nil
  16254. case msg.FieldToid:
  16255. m.ResetToid()
  16256. return nil
  16257. case msg.FieldMsgtype:
  16258. m.ResetMsgtype()
  16259. return nil
  16260. case msg.FieldMsg:
  16261. m.ResetMsg()
  16262. return nil
  16263. case msg.FieldBatchNo:
  16264. m.ResetBatchNo()
  16265. return nil
  16266. }
  16267. return fmt.Errorf("unknown Msg field %s", name)
  16268. }
  16269. // AddedEdges returns all edge names that were set/added in this mutation.
  16270. func (m *MsgMutation) AddedEdges() []string {
  16271. edges := make([]string, 0, 0)
  16272. return edges
  16273. }
  16274. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16275. // name in this mutation.
  16276. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  16277. return nil
  16278. }
  16279. // RemovedEdges returns all edge names that were removed in this mutation.
  16280. func (m *MsgMutation) RemovedEdges() []string {
  16281. edges := make([]string, 0, 0)
  16282. return edges
  16283. }
  16284. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16285. // the given name in this mutation.
  16286. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  16287. return nil
  16288. }
  16289. // ClearedEdges returns all edge names that were cleared in this mutation.
  16290. func (m *MsgMutation) ClearedEdges() []string {
  16291. edges := make([]string, 0, 0)
  16292. return edges
  16293. }
  16294. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16295. // was cleared in this mutation.
  16296. func (m *MsgMutation) EdgeCleared(name string) bool {
  16297. return false
  16298. }
  16299. // ClearEdge clears the value of the edge with the given name. It returns an error
  16300. // if that edge is not defined in the schema.
  16301. func (m *MsgMutation) ClearEdge(name string) error {
  16302. return fmt.Errorf("unknown Msg unique edge %s", name)
  16303. }
  16304. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16305. // It returns an error if the edge is not defined in the schema.
  16306. func (m *MsgMutation) ResetEdge(name string) error {
  16307. return fmt.Errorf("unknown Msg edge %s", name)
  16308. }
  16309. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  16310. type ServerMutation struct {
  16311. config
  16312. op Op
  16313. typ string
  16314. id *uint64
  16315. created_at *time.Time
  16316. updated_at *time.Time
  16317. status *uint8
  16318. addstatus *int8
  16319. deleted_at *time.Time
  16320. name *string
  16321. public_ip *string
  16322. private_ip *string
  16323. admin_port *string
  16324. clearedFields map[string]struct{}
  16325. wxs map[uint64]struct{}
  16326. removedwxs map[uint64]struct{}
  16327. clearedwxs bool
  16328. done bool
  16329. oldValue func(context.Context) (*Server, error)
  16330. predicates []predicate.Server
  16331. }
  16332. var _ ent.Mutation = (*ServerMutation)(nil)
  16333. // serverOption allows management of the mutation configuration using functional options.
  16334. type serverOption func(*ServerMutation)
  16335. // newServerMutation creates new mutation for the Server entity.
  16336. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  16337. m := &ServerMutation{
  16338. config: c,
  16339. op: op,
  16340. typ: TypeServer,
  16341. clearedFields: make(map[string]struct{}),
  16342. }
  16343. for _, opt := range opts {
  16344. opt(m)
  16345. }
  16346. return m
  16347. }
  16348. // withServerID sets the ID field of the mutation.
  16349. func withServerID(id uint64) serverOption {
  16350. return func(m *ServerMutation) {
  16351. var (
  16352. err error
  16353. once sync.Once
  16354. value *Server
  16355. )
  16356. m.oldValue = func(ctx context.Context) (*Server, error) {
  16357. once.Do(func() {
  16358. if m.done {
  16359. err = errors.New("querying old values post mutation is not allowed")
  16360. } else {
  16361. value, err = m.Client().Server.Get(ctx, id)
  16362. }
  16363. })
  16364. return value, err
  16365. }
  16366. m.id = &id
  16367. }
  16368. }
  16369. // withServer sets the old Server of the mutation.
  16370. func withServer(node *Server) serverOption {
  16371. return func(m *ServerMutation) {
  16372. m.oldValue = func(context.Context) (*Server, error) {
  16373. return node, nil
  16374. }
  16375. m.id = &node.ID
  16376. }
  16377. }
  16378. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16379. // executed in a transaction (ent.Tx), a transactional client is returned.
  16380. func (m ServerMutation) Client() *Client {
  16381. client := &Client{config: m.config}
  16382. client.init()
  16383. return client
  16384. }
  16385. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16386. // it returns an error otherwise.
  16387. func (m ServerMutation) Tx() (*Tx, error) {
  16388. if _, ok := m.driver.(*txDriver); !ok {
  16389. return nil, errors.New("ent: mutation is not running in a transaction")
  16390. }
  16391. tx := &Tx{config: m.config}
  16392. tx.init()
  16393. return tx, nil
  16394. }
  16395. // SetID sets the value of the id field. Note that this
  16396. // operation is only accepted on creation of Server entities.
  16397. func (m *ServerMutation) SetID(id uint64) {
  16398. m.id = &id
  16399. }
  16400. // ID returns the ID value in the mutation. Note that the ID is only available
  16401. // if it was provided to the builder or after it was returned from the database.
  16402. func (m *ServerMutation) ID() (id uint64, exists bool) {
  16403. if m.id == nil {
  16404. return
  16405. }
  16406. return *m.id, true
  16407. }
  16408. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16409. // That means, if the mutation is applied within a transaction with an isolation level such
  16410. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16411. // or updated by the mutation.
  16412. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  16413. switch {
  16414. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16415. id, exists := m.ID()
  16416. if exists {
  16417. return []uint64{id}, nil
  16418. }
  16419. fallthrough
  16420. case m.op.Is(OpUpdate | OpDelete):
  16421. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  16422. default:
  16423. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16424. }
  16425. }
  16426. // SetCreatedAt sets the "created_at" field.
  16427. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  16428. m.created_at = &t
  16429. }
  16430. // CreatedAt returns the value of the "created_at" field in the mutation.
  16431. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  16432. v := m.created_at
  16433. if v == nil {
  16434. return
  16435. }
  16436. return *v, true
  16437. }
  16438. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  16439. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16441. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16442. if !m.op.Is(OpUpdateOne) {
  16443. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16444. }
  16445. if m.id == nil || m.oldValue == nil {
  16446. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16447. }
  16448. oldValue, err := m.oldValue(ctx)
  16449. if err != nil {
  16450. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16451. }
  16452. return oldValue.CreatedAt, nil
  16453. }
  16454. // ResetCreatedAt resets all changes to the "created_at" field.
  16455. func (m *ServerMutation) ResetCreatedAt() {
  16456. m.created_at = nil
  16457. }
  16458. // SetUpdatedAt sets the "updated_at" field.
  16459. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  16460. m.updated_at = &t
  16461. }
  16462. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16463. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  16464. v := m.updated_at
  16465. if v == nil {
  16466. return
  16467. }
  16468. return *v, true
  16469. }
  16470. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  16471. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16473. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16474. if !m.op.Is(OpUpdateOne) {
  16475. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16476. }
  16477. if m.id == nil || m.oldValue == nil {
  16478. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16479. }
  16480. oldValue, err := m.oldValue(ctx)
  16481. if err != nil {
  16482. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16483. }
  16484. return oldValue.UpdatedAt, nil
  16485. }
  16486. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16487. func (m *ServerMutation) ResetUpdatedAt() {
  16488. m.updated_at = nil
  16489. }
  16490. // SetStatus sets the "status" field.
  16491. func (m *ServerMutation) SetStatus(u uint8) {
  16492. m.status = &u
  16493. m.addstatus = nil
  16494. }
  16495. // Status returns the value of the "status" field in the mutation.
  16496. func (m *ServerMutation) Status() (r uint8, exists bool) {
  16497. v := m.status
  16498. if v == nil {
  16499. return
  16500. }
  16501. return *v, true
  16502. }
  16503. // OldStatus returns the old "status" field's value of the Server entity.
  16504. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16506. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16507. if !m.op.Is(OpUpdateOne) {
  16508. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16509. }
  16510. if m.id == nil || m.oldValue == nil {
  16511. return v, errors.New("OldStatus requires an ID field in the mutation")
  16512. }
  16513. oldValue, err := m.oldValue(ctx)
  16514. if err != nil {
  16515. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16516. }
  16517. return oldValue.Status, nil
  16518. }
  16519. // AddStatus adds u to the "status" field.
  16520. func (m *ServerMutation) AddStatus(u int8) {
  16521. if m.addstatus != nil {
  16522. *m.addstatus += u
  16523. } else {
  16524. m.addstatus = &u
  16525. }
  16526. }
  16527. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16528. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  16529. v := m.addstatus
  16530. if v == nil {
  16531. return
  16532. }
  16533. return *v, true
  16534. }
  16535. // ClearStatus clears the value of the "status" field.
  16536. func (m *ServerMutation) ClearStatus() {
  16537. m.status = nil
  16538. m.addstatus = nil
  16539. m.clearedFields[server.FieldStatus] = struct{}{}
  16540. }
  16541. // StatusCleared returns if the "status" field was cleared in this mutation.
  16542. func (m *ServerMutation) StatusCleared() bool {
  16543. _, ok := m.clearedFields[server.FieldStatus]
  16544. return ok
  16545. }
  16546. // ResetStatus resets all changes to the "status" field.
  16547. func (m *ServerMutation) ResetStatus() {
  16548. m.status = nil
  16549. m.addstatus = nil
  16550. delete(m.clearedFields, server.FieldStatus)
  16551. }
  16552. // SetDeletedAt sets the "deleted_at" field.
  16553. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  16554. m.deleted_at = &t
  16555. }
  16556. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16557. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  16558. v := m.deleted_at
  16559. if v == nil {
  16560. return
  16561. }
  16562. return *v, true
  16563. }
  16564. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  16565. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16567. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16568. if !m.op.Is(OpUpdateOne) {
  16569. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16570. }
  16571. if m.id == nil || m.oldValue == nil {
  16572. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16573. }
  16574. oldValue, err := m.oldValue(ctx)
  16575. if err != nil {
  16576. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16577. }
  16578. return oldValue.DeletedAt, nil
  16579. }
  16580. // ClearDeletedAt clears the value of the "deleted_at" field.
  16581. func (m *ServerMutation) ClearDeletedAt() {
  16582. m.deleted_at = nil
  16583. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  16584. }
  16585. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16586. func (m *ServerMutation) DeletedAtCleared() bool {
  16587. _, ok := m.clearedFields[server.FieldDeletedAt]
  16588. return ok
  16589. }
  16590. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16591. func (m *ServerMutation) ResetDeletedAt() {
  16592. m.deleted_at = nil
  16593. delete(m.clearedFields, server.FieldDeletedAt)
  16594. }
  16595. // SetName sets the "name" field.
  16596. func (m *ServerMutation) SetName(s string) {
  16597. m.name = &s
  16598. }
  16599. // Name returns the value of the "name" field in the mutation.
  16600. func (m *ServerMutation) Name() (r string, exists bool) {
  16601. v := m.name
  16602. if v == nil {
  16603. return
  16604. }
  16605. return *v, true
  16606. }
  16607. // OldName returns the old "name" field's value of the Server entity.
  16608. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16610. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  16611. if !m.op.Is(OpUpdateOne) {
  16612. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16613. }
  16614. if m.id == nil || m.oldValue == nil {
  16615. return v, errors.New("OldName requires an ID field in the mutation")
  16616. }
  16617. oldValue, err := m.oldValue(ctx)
  16618. if err != nil {
  16619. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16620. }
  16621. return oldValue.Name, nil
  16622. }
  16623. // ResetName resets all changes to the "name" field.
  16624. func (m *ServerMutation) ResetName() {
  16625. m.name = nil
  16626. }
  16627. // SetPublicIP sets the "public_ip" field.
  16628. func (m *ServerMutation) SetPublicIP(s string) {
  16629. m.public_ip = &s
  16630. }
  16631. // PublicIP returns the value of the "public_ip" field in the mutation.
  16632. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  16633. v := m.public_ip
  16634. if v == nil {
  16635. return
  16636. }
  16637. return *v, true
  16638. }
  16639. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  16640. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16642. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  16643. if !m.op.Is(OpUpdateOne) {
  16644. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  16645. }
  16646. if m.id == nil || m.oldValue == nil {
  16647. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  16648. }
  16649. oldValue, err := m.oldValue(ctx)
  16650. if err != nil {
  16651. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  16652. }
  16653. return oldValue.PublicIP, nil
  16654. }
  16655. // ResetPublicIP resets all changes to the "public_ip" field.
  16656. func (m *ServerMutation) ResetPublicIP() {
  16657. m.public_ip = nil
  16658. }
  16659. // SetPrivateIP sets the "private_ip" field.
  16660. func (m *ServerMutation) SetPrivateIP(s string) {
  16661. m.private_ip = &s
  16662. }
  16663. // PrivateIP returns the value of the "private_ip" field in the mutation.
  16664. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  16665. v := m.private_ip
  16666. if v == nil {
  16667. return
  16668. }
  16669. return *v, true
  16670. }
  16671. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  16672. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16674. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  16675. if !m.op.Is(OpUpdateOne) {
  16676. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  16677. }
  16678. if m.id == nil || m.oldValue == nil {
  16679. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  16680. }
  16681. oldValue, err := m.oldValue(ctx)
  16682. if err != nil {
  16683. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  16684. }
  16685. return oldValue.PrivateIP, nil
  16686. }
  16687. // ResetPrivateIP resets all changes to the "private_ip" field.
  16688. func (m *ServerMutation) ResetPrivateIP() {
  16689. m.private_ip = nil
  16690. }
  16691. // SetAdminPort sets the "admin_port" field.
  16692. func (m *ServerMutation) SetAdminPort(s string) {
  16693. m.admin_port = &s
  16694. }
  16695. // AdminPort returns the value of the "admin_port" field in the mutation.
  16696. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  16697. v := m.admin_port
  16698. if v == nil {
  16699. return
  16700. }
  16701. return *v, true
  16702. }
  16703. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  16704. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16706. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  16707. if !m.op.Is(OpUpdateOne) {
  16708. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  16709. }
  16710. if m.id == nil || m.oldValue == nil {
  16711. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  16712. }
  16713. oldValue, err := m.oldValue(ctx)
  16714. if err != nil {
  16715. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  16716. }
  16717. return oldValue.AdminPort, nil
  16718. }
  16719. // ResetAdminPort resets all changes to the "admin_port" field.
  16720. func (m *ServerMutation) ResetAdminPort() {
  16721. m.admin_port = nil
  16722. }
  16723. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  16724. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  16725. if m.wxs == nil {
  16726. m.wxs = make(map[uint64]struct{})
  16727. }
  16728. for i := range ids {
  16729. m.wxs[ids[i]] = struct{}{}
  16730. }
  16731. }
  16732. // ClearWxs clears the "wxs" edge to the Wx entity.
  16733. func (m *ServerMutation) ClearWxs() {
  16734. m.clearedwxs = true
  16735. }
  16736. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  16737. func (m *ServerMutation) WxsCleared() bool {
  16738. return m.clearedwxs
  16739. }
  16740. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  16741. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  16742. if m.removedwxs == nil {
  16743. m.removedwxs = make(map[uint64]struct{})
  16744. }
  16745. for i := range ids {
  16746. delete(m.wxs, ids[i])
  16747. m.removedwxs[ids[i]] = struct{}{}
  16748. }
  16749. }
  16750. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  16751. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  16752. for id := range m.removedwxs {
  16753. ids = append(ids, id)
  16754. }
  16755. return
  16756. }
  16757. // WxsIDs returns the "wxs" edge IDs in the mutation.
  16758. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  16759. for id := range m.wxs {
  16760. ids = append(ids, id)
  16761. }
  16762. return
  16763. }
  16764. // ResetWxs resets all changes to the "wxs" edge.
  16765. func (m *ServerMutation) ResetWxs() {
  16766. m.wxs = nil
  16767. m.clearedwxs = false
  16768. m.removedwxs = nil
  16769. }
  16770. // Where appends a list predicates to the ServerMutation builder.
  16771. func (m *ServerMutation) Where(ps ...predicate.Server) {
  16772. m.predicates = append(m.predicates, ps...)
  16773. }
  16774. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  16775. // users can use type-assertion to append predicates that do not depend on any generated package.
  16776. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  16777. p := make([]predicate.Server, len(ps))
  16778. for i := range ps {
  16779. p[i] = ps[i]
  16780. }
  16781. m.Where(p...)
  16782. }
  16783. // Op returns the operation name.
  16784. func (m *ServerMutation) Op() Op {
  16785. return m.op
  16786. }
  16787. // SetOp allows setting the mutation operation.
  16788. func (m *ServerMutation) SetOp(op Op) {
  16789. m.op = op
  16790. }
  16791. // Type returns the node type of this mutation (Server).
  16792. func (m *ServerMutation) Type() string {
  16793. return m.typ
  16794. }
  16795. // Fields returns all fields that were changed during this mutation. Note that in
  16796. // order to get all numeric fields that were incremented/decremented, call
  16797. // AddedFields().
  16798. func (m *ServerMutation) Fields() []string {
  16799. fields := make([]string, 0, 8)
  16800. if m.created_at != nil {
  16801. fields = append(fields, server.FieldCreatedAt)
  16802. }
  16803. if m.updated_at != nil {
  16804. fields = append(fields, server.FieldUpdatedAt)
  16805. }
  16806. if m.status != nil {
  16807. fields = append(fields, server.FieldStatus)
  16808. }
  16809. if m.deleted_at != nil {
  16810. fields = append(fields, server.FieldDeletedAt)
  16811. }
  16812. if m.name != nil {
  16813. fields = append(fields, server.FieldName)
  16814. }
  16815. if m.public_ip != nil {
  16816. fields = append(fields, server.FieldPublicIP)
  16817. }
  16818. if m.private_ip != nil {
  16819. fields = append(fields, server.FieldPrivateIP)
  16820. }
  16821. if m.admin_port != nil {
  16822. fields = append(fields, server.FieldAdminPort)
  16823. }
  16824. return fields
  16825. }
  16826. // Field returns the value of a field with the given name. The second boolean
  16827. // return value indicates that this field was not set, or was not defined in the
  16828. // schema.
  16829. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  16830. switch name {
  16831. case server.FieldCreatedAt:
  16832. return m.CreatedAt()
  16833. case server.FieldUpdatedAt:
  16834. return m.UpdatedAt()
  16835. case server.FieldStatus:
  16836. return m.Status()
  16837. case server.FieldDeletedAt:
  16838. return m.DeletedAt()
  16839. case server.FieldName:
  16840. return m.Name()
  16841. case server.FieldPublicIP:
  16842. return m.PublicIP()
  16843. case server.FieldPrivateIP:
  16844. return m.PrivateIP()
  16845. case server.FieldAdminPort:
  16846. return m.AdminPort()
  16847. }
  16848. return nil, false
  16849. }
  16850. // OldField returns the old value of the field from the database. An error is
  16851. // returned if the mutation operation is not UpdateOne, or the query to the
  16852. // database failed.
  16853. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16854. switch name {
  16855. case server.FieldCreatedAt:
  16856. return m.OldCreatedAt(ctx)
  16857. case server.FieldUpdatedAt:
  16858. return m.OldUpdatedAt(ctx)
  16859. case server.FieldStatus:
  16860. return m.OldStatus(ctx)
  16861. case server.FieldDeletedAt:
  16862. return m.OldDeletedAt(ctx)
  16863. case server.FieldName:
  16864. return m.OldName(ctx)
  16865. case server.FieldPublicIP:
  16866. return m.OldPublicIP(ctx)
  16867. case server.FieldPrivateIP:
  16868. return m.OldPrivateIP(ctx)
  16869. case server.FieldAdminPort:
  16870. return m.OldAdminPort(ctx)
  16871. }
  16872. return nil, fmt.Errorf("unknown Server field %s", name)
  16873. }
  16874. // SetField sets the value of a field with the given name. It returns an error if
  16875. // the field is not defined in the schema, or if the type mismatched the field
  16876. // type.
  16877. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  16878. switch name {
  16879. case server.FieldCreatedAt:
  16880. v, ok := value.(time.Time)
  16881. if !ok {
  16882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16883. }
  16884. m.SetCreatedAt(v)
  16885. return nil
  16886. case server.FieldUpdatedAt:
  16887. v, ok := value.(time.Time)
  16888. if !ok {
  16889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16890. }
  16891. m.SetUpdatedAt(v)
  16892. return nil
  16893. case server.FieldStatus:
  16894. v, ok := value.(uint8)
  16895. if !ok {
  16896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16897. }
  16898. m.SetStatus(v)
  16899. return nil
  16900. case server.FieldDeletedAt:
  16901. v, ok := value.(time.Time)
  16902. if !ok {
  16903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16904. }
  16905. m.SetDeletedAt(v)
  16906. return nil
  16907. case server.FieldName:
  16908. v, ok := value.(string)
  16909. if !ok {
  16910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16911. }
  16912. m.SetName(v)
  16913. return nil
  16914. case server.FieldPublicIP:
  16915. v, ok := value.(string)
  16916. if !ok {
  16917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16918. }
  16919. m.SetPublicIP(v)
  16920. return nil
  16921. case server.FieldPrivateIP:
  16922. v, ok := value.(string)
  16923. if !ok {
  16924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16925. }
  16926. m.SetPrivateIP(v)
  16927. return nil
  16928. case server.FieldAdminPort:
  16929. v, ok := value.(string)
  16930. if !ok {
  16931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16932. }
  16933. m.SetAdminPort(v)
  16934. return nil
  16935. }
  16936. return fmt.Errorf("unknown Server field %s", name)
  16937. }
  16938. // AddedFields returns all numeric fields that were incremented/decremented during
  16939. // this mutation.
  16940. func (m *ServerMutation) AddedFields() []string {
  16941. var fields []string
  16942. if m.addstatus != nil {
  16943. fields = append(fields, server.FieldStatus)
  16944. }
  16945. return fields
  16946. }
  16947. // AddedField returns the numeric value that was incremented/decremented on a field
  16948. // with the given name. The second boolean return value indicates that this field
  16949. // was not set, or was not defined in the schema.
  16950. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  16951. switch name {
  16952. case server.FieldStatus:
  16953. return m.AddedStatus()
  16954. }
  16955. return nil, false
  16956. }
  16957. // AddField adds the value to the field with the given name. It returns an error if
  16958. // the field is not defined in the schema, or if the type mismatched the field
  16959. // type.
  16960. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  16961. switch name {
  16962. case server.FieldStatus:
  16963. v, ok := value.(int8)
  16964. if !ok {
  16965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16966. }
  16967. m.AddStatus(v)
  16968. return nil
  16969. }
  16970. return fmt.Errorf("unknown Server numeric field %s", name)
  16971. }
  16972. // ClearedFields returns all nullable fields that were cleared during this
  16973. // mutation.
  16974. func (m *ServerMutation) ClearedFields() []string {
  16975. var fields []string
  16976. if m.FieldCleared(server.FieldStatus) {
  16977. fields = append(fields, server.FieldStatus)
  16978. }
  16979. if m.FieldCleared(server.FieldDeletedAt) {
  16980. fields = append(fields, server.FieldDeletedAt)
  16981. }
  16982. return fields
  16983. }
  16984. // FieldCleared returns a boolean indicating if a field with the given name was
  16985. // cleared in this mutation.
  16986. func (m *ServerMutation) FieldCleared(name string) bool {
  16987. _, ok := m.clearedFields[name]
  16988. return ok
  16989. }
  16990. // ClearField clears the value of the field with the given name. It returns an
  16991. // error if the field is not defined in the schema.
  16992. func (m *ServerMutation) ClearField(name string) error {
  16993. switch name {
  16994. case server.FieldStatus:
  16995. m.ClearStatus()
  16996. return nil
  16997. case server.FieldDeletedAt:
  16998. m.ClearDeletedAt()
  16999. return nil
  17000. }
  17001. return fmt.Errorf("unknown Server nullable field %s", name)
  17002. }
  17003. // ResetField resets all changes in the mutation for the field with the given name.
  17004. // It returns an error if the field is not defined in the schema.
  17005. func (m *ServerMutation) ResetField(name string) error {
  17006. switch name {
  17007. case server.FieldCreatedAt:
  17008. m.ResetCreatedAt()
  17009. return nil
  17010. case server.FieldUpdatedAt:
  17011. m.ResetUpdatedAt()
  17012. return nil
  17013. case server.FieldStatus:
  17014. m.ResetStatus()
  17015. return nil
  17016. case server.FieldDeletedAt:
  17017. m.ResetDeletedAt()
  17018. return nil
  17019. case server.FieldName:
  17020. m.ResetName()
  17021. return nil
  17022. case server.FieldPublicIP:
  17023. m.ResetPublicIP()
  17024. return nil
  17025. case server.FieldPrivateIP:
  17026. m.ResetPrivateIP()
  17027. return nil
  17028. case server.FieldAdminPort:
  17029. m.ResetAdminPort()
  17030. return nil
  17031. }
  17032. return fmt.Errorf("unknown Server field %s", name)
  17033. }
  17034. // AddedEdges returns all edge names that were set/added in this mutation.
  17035. func (m *ServerMutation) AddedEdges() []string {
  17036. edges := make([]string, 0, 1)
  17037. if m.wxs != nil {
  17038. edges = append(edges, server.EdgeWxs)
  17039. }
  17040. return edges
  17041. }
  17042. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17043. // name in this mutation.
  17044. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  17045. switch name {
  17046. case server.EdgeWxs:
  17047. ids := make([]ent.Value, 0, len(m.wxs))
  17048. for id := range m.wxs {
  17049. ids = append(ids, id)
  17050. }
  17051. return ids
  17052. }
  17053. return nil
  17054. }
  17055. // RemovedEdges returns all edge names that were removed in this mutation.
  17056. func (m *ServerMutation) RemovedEdges() []string {
  17057. edges := make([]string, 0, 1)
  17058. if m.removedwxs != nil {
  17059. edges = append(edges, server.EdgeWxs)
  17060. }
  17061. return edges
  17062. }
  17063. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17064. // the given name in this mutation.
  17065. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  17066. switch name {
  17067. case server.EdgeWxs:
  17068. ids := make([]ent.Value, 0, len(m.removedwxs))
  17069. for id := range m.removedwxs {
  17070. ids = append(ids, id)
  17071. }
  17072. return ids
  17073. }
  17074. return nil
  17075. }
  17076. // ClearedEdges returns all edge names that were cleared in this mutation.
  17077. func (m *ServerMutation) ClearedEdges() []string {
  17078. edges := make([]string, 0, 1)
  17079. if m.clearedwxs {
  17080. edges = append(edges, server.EdgeWxs)
  17081. }
  17082. return edges
  17083. }
  17084. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17085. // was cleared in this mutation.
  17086. func (m *ServerMutation) EdgeCleared(name string) bool {
  17087. switch name {
  17088. case server.EdgeWxs:
  17089. return m.clearedwxs
  17090. }
  17091. return false
  17092. }
  17093. // ClearEdge clears the value of the edge with the given name. It returns an error
  17094. // if that edge is not defined in the schema.
  17095. func (m *ServerMutation) ClearEdge(name string) error {
  17096. switch name {
  17097. }
  17098. return fmt.Errorf("unknown Server unique edge %s", name)
  17099. }
  17100. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17101. // It returns an error if the edge is not defined in the schema.
  17102. func (m *ServerMutation) ResetEdge(name string) error {
  17103. switch name {
  17104. case server.EdgeWxs:
  17105. m.ResetWxs()
  17106. return nil
  17107. }
  17108. return fmt.Errorf("unknown Server edge %s", name)
  17109. }
  17110. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  17111. type SopNodeMutation struct {
  17112. config
  17113. op Op
  17114. typ string
  17115. id *uint64
  17116. created_at *time.Time
  17117. updated_at *time.Time
  17118. status *uint8
  17119. addstatus *int8
  17120. deleted_at *time.Time
  17121. parent_id *uint64
  17122. addparent_id *int64
  17123. name *string
  17124. condition_type *int
  17125. addcondition_type *int
  17126. condition_list *[]string
  17127. appendcondition_list []string
  17128. no_reply_condition *uint64
  17129. addno_reply_condition *int64
  17130. no_reply_unit *string
  17131. action_message *[]custom_types.Action
  17132. appendaction_message []custom_types.Action
  17133. action_label_add *[]uint64
  17134. appendaction_label_add []uint64
  17135. action_label_del *[]uint64
  17136. appendaction_label_del []uint64
  17137. action_forward **custom_types.ActionForward
  17138. clearedFields map[string]struct{}
  17139. sop_stage *uint64
  17140. clearedsop_stage bool
  17141. node_messages map[uint64]struct{}
  17142. removednode_messages map[uint64]struct{}
  17143. clearednode_messages bool
  17144. done bool
  17145. oldValue func(context.Context) (*SopNode, error)
  17146. predicates []predicate.SopNode
  17147. }
  17148. var _ ent.Mutation = (*SopNodeMutation)(nil)
  17149. // sopnodeOption allows management of the mutation configuration using functional options.
  17150. type sopnodeOption func(*SopNodeMutation)
  17151. // newSopNodeMutation creates new mutation for the SopNode entity.
  17152. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  17153. m := &SopNodeMutation{
  17154. config: c,
  17155. op: op,
  17156. typ: TypeSopNode,
  17157. clearedFields: make(map[string]struct{}),
  17158. }
  17159. for _, opt := range opts {
  17160. opt(m)
  17161. }
  17162. return m
  17163. }
  17164. // withSopNodeID sets the ID field of the mutation.
  17165. func withSopNodeID(id uint64) sopnodeOption {
  17166. return func(m *SopNodeMutation) {
  17167. var (
  17168. err error
  17169. once sync.Once
  17170. value *SopNode
  17171. )
  17172. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  17173. once.Do(func() {
  17174. if m.done {
  17175. err = errors.New("querying old values post mutation is not allowed")
  17176. } else {
  17177. value, err = m.Client().SopNode.Get(ctx, id)
  17178. }
  17179. })
  17180. return value, err
  17181. }
  17182. m.id = &id
  17183. }
  17184. }
  17185. // withSopNode sets the old SopNode of the mutation.
  17186. func withSopNode(node *SopNode) sopnodeOption {
  17187. return func(m *SopNodeMutation) {
  17188. m.oldValue = func(context.Context) (*SopNode, error) {
  17189. return node, nil
  17190. }
  17191. m.id = &node.ID
  17192. }
  17193. }
  17194. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17195. // executed in a transaction (ent.Tx), a transactional client is returned.
  17196. func (m SopNodeMutation) Client() *Client {
  17197. client := &Client{config: m.config}
  17198. client.init()
  17199. return client
  17200. }
  17201. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17202. // it returns an error otherwise.
  17203. func (m SopNodeMutation) Tx() (*Tx, error) {
  17204. if _, ok := m.driver.(*txDriver); !ok {
  17205. return nil, errors.New("ent: mutation is not running in a transaction")
  17206. }
  17207. tx := &Tx{config: m.config}
  17208. tx.init()
  17209. return tx, nil
  17210. }
  17211. // SetID sets the value of the id field. Note that this
  17212. // operation is only accepted on creation of SopNode entities.
  17213. func (m *SopNodeMutation) SetID(id uint64) {
  17214. m.id = &id
  17215. }
  17216. // ID returns the ID value in the mutation. Note that the ID is only available
  17217. // if it was provided to the builder or after it was returned from the database.
  17218. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  17219. if m.id == nil {
  17220. return
  17221. }
  17222. return *m.id, true
  17223. }
  17224. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17225. // That means, if the mutation is applied within a transaction with an isolation level such
  17226. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17227. // or updated by the mutation.
  17228. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  17229. switch {
  17230. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17231. id, exists := m.ID()
  17232. if exists {
  17233. return []uint64{id}, nil
  17234. }
  17235. fallthrough
  17236. case m.op.Is(OpUpdate | OpDelete):
  17237. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  17238. default:
  17239. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17240. }
  17241. }
  17242. // SetCreatedAt sets the "created_at" field.
  17243. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  17244. m.created_at = &t
  17245. }
  17246. // CreatedAt returns the value of the "created_at" field in the mutation.
  17247. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  17248. v := m.created_at
  17249. if v == nil {
  17250. return
  17251. }
  17252. return *v, true
  17253. }
  17254. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  17255. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17257. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17258. if !m.op.Is(OpUpdateOne) {
  17259. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17260. }
  17261. if m.id == nil || m.oldValue == nil {
  17262. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17263. }
  17264. oldValue, err := m.oldValue(ctx)
  17265. if err != nil {
  17266. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17267. }
  17268. return oldValue.CreatedAt, nil
  17269. }
  17270. // ResetCreatedAt resets all changes to the "created_at" field.
  17271. func (m *SopNodeMutation) ResetCreatedAt() {
  17272. m.created_at = nil
  17273. }
  17274. // SetUpdatedAt sets the "updated_at" field.
  17275. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  17276. m.updated_at = &t
  17277. }
  17278. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17279. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  17280. v := m.updated_at
  17281. if v == nil {
  17282. return
  17283. }
  17284. return *v, true
  17285. }
  17286. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  17287. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17289. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17290. if !m.op.Is(OpUpdateOne) {
  17291. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17292. }
  17293. if m.id == nil || m.oldValue == nil {
  17294. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17295. }
  17296. oldValue, err := m.oldValue(ctx)
  17297. if err != nil {
  17298. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17299. }
  17300. return oldValue.UpdatedAt, nil
  17301. }
  17302. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17303. func (m *SopNodeMutation) ResetUpdatedAt() {
  17304. m.updated_at = nil
  17305. }
  17306. // SetStatus sets the "status" field.
  17307. func (m *SopNodeMutation) SetStatus(u uint8) {
  17308. m.status = &u
  17309. m.addstatus = nil
  17310. }
  17311. // Status returns the value of the "status" field in the mutation.
  17312. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  17313. v := m.status
  17314. if v == nil {
  17315. return
  17316. }
  17317. return *v, true
  17318. }
  17319. // OldStatus returns the old "status" field's value of the SopNode entity.
  17320. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17322. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17323. if !m.op.Is(OpUpdateOne) {
  17324. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17325. }
  17326. if m.id == nil || m.oldValue == nil {
  17327. return v, errors.New("OldStatus requires an ID field in the mutation")
  17328. }
  17329. oldValue, err := m.oldValue(ctx)
  17330. if err != nil {
  17331. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17332. }
  17333. return oldValue.Status, nil
  17334. }
  17335. // AddStatus adds u to the "status" field.
  17336. func (m *SopNodeMutation) AddStatus(u int8) {
  17337. if m.addstatus != nil {
  17338. *m.addstatus += u
  17339. } else {
  17340. m.addstatus = &u
  17341. }
  17342. }
  17343. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17344. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  17345. v := m.addstatus
  17346. if v == nil {
  17347. return
  17348. }
  17349. return *v, true
  17350. }
  17351. // ClearStatus clears the value of the "status" field.
  17352. func (m *SopNodeMutation) ClearStatus() {
  17353. m.status = nil
  17354. m.addstatus = nil
  17355. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  17356. }
  17357. // StatusCleared returns if the "status" field was cleared in this mutation.
  17358. func (m *SopNodeMutation) StatusCleared() bool {
  17359. _, ok := m.clearedFields[sopnode.FieldStatus]
  17360. return ok
  17361. }
  17362. // ResetStatus resets all changes to the "status" field.
  17363. func (m *SopNodeMutation) ResetStatus() {
  17364. m.status = nil
  17365. m.addstatus = nil
  17366. delete(m.clearedFields, sopnode.FieldStatus)
  17367. }
  17368. // SetDeletedAt sets the "deleted_at" field.
  17369. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  17370. m.deleted_at = &t
  17371. }
  17372. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17373. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  17374. v := m.deleted_at
  17375. if v == nil {
  17376. return
  17377. }
  17378. return *v, true
  17379. }
  17380. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  17381. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17383. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17384. if !m.op.Is(OpUpdateOne) {
  17385. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17386. }
  17387. if m.id == nil || m.oldValue == nil {
  17388. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17389. }
  17390. oldValue, err := m.oldValue(ctx)
  17391. if err != nil {
  17392. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17393. }
  17394. return oldValue.DeletedAt, nil
  17395. }
  17396. // ClearDeletedAt clears the value of the "deleted_at" field.
  17397. func (m *SopNodeMutation) ClearDeletedAt() {
  17398. m.deleted_at = nil
  17399. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  17400. }
  17401. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17402. func (m *SopNodeMutation) DeletedAtCleared() bool {
  17403. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  17404. return ok
  17405. }
  17406. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17407. func (m *SopNodeMutation) ResetDeletedAt() {
  17408. m.deleted_at = nil
  17409. delete(m.clearedFields, sopnode.FieldDeletedAt)
  17410. }
  17411. // SetStageID sets the "stage_id" field.
  17412. func (m *SopNodeMutation) SetStageID(u uint64) {
  17413. m.sop_stage = &u
  17414. }
  17415. // StageID returns the value of the "stage_id" field in the mutation.
  17416. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  17417. v := m.sop_stage
  17418. if v == nil {
  17419. return
  17420. }
  17421. return *v, true
  17422. }
  17423. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  17424. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17426. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  17427. if !m.op.Is(OpUpdateOne) {
  17428. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  17429. }
  17430. if m.id == nil || m.oldValue == nil {
  17431. return v, errors.New("OldStageID requires an ID field in the mutation")
  17432. }
  17433. oldValue, err := m.oldValue(ctx)
  17434. if err != nil {
  17435. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  17436. }
  17437. return oldValue.StageID, nil
  17438. }
  17439. // ResetStageID resets all changes to the "stage_id" field.
  17440. func (m *SopNodeMutation) ResetStageID() {
  17441. m.sop_stage = nil
  17442. }
  17443. // SetParentID sets the "parent_id" field.
  17444. func (m *SopNodeMutation) SetParentID(u uint64) {
  17445. m.parent_id = &u
  17446. m.addparent_id = nil
  17447. }
  17448. // ParentID returns the value of the "parent_id" field in the mutation.
  17449. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  17450. v := m.parent_id
  17451. if v == nil {
  17452. return
  17453. }
  17454. return *v, true
  17455. }
  17456. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  17457. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17459. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  17460. if !m.op.Is(OpUpdateOne) {
  17461. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  17462. }
  17463. if m.id == nil || m.oldValue == nil {
  17464. return v, errors.New("OldParentID requires an ID field in the mutation")
  17465. }
  17466. oldValue, err := m.oldValue(ctx)
  17467. if err != nil {
  17468. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  17469. }
  17470. return oldValue.ParentID, nil
  17471. }
  17472. // AddParentID adds u to the "parent_id" field.
  17473. func (m *SopNodeMutation) AddParentID(u int64) {
  17474. if m.addparent_id != nil {
  17475. *m.addparent_id += u
  17476. } else {
  17477. m.addparent_id = &u
  17478. }
  17479. }
  17480. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  17481. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  17482. v := m.addparent_id
  17483. if v == nil {
  17484. return
  17485. }
  17486. return *v, true
  17487. }
  17488. // ResetParentID resets all changes to the "parent_id" field.
  17489. func (m *SopNodeMutation) ResetParentID() {
  17490. m.parent_id = nil
  17491. m.addparent_id = nil
  17492. }
  17493. // SetName sets the "name" field.
  17494. func (m *SopNodeMutation) SetName(s string) {
  17495. m.name = &s
  17496. }
  17497. // Name returns the value of the "name" field in the mutation.
  17498. func (m *SopNodeMutation) Name() (r string, exists bool) {
  17499. v := m.name
  17500. if v == nil {
  17501. return
  17502. }
  17503. return *v, true
  17504. }
  17505. // OldName returns the old "name" field's value of the SopNode entity.
  17506. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17508. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  17509. if !m.op.Is(OpUpdateOne) {
  17510. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17511. }
  17512. if m.id == nil || m.oldValue == nil {
  17513. return v, errors.New("OldName requires an ID field in the mutation")
  17514. }
  17515. oldValue, err := m.oldValue(ctx)
  17516. if err != nil {
  17517. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17518. }
  17519. return oldValue.Name, nil
  17520. }
  17521. // ResetName resets all changes to the "name" field.
  17522. func (m *SopNodeMutation) ResetName() {
  17523. m.name = nil
  17524. }
  17525. // SetConditionType sets the "condition_type" field.
  17526. func (m *SopNodeMutation) SetConditionType(i int) {
  17527. m.condition_type = &i
  17528. m.addcondition_type = nil
  17529. }
  17530. // ConditionType returns the value of the "condition_type" field in the mutation.
  17531. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  17532. v := m.condition_type
  17533. if v == nil {
  17534. return
  17535. }
  17536. return *v, true
  17537. }
  17538. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  17539. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17541. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  17542. if !m.op.Is(OpUpdateOne) {
  17543. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  17544. }
  17545. if m.id == nil || m.oldValue == nil {
  17546. return v, errors.New("OldConditionType requires an ID field in the mutation")
  17547. }
  17548. oldValue, err := m.oldValue(ctx)
  17549. if err != nil {
  17550. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  17551. }
  17552. return oldValue.ConditionType, nil
  17553. }
  17554. // AddConditionType adds i to the "condition_type" field.
  17555. func (m *SopNodeMutation) AddConditionType(i int) {
  17556. if m.addcondition_type != nil {
  17557. *m.addcondition_type += i
  17558. } else {
  17559. m.addcondition_type = &i
  17560. }
  17561. }
  17562. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  17563. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  17564. v := m.addcondition_type
  17565. if v == nil {
  17566. return
  17567. }
  17568. return *v, true
  17569. }
  17570. // ResetConditionType resets all changes to the "condition_type" field.
  17571. func (m *SopNodeMutation) ResetConditionType() {
  17572. m.condition_type = nil
  17573. m.addcondition_type = nil
  17574. }
  17575. // SetConditionList sets the "condition_list" field.
  17576. func (m *SopNodeMutation) SetConditionList(s []string) {
  17577. m.condition_list = &s
  17578. m.appendcondition_list = nil
  17579. }
  17580. // ConditionList returns the value of the "condition_list" field in the mutation.
  17581. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  17582. v := m.condition_list
  17583. if v == nil {
  17584. return
  17585. }
  17586. return *v, true
  17587. }
  17588. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  17589. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17591. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  17592. if !m.op.Is(OpUpdateOne) {
  17593. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  17594. }
  17595. if m.id == nil || m.oldValue == nil {
  17596. return v, errors.New("OldConditionList requires an ID field in the mutation")
  17597. }
  17598. oldValue, err := m.oldValue(ctx)
  17599. if err != nil {
  17600. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  17601. }
  17602. return oldValue.ConditionList, nil
  17603. }
  17604. // AppendConditionList adds s to the "condition_list" field.
  17605. func (m *SopNodeMutation) AppendConditionList(s []string) {
  17606. m.appendcondition_list = append(m.appendcondition_list, s...)
  17607. }
  17608. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  17609. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  17610. if len(m.appendcondition_list) == 0 {
  17611. return nil, false
  17612. }
  17613. return m.appendcondition_list, true
  17614. }
  17615. // ClearConditionList clears the value of the "condition_list" field.
  17616. func (m *SopNodeMutation) ClearConditionList() {
  17617. m.condition_list = nil
  17618. m.appendcondition_list = nil
  17619. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  17620. }
  17621. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  17622. func (m *SopNodeMutation) ConditionListCleared() bool {
  17623. _, ok := m.clearedFields[sopnode.FieldConditionList]
  17624. return ok
  17625. }
  17626. // ResetConditionList resets all changes to the "condition_list" field.
  17627. func (m *SopNodeMutation) ResetConditionList() {
  17628. m.condition_list = nil
  17629. m.appendcondition_list = nil
  17630. delete(m.clearedFields, sopnode.FieldConditionList)
  17631. }
  17632. // SetNoReplyCondition sets the "no_reply_condition" field.
  17633. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  17634. m.no_reply_condition = &u
  17635. m.addno_reply_condition = nil
  17636. }
  17637. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  17638. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  17639. v := m.no_reply_condition
  17640. if v == nil {
  17641. return
  17642. }
  17643. return *v, true
  17644. }
  17645. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  17646. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17648. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  17649. if !m.op.Is(OpUpdateOne) {
  17650. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  17651. }
  17652. if m.id == nil || m.oldValue == nil {
  17653. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  17654. }
  17655. oldValue, err := m.oldValue(ctx)
  17656. if err != nil {
  17657. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  17658. }
  17659. return oldValue.NoReplyCondition, nil
  17660. }
  17661. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  17662. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  17663. if m.addno_reply_condition != nil {
  17664. *m.addno_reply_condition += u
  17665. } else {
  17666. m.addno_reply_condition = &u
  17667. }
  17668. }
  17669. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  17670. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  17671. v := m.addno_reply_condition
  17672. if v == nil {
  17673. return
  17674. }
  17675. return *v, true
  17676. }
  17677. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  17678. func (m *SopNodeMutation) ResetNoReplyCondition() {
  17679. m.no_reply_condition = nil
  17680. m.addno_reply_condition = nil
  17681. }
  17682. // SetNoReplyUnit sets the "no_reply_unit" field.
  17683. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  17684. m.no_reply_unit = &s
  17685. }
  17686. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  17687. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  17688. v := m.no_reply_unit
  17689. if v == nil {
  17690. return
  17691. }
  17692. return *v, true
  17693. }
  17694. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  17695. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17697. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  17698. if !m.op.Is(OpUpdateOne) {
  17699. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  17700. }
  17701. if m.id == nil || m.oldValue == nil {
  17702. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  17703. }
  17704. oldValue, err := m.oldValue(ctx)
  17705. if err != nil {
  17706. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  17707. }
  17708. return oldValue.NoReplyUnit, nil
  17709. }
  17710. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  17711. func (m *SopNodeMutation) ResetNoReplyUnit() {
  17712. m.no_reply_unit = nil
  17713. }
  17714. // SetActionMessage sets the "action_message" field.
  17715. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  17716. m.action_message = &ct
  17717. m.appendaction_message = nil
  17718. }
  17719. // ActionMessage returns the value of the "action_message" field in the mutation.
  17720. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  17721. v := m.action_message
  17722. if v == nil {
  17723. return
  17724. }
  17725. return *v, true
  17726. }
  17727. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  17728. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17730. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  17731. if !m.op.Is(OpUpdateOne) {
  17732. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  17733. }
  17734. if m.id == nil || m.oldValue == nil {
  17735. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  17736. }
  17737. oldValue, err := m.oldValue(ctx)
  17738. if err != nil {
  17739. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  17740. }
  17741. return oldValue.ActionMessage, nil
  17742. }
  17743. // AppendActionMessage adds ct to the "action_message" field.
  17744. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  17745. m.appendaction_message = append(m.appendaction_message, ct...)
  17746. }
  17747. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  17748. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  17749. if len(m.appendaction_message) == 0 {
  17750. return nil, false
  17751. }
  17752. return m.appendaction_message, true
  17753. }
  17754. // ClearActionMessage clears the value of the "action_message" field.
  17755. func (m *SopNodeMutation) ClearActionMessage() {
  17756. m.action_message = nil
  17757. m.appendaction_message = nil
  17758. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  17759. }
  17760. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17761. func (m *SopNodeMutation) ActionMessageCleared() bool {
  17762. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  17763. return ok
  17764. }
  17765. // ResetActionMessage resets all changes to the "action_message" field.
  17766. func (m *SopNodeMutation) ResetActionMessage() {
  17767. m.action_message = nil
  17768. m.appendaction_message = nil
  17769. delete(m.clearedFields, sopnode.FieldActionMessage)
  17770. }
  17771. // SetActionLabelAdd sets the "action_label_add" field.
  17772. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  17773. m.action_label_add = &u
  17774. m.appendaction_label_add = nil
  17775. }
  17776. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17777. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17778. v := m.action_label_add
  17779. if v == nil {
  17780. return
  17781. }
  17782. return *v, true
  17783. }
  17784. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  17785. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17787. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17788. if !m.op.Is(OpUpdateOne) {
  17789. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17790. }
  17791. if m.id == nil || m.oldValue == nil {
  17792. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17793. }
  17794. oldValue, err := m.oldValue(ctx)
  17795. if err != nil {
  17796. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17797. }
  17798. return oldValue.ActionLabelAdd, nil
  17799. }
  17800. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17801. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  17802. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17803. }
  17804. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17805. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17806. if len(m.appendaction_label_add) == 0 {
  17807. return nil, false
  17808. }
  17809. return m.appendaction_label_add, true
  17810. }
  17811. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17812. func (m *SopNodeMutation) ClearActionLabelAdd() {
  17813. m.action_label_add = nil
  17814. m.appendaction_label_add = nil
  17815. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  17816. }
  17817. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17818. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  17819. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  17820. return ok
  17821. }
  17822. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17823. func (m *SopNodeMutation) ResetActionLabelAdd() {
  17824. m.action_label_add = nil
  17825. m.appendaction_label_add = nil
  17826. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  17827. }
  17828. // SetActionLabelDel sets the "action_label_del" field.
  17829. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  17830. m.action_label_del = &u
  17831. m.appendaction_label_del = nil
  17832. }
  17833. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17834. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  17835. v := m.action_label_del
  17836. if v == nil {
  17837. return
  17838. }
  17839. return *v, true
  17840. }
  17841. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  17842. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17844. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17845. if !m.op.Is(OpUpdateOne) {
  17846. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17847. }
  17848. if m.id == nil || m.oldValue == nil {
  17849. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17850. }
  17851. oldValue, err := m.oldValue(ctx)
  17852. if err != nil {
  17853. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17854. }
  17855. return oldValue.ActionLabelDel, nil
  17856. }
  17857. // AppendActionLabelDel adds u to the "action_label_del" field.
  17858. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  17859. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17860. }
  17861. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17862. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17863. if len(m.appendaction_label_del) == 0 {
  17864. return nil, false
  17865. }
  17866. return m.appendaction_label_del, true
  17867. }
  17868. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17869. func (m *SopNodeMutation) ClearActionLabelDel() {
  17870. m.action_label_del = nil
  17871. m.appendaction_label_del = nil
  17872. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  17873. }
  17874. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17875. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  17876. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  17877. return ok
  17878. }
  17879. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17880. func (m *SopNodeMutation) ResetActionLabelDel() {
  17881. m.action_label_del = nil
  17882. m.appendaction_label_del = nil
  17883. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  17884. }
  17885. // SetActionForward sets the "action_forward" field.
  17886. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17887. m.action_forward = &ctf
  17888. }
  17889. // ActionForward returns the value of the "action_forward" field in the mutation.
  17890. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17891. v := m.action_forward
  17892. if v == nil {
  17893. return
  17894. }
  17895. return *v, true
  17896. }
  17897. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  17898. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17900. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17901. if !m.op.Is(OpUpdateOne) {
  17902. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17903. }
  17904. if m.id == nil || m.oldValue == nil {
  17905. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17906. }
  17907. oldValue, err := m.oldValue(ctx)
  17908. if err != nil {
  17909. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17910. }
  17911. return oldValue.ActionForward, nil
  17912. }
  17913. // ClearActionForward clears the value of the "action_forward" field.
  17914. func (m *SopNodeMutation) ClearActionForward() {
  17915. m.action_forward = nil
  17916. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  17917. }
  17918. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17919. func (m *SopNodeMutation) ActionForwardCleared() bool {
  17920. _, ok := m.clearedFields[sopnode.FieldActionForward]
  17921. return ok
  17922. }
  17923. // ResetActionForward resets all changes to the "action_forward" field.
  17924. func (m *SopNodeMutation) ResetActionForward() {
  17925. m.action_forward = nil
  17926. delete(m.clearedFields, sopnode.FieldActionForward)
  17927. }
  17928. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17929. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  17930. m.sop_stage = &id
  17931. }
  17932. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17933. func (m *SopNodeMutation) ClearSopStage() {
  17934. m.clearedsop_stage = true
  17935. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  17936. }
  17937. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17938. func (m *SopNodeMutation) SopStageCleared() bool {
  17939. return m.clearedsop_stage
  17940. }
  17941. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17942. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  17943. if m.sop_stage != nil {
  17944. return *m.sop_stage, true
  17945. }
  17946. return
  17947. }
  17948. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17949. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17950. // SopStageID instead. It exists only for internal usage by the builders.
  17951. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  17952. if id := m.sop_stage; id != nil {
  17953. ids = append(ids, *id)
  17954. }
  17955. return
  17956. }
  17957. // ResetSopStage resets all changes to the "sop_stage" edge.
  17958. func (m *SopNodeMutation) ResetSopStage() {
  17959. m.sop_stage = nil
  17960. m.clearedsop_stage = false
  17961. }
  17962. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  17963. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  17964. if m.node_messages == nil {
  17965. m.node_messages = make(map[uint64]struct{})
  17966. }
  17967. for i := range ids {
  17968. m.node_messages[ids[i]] = struct{}{}
  17969. }
  17970. }
  17971. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  17972. func (m *SopNodeMutation) ClearNodeMessages() {
  17973. m.clearednode_messages = true
  17974. }
  17975. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  17976. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  17977. return m.clearednode_messages
  17978. }
  17979. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  17980. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  17981. if m.removednode_messages == nil {
  17982. m.removednode_messages = make(map[uint64]struct{})
  17983. }
  17984. for i := range ids {
  17985. delete(m.node_messages, ids[i])
  17986. m.removednode_messages[ids[i]] = struct{}{}
  17987. }
  17988. }
  17989. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  17990. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  17991. for id := range m.removednode_messages {
  17992. ids = append(ids, id)
  17993. }
  17994. return
  17995. }
  17996. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  17997. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  17998. for id := range m.node_messages {
  17999. ids = append(ids, id)
  18000. }
  18001. return
  18002. }
  18003. // ResetNodeMessages resets all changes to the "node_messages" edge.
  18004. func (m *SopNodeMutation) ResetNodeMessages() {
  18005. m.node_messages = nil
  18006. m.clearednode_messages = false
  18007. m.removednode_messages = nil
  18008. }
  18009. // Where appends a list predicates to the SopNodeMutation builder.
  18010. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  18011. m.predicates = append(m.predicates, ps...)
  18012. }
  18013. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  18014. // users can use type-assertion to append predicates that do not depend on any generated package.
  18015. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  18016. p := make([]predicate.SopNode, len(ps))
  18017. for i := range ps {
  18018. p[i] = ps[i]
  18019. }
  18020. m.Where(p...)
  18021. }
  18022. // Op returns the operation name.
  18023. func (m *SopNodeMutation) Op() Op {
  18024. return m.op
  18025. }
  18026. // SetOp allows setting the mutation operation.
  18027. func (m *SopNodeMutation) SetOp(op Op) {
  18028. m.op = op
  18029. }
  18030. // Type returns the node type of this mutation (SopNode).
  18031. func (m *SopNodeMutation) Type() string {
  18032. return m.typ
  18033. }
  18034. // Fields returns all fields that were changed during this mutation. Note that in
  18035. // order to get all numeric fields that were incremented/decremented, call
  18036. // AddedFields().
  18037. func (m *SopNodeMutation) Fields() []string {
  18038. fields := make([]string, 0, 15)
  18039. if m.created_at != nil {
  18040. fields = append(fields, sopnode.FieldCreatedAt)
  18041. }
  18042. if m.updated_at != nil {
  18043. fields = append(fields, sopnode.FieldUpdatedAt)
  18044. }
  18045. if m.status != nil {
  18046. fields = append(fields, sopnode.FieldStatus)
  18047. }
  18048. if m.deleted_at != nil {
  18049. fields = append(fields, sopnode.FieldDeletedAt)
  18050. }
  18051. if m.sop_stage != nil {
  18052. fields = append(fields, sopnode.FieldStageID)
  18053. }
  18054. if m.parent_id != nil {
  18055. fields = append(fields, sopnode.FieldParentID)
  18056. }
  18057. if m.name != nil {
  18058. fields = append(fields, sopnode.FieldName)
  18059. }
  18060. if m.condition_type != nil {
  18061. fields = append(fields, sopnode.FieldConditionType)
  18062. }
  18063. if m.condition_list != nil {
  18064. fields = append(fields, sopnode.FieldConditionList)
  18065. }
  18066. if m.no_reply_condition != nil {
  18067. fields = append(fields, sopnode.FieldNoReplyCondition)
  18068. }
  18069. if m.no_reply_unit != nil {
  18070. fields = append(fields, sopnode.FieldNoReplyUnit)
  18071. }
  18072. if m.action_message != nil {
  18073. fields = append(fields, sopnode.FieldActionMessage)
  18074. }
  18075. if m.action_label_add != nil {
  18076. fields = append(fields, sopnode.FieldActionLabelAdd)
  18077. }
  18078. if m.action_label_del != nil {
  18079. fields = append(fields, sopnode.FieldActionLabelDel)
  18080. }
  18081. if m.action_forward != nil {
  18082. fields = append(fields, sopnode.FieldActionForward)
  18083. }
  18084. return fields
  18085. }
  18086. // Field returns the value of a field with the given name. The second boolean
  18087. // return value indicates that this field was not set, or was not defined in the
  18088. // schema.
  18089. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  18090. switch name {
  18091. case sopnode.FieldCreatedAt:
  18092. return m.CreatedAt()
  18093. case sopnode.FieldUpdatedAt:
  18094. return m.UpdatedAt()
  18095. case sopnode.FieldStatus:
  18096. return m.Status()
  18097. case sopnode.FieldDeletedAt:
  18098. return m.DeletedAt()
  18099. case sopnode.FieldStageID:
  18100. return m.StageID()
  18101. case sopnode.FieldParentID:
  18102. return m.ParentID()
  18103. case sopnode.FieldName:
  18104. return m.Name()
  18105. case sopnode.FieldConditionType:
  18106. return m.ConditionType()
  18107. case sopnode.FieldConditionList:
  18108. return m.ConditionList()
  18109. case sopnode.FieldNoReplyCondition:
  18110. return m.NoReplyCondition()
  18111. case sopnode.FieldNoReplyUnit:
  18112. return m.NoReplyUnit()
  18113. case sopnode.FieldActionMessage:
  18114. return m.ActionMessage()
  18115. case sopnode.FieldActionLabelAdd:
  18116. return m.ActionLabelAdd()
  18117. case sopnode.FieldActionLabelDel:
  18118. return m.ActionLabelDel()
  18119. case sopnode.FieldActionForward:
  18120. return m.ActionForward()
  18121. }
  18122. return nil, false
  18123. }
  18124. // OldField returns the old value of the field from the database. An error is
  18125. // returned if the mutation operation is not UpdateOne, or the query to the
  18126. // database failed.
  18127. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18128. switch name {
  18129. case sopnode.FieldCreatedAt:
  18130. return m.OldCreatedAt(ctx)
  18131. case sopnode.FieldUpdatedAt:
  18132. return m.OldUpdatedAt(ctx)
  18133. case sopnode.FieldStatus:
  18134. return m.OldStatus(ctx)
  18135. case sopnode.FieldDeletedAt:
  18136. return m.OldDeletedAt(ctx)
  18137. case sopnode.FieldStageID:
  18138. return m.OldStageID(ctx)
  18139. case sopnode.FieldParentID:
  18140. return m.OldParentID(ctx)
  18141. case sopnode.FieldName:
  18142. return m.OldName(ctx)
  18143. case sopnode.FieldConditionType:
  18144. return m.OldConditionType(ctx)
  18145. case sopnode.FieldConditionList:
  18146. return m.OldConditionList(ctx)
  18147. case sopnode.FieldNoReplyCondition:
  18148. return m.OldNoReplyCondition(ctx)
  18149. case sopnode.FieldNoReplyUnit:
  18150. return m.OldNoReplyUnit(ctx)
  18151. case sopnode.FieldActionMessage:
  18152. return m.OldActionMessage(ctx)
  18153. case sopnode.FieldActionLabelAdd:
  18154. return m.OldActionLabelAdd(ctx)
  18155. case sopnode.FieldActionLabelDel:
  18156. return m.OldActionLabelDel(ctx)
  18157. case sopnode.FieldActionForward:
  18158. return m.OldActionForward(ctx)
  18159. }
  18160. return nil, fmt.Errorf("unknown SopNode field %s", name)
  18161. }
  18162. // SetField sets the value of a field with the given name. It returns an error if
  18163. // the field is not defined in the schema, or if the type mismatched the field
  18164. // type.
  18165. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  18166. switch name {
  18167. case sopnode.FieldCreatedAt:
  18168. v, ok := value.(time.Time)
  18169. if !ok {
  18170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18171. }
  18172. m.SetCreatedAt(v)
  18173. return nil
  18174. case sopnode.FieldUpdatedAt:
  18175. v, ok := value.(time.Time)
  18176. if !ok {
  18177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18178. }
  18179. m.SetUpdatedAt(v)
  18180. return nil
  18181. case sopnode.FieldStatus:
  18182. v, ok := value.(uint8)
  18183. if !ok {
  18184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18185. }
  18186. m.SetStatus(v)
  18187. return nil
  18188. case sopnode.FieldDeletedAt:
  18189. v, ok := value.(time.Time)
  18190. if !ok {
  18191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18192. }
  18193. m.SetDeletedAt(v)
  18194. return nil
  18195. case sopnode.FieldStageID:
  18196. v, ok := value.(uint64)
  18197. if !ok {
  18198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18199. }
  18200. m.SetStageID(v)
  18201. return nil
  18202. case sopnode.FieldParentID:
  18203. v, ok := value.(uint64)
  18204. if !ok {
  18205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18206. }
  18207. m.SetParentID(v)
  18208. return nil
  18209. case sopnode.FieldName:
  18210. v, ok := value.(string)
  18211. if !ok {
  18212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18213. }
  18214. m.SetName(v)
  18215. return nil
  18216. case sopnode.FieldConditionType:
  18217. v, ok := value.(int)
  18218. if !ok {
  18219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18220. }
  18221. m.SetConditionType(v)
  18222. return nil
  18223. case sopnode.FieldConditionList:
  18224. v, ok := value.([]string)
  18225. if !ok {
  18226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18227. }
  18228. m.SetConditionList(v)
  18229. return nil
  18230. case sopnode.FieldNoReplyCondition:
  18231. v, ok := value.(uint64)
  18232. if !ok {
  18233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18234. }
  18235. m.SetNoReplyCondition(v)
  18236. return nil
  18237. case sopnode.FieldNoReplyUnit:
  18238. v, ok := value.(string)
  18239. if !ok {
  18240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18241. }
  18242. m.SetNoReplyUnit(v)
  18243. return nil
  18244. case sopnode.FieldActionMessage:
  18245. v, ok := value.([]custom_types.Action)
  18246. if !ok {
  18247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18248. }
  18249. m.SetActionMessage(v)
  18250. return nil
  18251. case sopnode.FieldActionLabelAdd:
  18252. v, ok := value.([]uint64)
  18253. if !ok {
  18254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18255. }
  18256. m.SetActionLabelAdd(v)
  18257. return nil
  18258. case sopnode.FieldActionLabelDel:
  18259. v, ok := value.([]uint64)
  18260. if !ok {
  18261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18262. }
  18263. m.SetActionLabelDel(v)
  18264. return nil
  18265. case sopnode.FieldActionForward:
  18266. v, ok := value.(*custom_types.ActionForward)
  18267. if !ok {
  18268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18269. }
  18270. m.SetActionForward(v)
  18271. return nil
  18272. }
  18273. return fmt.Errorf("unknown SopNode field %s", name)
  18274. }
  18275. // AddedFields returns all numeric fields that were incremented/decremented during
  18276. // this mutation.
  18277. func (m *SopNodeMutation) AddedFields() []string {
  18278. var fields []string
  18279. if m.addstatus != nil {
  18280. fields = append(fields, sopnode.FieldStatus)
  18281. }
  18282. if m.addparent_id != nil {
  18283. fields = append(fields, sopnode.FieldParentID)
  18284. }
  18285. if m.addcondition_type != nil {
  18286. fields = append(fields, sopnode.FieldConditionType)
  18287. }
  18288. if m.addno_reply_condition != nil {
  18289. fields = append(fields, sopnode.FieldNoReplyCondition)
  18290. }
  18291. return fields
  18292. }
  18293. // AddedField returns the numeric value that was incremented/decremented on a field
  18294. // with the given name. The second boolean return value indicates that this field
  18295. // was not set, or was not defined in the schema.
  18296. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  18297. switch name {
  18298. case sopnode.FieldStatus:
  18299. return m.AddedStatus()
  18300. case sopnode.FieldParentID:
  18301. return m.AddedParentID()
  18302. case sopnode.FieldConditionType:
  18303. return m.AddedConditionType()
  18304. case sopnode.FieldNoReplyCondition:
  18305. return m.AddedNoReplyCondition()
  18306. }
  18307. return nil, false
  18308. }
  18309. // AddField adds the value to the field with the given name. It returns an error if
  18310. // the field is not defined in the schema, or if the type mismatched the field
  18311. // type.
  18312. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  18313. switch name {
  18314. case sopnode.FieldStatus:
  18315. v, ok := value.(int8)
  18316. if !ok {
  18317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18318. }
  18319. m.AddStatus(v)
  18320. return nil
  18321. case sopnode.FieldParentID:
  18322. v, ok := value.(int64)
  18323. if !ok {
  18324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18325. }
  18326. m.AddParentID(v)
  18327. return nil
  18328. case sopnode.FieldConditionType:
  18329. v, ok := value.(int)
  18330. if !ok {
  18331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18332. }
  18333. m.AddConditionType(v)
  18334. return nil
  18335. case sopnode.FieldNoReplyCondition:
  18336. v, ok := value.(int64)
  18337. if !ok {
  18338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18339. }
  18340. m.AddNoReplyCondition(v)
  18341. return nil
  18342. }
  18343. return fmt.Errorf("unknown SopNode numeric field %s", name)
  18344. }
  18345. // ClearedFields returns all nullable fields that were cleared during this
  18346. // mutation.
  18347. func (m *SopNodeMutation) ClearedFields() []string {
  18348. var fields []string
  18349. if m.FieldCleared(sopnode.FieldStatus) {
  18350. fields = append(fields, sopnode.FieldStatus)
  18351. }
  18352. if m.FieldCleared(sopnode.FieldDeletedAt) {
  18353. fields = append(fields, sopnode.FieldDeletedAt)
  18354. }
  18355. if m.FieldCleared(sopnode.FieldConditionList) {
  18356. fields = append(fields, sopnode.FieldConditionList)
  18357. }
  18358. if m.FieldCleared(sopnode.FieldActionMessage) {
  18359. fields = append(fields, sopnode.FieldActionMessage)
  18360. }
  18361. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  18362. fields = append(fields, sopnode.FieldActionLabelAdd)
  18363. }
  18364. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  18365. fields = append(fields, sopnode.FieldActionLabelDel)
  18366. }
  18367. if m.FieldCleared(sopnode.FieldActionForward) {
  18368. fields = append(fields, sopnode.FieldActionForward)
  18369. }
  18370. return fields
  18371. }
  18372. // FieldCleared returns a boolean indicating if a field with the given name was
  18373. // cleared in this mutation.
  18374. func (m *SopNodeMutation) FieldCleared(name string) bool {
  18375. _, ok := m.clearedFields[name]
  18376. return ok
  18377. }
  18378. // ClearField clears the value of the field with the given name. It returns an
  18379. // error if the field is not defined in the schema.
  18380. func (m *SopNodeMutation) ClearField(name string) error {
  18381. switch name {
  18382. case sopnode.FieldStatus:
  18383. m.ClearStatus()
  18384. return nil
  18385. case sopnode.FieldDeletedAt:
  18386. m.ClearDeletedAt()
  18387. return nil
  18388. case sopnode.FieldConditionList:
  18389. m.ClearConditionList()
  18390. return nil
  18391. case sopnode.FieldActionMessage:
  18392. m.ClearActionMessage()
  18393. return nil
  18394. case sopnode.FieldActionLabelAdd:
  18395. m.ClearActionLabelAdd()
  18396. return nil
  18397. case sopnode.FieldActionLabelDel:
  18398. m.ClearActionLabelDel()
  18399. return nil
  18400. case sopnode.FieldActionForward:
  18401. m.ClearActionForward()
  18402. return nil
  18403. }
  18404. return fmt.Errorf("unknown SopNode nullable field %s", name)
  18405. }
  18406. // ResetField resets all changes in the mutation for the field with the given name.
  18407. // It returns an error if the field is not defined in the schema.
  18408. func (m *SopNodeMutation) ResetField(name string) error {
  18409. switch name {
  18410. case sopnode.FieldCreatedAt:
  18411. m.ResetCreatedAt()
  18412. return nil
  18413. case sopnode.FieldUpdatedAt:
  18414. m.ResetUpdatedAt()
  18415. return nil
  18416. case sopnode.FieldStatus:
  18417. m.ResetStatus()
  18418. return nil
  18419. case sopnode.FieldDeletedAt:
  18420. m.ResetDeletedAt()
  18421. return nil
  18422. case sopnode.FieldStageID:
  18423. m.ResetStageID()
  18424. return nil
  18425. case sopnode.FieldParentID:
  18426. m.ResetParentID()
  18427. return nil
  18428. case sopnode.FieldName:
  18429. m.ResetName()
  18430. return nil
  18431. case sopnode.FieldConditionType:
  18432. m.ResetConditionType()
  18433. return nil
  18434. case sopnode.FieldConditionList:
  18435. m.ResetConditionList()
  18436. return nil
  18437. case sopnode.FieldNoReplyCondition:
  18438. m.ResetNoReplyCondition()
  18439. return nil
  18440. case sopnode.FieldNoReplyUnit:
  18441. m.ResetNoReplyUnit()
  18442. return nil
  18443. case sopnode.FieldActionMessage:
  18444. m.ResetActionMessage()
  18445. return nil
  18446. case sopnode.FieldActionLabelAdd:
  18447. m.ResetActionLabelAdd()
  18448. return nil
  18449. case sopnode.FieldActionLabelDel:
  18450. m.ResetActionLabelDel()
  18451. return nil
  18452. case sopnode.FieldActionForward:
  18453. m.ResetActionForward()
  18454. return nil
  18455. }
  18456. return fmt.Errorf("unknown SopNode field %s", name)
  18457. }
  18458. // AddedEdges returns all edge names that were set/added in this mutation.
  18459. func (m *SopNodeMutation) AddedEdges() []string {
  18460. edges := make([]string, 0, 2)
  18461. if m.sop_stage != nil {
  18462. edges = append(edges, sopnode.EdgeSopStage)
  18463. }
  18464. if m.node_messages != nil {
  18465. edges = append(edges, sopnode.EdgeNodeMessages)
  18466. }
  18467. return edges
  18468. }
  18469. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18470. // name in this mutation.
  18471. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  18472. switch name {
  18473. case sopnode.EdgeSopStage:
  18474. if id := m.sop_stage; id != nil {
  18475. return []ent.Value{*id}
  18476. }
  18477. case sopnode.EdgeNodeMessages:
  18478. ids := make([]ent.Value, 0, len(m.node_messages))
  18479. for id := range m.node_messages {
  18480. ids = append(ids, id)
  18481. }
  18482. return ids
  18483. }
  18484. return nil
  18485. }
  18486. // RemovedEdges returns all edge names that were removed in this mutation.
  18487. func (m *SopNodeMutation) RemovedEdges() []string {
  18488. edges := make([]string, 0, 2)
  18489. if m.removednode_messages != nil {
  18490. edges = append(edges, sopnode.EdgeNodeMessages)
  18491. }
  18492. return edges
  18493. }
  18494. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18495. // the given name in this mutation.
  18496. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  18497. switch name {
  18498. case sopnode.EdgeNodeMessages:
  18499. ids := make([]ent.Value, 0, len(m.removednode_messages))
  18500. for id := range m.removednode_messages {
  18501. ids = append(ids, id)
  18502. }
  18503. return ids
  18504. }
  18505. return nil
  18506. }
  18507. // ClearedEdges returns all edge names that were cleared in this mutation.
  18508. func (m *SopNodeMutation) ClearedEdges() []string {
  18509. edges := make([]string, 0, 2)
  18510. if m.clearedsop_stage {
  18511. edges = append(edges, sopnode.EdgeSopStage)
  18512. }
  18513. if m.clearednode_messages {
  18514. edges = append(edges, sopnode.EdgeNodeMessages)
  18515. }
  18516. return edges
  18517. }
  18518. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18519. // was cleared in this mutation.
  18520. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  18521. switch name {
  18522. case sopnode.EdgeSopStage:
  18523. return m.clearedsop_stage
  18524. case sopnode.EdgeNodeMessages:
  18525. return m.clearednode_messages
  18526. }
  18527. return false
  18528. }
  18529. // ClearEdge clears the value of the edge with the given name. It returns an error
  18530. // if that edge is not defined in the schema.
  18531. func (m *SopNodeMutation) ClearEdge(name string) error {
  18532. switch name {
  18533. case sopnode.EdgeSopStage:
  18534. m.ClearSopStage()
  18535. return nil
  18536. }
  18537. return fmt.Errorf("unknown SopNode unique edge %s", name)
  18538. }
  18539. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18540. // It returns an error if the edge is not defined in the schema.
  18541. func (m *SopNodeMutation) ResetEdge(name string) error {
  18542. switch name {
  18543. case sopnode.EdgeSopStage:
  18544. m.ResetSopStage()
  18545. return nil
  18546. case sopnode.EdgeNodeMessages:
  18547. m.ResetNodeMessages()
  18548. return nil
  18549. }
  18550. return fmt.Errorf("unknown SopNode edge %s", name)
  18551. }
  18552. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  18553. type SopStageMutation struct {
  18554. config
  18555. op Op
  18556. typ string
  18557. id *uint64
  18558. created_at *time.Time
  18559. updated_at *time.Time
  18560. status *uint8
  18561. addstatus *int8
  18562. deleted_at *time.Time
  18563. name *string
  18564. condition_type *int
  18565. addcondition_type *int
  18566. condition_operator *int
  18567. addcondition_operator *int
  18568. condition_list *[]custom_types.Condition
  18569. appendcondition_list []custom_types.Condition
  18570. action_message *[]custom_types.Action
  18571. appendaction_message []custom_types.Action
  18572. action_label_add *[]uint64
  18573. appendaction_label_add []uint64
  18574. action_label_del *[]uint64
  18575. appendaction_label_del []uint64
  18576. action_forward **custom_types.ActionForward
  18577. index_sort *int
  18578. addindex_sort *int
  18579. clearedFields map[string]struct{}
  18580. sop_task *uint64
  18581. clearedsop_task bool
  18582. stage_nodes map[uint64]struct{}
  18583. removedstage_nodes map[uint64]struct{}
  18584. clearedstage_nodes bool
  18585. stage_messages map[uint64]struct{}
  18586. removedstage_messages map[uint64]struct{}
  18587. clearedstage_messages bool
  18588. done bool
  18589. oldValue func(context.Context) (*SopStage, error)
  18590. predicates []predicate.SopStage
  18591. }
  18592. var _ ent.Mutation = (*SopStageMutation)(nil)
  18593. // sopstageOption allows management of the mutation configuration using functional options.
  18594. type sopstageOption func(*SopStageMutation)
  18595. // newSopStageMutation creates new mutation for the SopStage entity.
  18596. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  18597. m := &SopStageMutation{
  18598. config: c,
  18599. op: op,
  18600. typ: TypeSopStage,
  18601. clearedFields: make(map[string]struct{}),
  18602. }
  18603. for _, opt := range opts {
  18604. opt(m)
  18605. }
  18606. return m
  18607. }
  18608. // withSopStageID sets the ID field of the mutation.
  18609. func withSopStageID(id uint64) sopstageOption {
  18610. return func(m *SopStageMutation) {
  18611. var (
  18612. err error
  18613. once sync.Once
  18614. value *SopStage
  18615. )
  18616. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  18617. once.Do(func() {
  18618. if m.done {
  18619. err = errors.New("querying old values post mutation is not allowed")
  18620. } else {
  18621. value, err = m.Client().SopStage.Get(ctx, id)
  18622. }
  18623. })
  18624. return value, err
  18625. }
  18626. m.id = &id
  18627. }
  18628. }
  18629. // withSopStage sets the old SopStage of the mutation.
  18630. func withSopStage(node *SopStage) sopstageOption {
  18631. return func(m *SopStageMutation) {
  18632. m.oldValue = func(context.Context) (*SopStage, error) {
  18633. return node, nil
  18634. }
  18635. m.id = &node.ID
  18636. }
  18637. }
  18638. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18639. // executed in a transaction (ent.Tx), a transactional client is returned.
  18640. func (m SopStageMutation) Client() *Client {
  18641. client := &Client{config: m.config}
  18642. client.init()
  18643. return client
  18644. }
  18645. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18646. // it returns an error otherwise.
  18647. func (m SopStageMutation) Tx() (*Tx, error) {
  18648. if _, ok := m.driver.(*txDriver); !ok {
  18649. return nil, errors.New("ent: mutation is not running in a transaction")
  18650. }
  18651. tx := &Tx{config: m.config}
  18652. tx.init()
  18653. return tx, nil
  18654. }
  18655. // SetID sets the value of the id field. Note that this
  18656. // operation is only accepted on creation of SopStage entities.
  18657. func (m *SopStageMutation) SetID(id uint64) {
  18658. m.id = &id
  18659. }
  18660. // ID returns the ID value in the mutation. Note that the ID is only available
  18661. // if it was provided to the builder or after it was returned from the database.
  18662. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  18663. if m.id == nil {
  18664. return
  18665. }
  18666. return *m.id, true
  18667. }
  18668. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18669. // That means, if the mutation is applied within a transaction with an isolation level such
  18670. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18671. // or updated by the mutation.
  18672. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  18673. switch {
  18674. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18675. id, exists := m.ID()
  18676. if exists {
  18677. return []uint64{id}, nil
  18678. }
  18679. fallthrough
  18680. case m.op.Is(OpUpdate | OpDelete):
  18681. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  18682. default:
  18683. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18684. }
  18685. }
  18686. // SetCreatedAt sets the "created_at" field.
  18687. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  18688. m.created_at = &t
  18689. }
  18690. // CreatedAt returns the value of the "created_at" field in the mutation.
  18691. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  18692. v := m.created_at
  18693. if v == nil {
  18694. return
  18695. }
  18696. return *v, true
  18697. }
  18698. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  18699. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18701. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18702. if !m.op.Is(OpUpdateOne) {
  18703. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18704. }
  18705. if m.id == nil || m.oldValue == nil {
  18706. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18707. }
  18708. oldValue, err := m.oldValue(ctx)
  18709. if err != nil {
  18710. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18711. }
  18712. return oldValue.CreatedAt, nil
  18713. }
  18714. // ResetCreatedAt resets all changes to the "created_at" field.
  18715. func (m *SopStageMutation) ResetCreatedAt() {
  18716. m.created_at = nil
  18717. }
  18718. // SetUpdatedAt sets the "updated_at" field.
  18719. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  18720. m.updated_at = &t
  18721. }
  18722. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18723. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  18724. v := m.updated_at
  18725. if v == nil {
  18726. return
  18727. }
  18728. return *v, true
  18729. }
  18730. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  18731. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18733. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18734. if !m.op.Is(OpUpdateOne) {
  18735. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18736. }
  18737. if m.id == nil || m.oldValue == nil {
  18738. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18739. }
  18740. oldValue, err := m.oldValue(ctx)
  18741. if err != nil {
  18742. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18743. }
  18744. return oldValue.UpdatedAt, nil
  18745. }
  18746. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18747. func (m *SopStageMutation) ResetUpdatedAt() {
  18748. m.updated_at = nil
  18749. }
  18750. // SetStatus sets the "status" field.
  18751. func (m *SopStageMutation) SetStatus(u uint8) {
  18752. m.status = &u
  18753. m.addstatus = nil
  18754. }
  18755. // Status returns the value of the "status" field in the mutation.
  18756. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  18757. v := m.status
  18758. if v == nil {
  18759. return
  18760. }
  18761. return *v, true
  18762. }
  18763. // OldStatus returns the old "status" field's value of the SopStage entity.
  18764. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18766. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18767. if !m.op.Is(OpUpdateOne) {
  18768. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18769. }
  18770. if m.id == nil || m.oldValue == nil {
  18771. return v, errors.New("OldStatus requires an ID field in the mutation")
  18772. }
  18773. oldValue, err := m.oldValue(ctx)
  18774. if err != nil {
  18775. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18776. }
  18777. return oldValue.Status, nil
  18778. }
  18779. // AddStatus adds u to the "status" field.
  18780. func (m *SopStageMutation) AddStatus(u int8) {
  18781. if m.addstatus != nil {
  18782. *m.addstatus += u
  18783. } else {
  18784. m.addstatus = &u
  18785. }
  18786. }
  18787. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18788. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  18789. v := m.addstatus
  18790. if v == nil {
  18791. return
  18792. }
  18793. return *v, true
  18794. }
  18795. // ClearStatus clears the value of the "status" field.
  18796. func (m *SopStageMutation) ClearStatus() {
  18797. m.status = nil
  18798. m.addstatus = nil
  18799. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  18800. }
  18801. // StatusCleared returns if the "status" field was cleared in this mutation.
  18802. func (m *SopStageMutation) StatusCleared() bool {
  18803. _, ok := m.clearedFields[sopstage.FieldStatus]
  18804. return ok
  18805. }
  18806. // ResetStatus resets all changes to the "status" field.
  18807. func (m *SopStageMutation) ResetStatus() {
  18808. m.status = nil
  18809. m.addstatus = nil
  18810. delete(m.clearedFields, sopstage.FieldStatus)
  18811. }
  18812. // SetDeletedAt sets the "deleted_at" field.
  18813. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  18814. m.deleted_at = &t
  18815. }
  18816. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18817. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  18818. v := m.deleted_at
  18819. if v == nil {
  18820. return
  18821. }
  18822. return *v, true
  18823. }
  18824. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  18825. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18827. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18828. if !m.op.Is(OpUpdateOne) {
  18829. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18830. }
  18831. if m.id == nil || m.oldValue == nil {
  18832. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18833. }
  18834. oldValue, err := m.oldValue(ctx)
  18835. if err != nil {
  18836. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18837. }
  18838. return oldValue.DeletedAt, nil
  18839. }
  18840. // ClearDeletedAt clears the value of the "deleted_at" field.
  18841. func (m *SopStageMutation) ClearDeletedAt() {
  18842. m.deleted_at = nil
  18843. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  18844. }
  18845. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18846. func (m *SopStageMutation) DeletedAtCleared() bool {
  18847. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  18848. return ok
  18849. }
  18850. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18851. func (m *SopStageMutation) ResetDeletedAt() {
  18852. m.deleted_at = nil
  18853. delete(m.clearedFields, sopstage.FieldDeletedAt)
  18854. }
  18855. // SetTaskID sets the "task_id" field.
  18856. func (m *SopStageMutation) SetTaskID(u uint64) {
  18857. m.sop_task = &u
  18858. }
  18859. // TaskID returns the value of the "task_id" field in the mutation.
  18860. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  18861. v := m.sop_task
  18862. if v == nil {
  18863. return
  18864. }
  18865. return *v, true
  18866. }
  18867. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  18868. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18870. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  18871. if !m.op.Is(OpUpdateOne) {
  18872. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  18873. }
  18874. if m.id == nil || m.oldValue == nil {
  18875. return v, errors.New("OldTaskID requires an ID field in the mutation")
  18876. }
  18877. oldValue, err := m.oldValue(ctx)
  18878. if err != nil {
  18879. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  18880. }
  18881. return oldValue.TaskID, nil
  18882. }
  18883. // ResetTaskID resets all changes to the "task_id" field.
  18884. func (m *SopStageMutation) ResetTaskID() {
  18885. m.sop_task = nil
  18886. }
  18887. // SetName sets the "name" field.
  18888. func (m *SopStageMutation) SetName(s string) {
  18889. m.name = &s
  18890. }
  18891. // Name returns the value of the "name" field in the mutation.
  18892. func (m *SopStageMutation) Name() (r string, exists bool) {
  18893. v := m.name
  18894. if v == nil {
  18895. return
  18896. }
  18897. return *v, true
  18898. }
  18899. // OldName returns the old "name" field's value of the SopStage entity.
  18900. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18902. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  18903. if !m.op.Is(OpUpdateOne) {
  18904. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18905. }
  18906. if m.id == nil || m.oldValue == nil {
  18907. return v, errors.New("OldName requires an ID field in the mutation")
  18908. }
  18909. oldValue, err := m.oldValue(ctx)
  18910. if err != nil {
  18911. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18912. }
  18913. return oldValue.Name, nil
  18914. }
  18915. // ResetName resets all changes to the "name" field.
  18916. func (m *SopStageMutation) ResetName() {
  18917. m.name = nil
  18918. }
  18919. // SetConditionType sets the "condition_type" field.
  18920. func (m *SopStageMutation) SetConditionType(i int) {
  18921. m.condition_type = &i
  18922. m.addcondition_type = nil
  18923. }
  18924. // ConditionType returns the value of the "condition_type" field in the mutation.
  18925. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  18926. v := m.condition_type
  18927. if v == nil {
  18928. return
  18929. }
  18930. return *v, true
  18931. }
  18932. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  18933. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18935. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18936. if !m.op.Is(OpUpdateOne) {
  18937. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18938. }
  18939. if m.id == nil || m.oldValue == nil {
  18940. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18941. }
  18942. oldValue, err := m.oldValue(ctx)
  18943. if err != nil {
  18944. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18945. }
  18946. return oldValue.ConditionType, nil
  18947. }
  18948. // AddConditionType adds i to the "condition_type" field.
  18949. func (m *SopStageMutation) AddConditionType(i int) {
  18950. if m.addcondition_type != nil {
  18951. *m.addcondition_type += i
  18952. } else {
  18953. m.addcondition_type = &i
  18954. }
  18955. }
  18956. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18957. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  18958. v := m.addcondition_type
  18959. if v == nil {
  18960. return
  18961. }
  18962. return *v, true
  18963. }
  18964. // ResetConditionType resets all changes to the "condition_type" field.
  18965. func (m *SopStageMutation) ResetConditionType() {
  18966. m.condition_type = nil
  18967. m.addcondition_type = nil
  18968. }
  18969. // SetConditionOperator sets the "condition_operator" field.
  18970. func (m *SopStageMutation) SetConditionOperator(i int) {
  18971. m.condition_operator = &i
  18972. m.addcondition_operator = nil
  18973. }
  18974. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  18975. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  18976. v := m.condition_operator
  18977. if v == nil {
  18978. return
  18979. }
  18980. return *v, true
  18981. }
  18982. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  18983. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18985. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  18986. if !m.op.Is(OpUpdateOne) {
  18987. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  18988. }
  18989. if m.id == nil || m.oldValue == nil {
  18990. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  18991. }
  18992. oldValue, err := m.oldValue(ctx)
  18993. if err != nil {
  18994. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  18995. }
  18996. return oldValue.ConditionOperator, nil
  18997. }
  18998. // AddConditionOperator adds i to the "condition_operator" field.
  18999. func (m *SopStageMutation) AddConditionOperator(i int) {
  19000. if m.addcondition_operator != nil {
  19001. *m.addcondition_operator += i
  19002. } else {
  19003. m.addcondition_operator = &i
  19004. }
  19005. }
  19006. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  19007. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  19008. v := m.addcondition_operator
  19009. if v == nil {
  19010. return
  19011. }
  19012. return *v, true
  19013. }
  19014. // ResetConditionOperator resets all changes to the "condition_operator" field.
  19015. func (m *SopStageMutation) ResetConditionOperator() {
  19016. m.condition_operator = nil
  19017. m.addcondition_operator = nil
  19018. }
  19019. // SetConditionList sets the "condition_list" field.
  19020. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  19021. m.condition_list = &ct
  19022. m.appendcondition_list = nil
  19023. }
  19024. // ConditionList returns the value of the "condition_list" field in the mutation.
  19025. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  19026. v := m.condition_list
  19027. if v == nil {
  19028. return
  19029. }
  19030. return *v, true
  19031. }
  19032. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  19033. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19035. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  19036. if !m.op.Is(OpUpdateOne) {
  19037. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  19038. }
  19039. if m.id == nil || m.oldValue == nil {
  19040. return v, errors.New("OldConditionList requires an ID field in the mutation")
  19041. }
  19042. oldValue, err := m.oldValue(ctx)
  19043. if err != nil {
  19044. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  19045. }
  19046. return oldValue.ConditionList, nil
  19047. }
  19048. // AppendConditionList adds ct to the "condition_list" field.
  19049. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  19050. m.appendcondition_list = append(m.appendcondition_list, ct...)
  19051. }
  19052. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  19053. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  19054. if len(m.appendcondition_list) == 0 {
  19055. return nil, false
  19056. }
  19057. return m.appendcondition_list, true
  19058. }
  19059. // ResetConditionList resets all changes to the "condition_list" field.
  19060. func (m *SopStageMutation) ResetConditionList() {
  19061. m.condition_list = nil
  19062. m.appendcondition_list = nil
  19063. }
  19064. // SetActionMessage sets the "action_message" field.
  19065. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  19066. m.action_message = &ct
  19067. m.appendaction_message = nil
  19068. }
  19069. // ActionMessage returns the value of the "action_message" field in the mutation.
  19070. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  19071. v := m.action_message
  19072. if v == nil {
  19073. return
  19074. }
  19075. return *v, true
  19076. }
  19077. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  19078. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19080. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  19081. if !m.op.Is(OpUpdateOne) {
  19082. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  19083. }
  19084. if m.id == nil || m.oldValue == nil {
  19085. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  19086. }
  19087. oldValue, err := m.oldValue(ctx)
  19088. if err != nil {
  19089. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  19090. }
  19091. return oldValue.ActionMessage, nil
  19092. }
  19093. // AppendActionMessage adds ct to the "action_message" field.
  19094. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  19095. m.appendaction_message = append(m.appendaction_message, ct...)
  19096. }
  19097. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  19098. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  19099. if len(m.appendaction_message) == 0 {
  19100. return nil, false
  19101. }
  19102. return m.appendaction_message, true
  19103. }
  19104. // ClearActionMessage clears the value of the "action_message" field.
  19105. func (m *SopStageMutation) ClearActionMessage() {
  19106. m.action_message = nil
  19107. m.appendaction_message = nil
  19108. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  19109. }
  19110. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  19111. func (m *SopStageMutation) ActionMessageCleared() bool {
  19112. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  19113. return ok
  19114. }
  19115. // ResetActionMessage resets all changes to the "action_message" field.
  19116. func (m *SopStageMutation) ResetActionMessage() {
  19117. m.action_message = nil
  19118. m.appendaction_message = nil
  19119. delete(m.clearedFields, sopstage.FieldActionMessage)
  19120. }
  19121. // SetActionLabelAdd sets the "action_label_add" field.
  19122. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  19123. m.action_label_add = &u
  19124. m.appendaction_label_add = nil
  19125. }
  19126. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  19127. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  19128. v := m.action_label_add
  19129. if v == nil {
  19130. return
  19131. }
  19132. return *v, true
  19133. }
  19134. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  19135. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19137. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  19138. if !m.op.Is(OpUpdateOne) {
  19139. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  19140. }
  19141. if m.id == nil || m.oldValue == nil {
  19142. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  19143. }
  19144. oldValue, err := m.oldValue(ctx)
  19145. if err != nil {
  19146. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  19147. }
  19148. return oldValue.ActionLabelAdd, nil
  19149. }
  19150. // AppendActionLabelAdd adds u to the "action_label_add" field.
  19151. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  19152. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  19153. }
  19154. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  19155. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  19156. if len(m.appendaction_label_add) == 0 {
  19157. return nil, false
  19158. }
  19159. return m.appendaction_label_add, true
  19160. }
  19161. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  19162. func (m *SopStageMutation) ClearActionLabelAdd() {
  19163. m.action_label_add = nil
  19164. m.appendaction_label_add = nil
  19165. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  19166. }
  19167. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  19168. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  19169. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  19170. return ok
  19171. }
  19172. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  19173. func (m *SopStageMutation) ResetActionLabelAdd() {
  19174. m.action_label_add = nil
  19175. m.appendaction_label_add = nil
  19176. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  19177. }
  19178. // SetActionLabelDel sets the "action_label_del" field.
  19179. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  19180. m.action_label_del = &u
  19181. m.appendaction_label_del = nil
  19182. }
  19183. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19184. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  19185. v := m.action_label_del
  19186. if v == nil {
  19187. return
  19188. }
  19189. return *v, true
  19190. }
  19191. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  19192. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19194. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19195. if !m.op.Is(OpUpdateOne) {
  19196. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19197. }
  19198. if m.id == nil || m.oldValue == nil {
  19199. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19200. }
  19201. oldValue, err := m.oldValue(ctx)
  19202. if err != nil {
  19203. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19204. }
  19205. return oldValue.ActionLabelDel, nil
  19206. }
  19207. // AppendActionLabelDel adds u to the "action_label_del" field.
  19208. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  19209. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19210. }
  19211. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19212. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19213. if len(m.appendaction_label_del) == 0 {
  19214. return nil, false
  19215. }
  19216. return m.appendaction_label_del, true
  19217. }
  19218. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19219. func (m *SopStageMutation) ClearActionLabelDel() {
  19220. m.action_label_del = nil
  19221. m.appendaction_label_del = nil
  19222. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  19223. }
  19224. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19225. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  19226. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  19227. return ok
  19228. }
  19229. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19230. func (m *SopStageMutation) ResetActionLabelDel() {
  19231. m.action_label_del = nil
  19232. m.appendaction_label_del = nil
  19233. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  19234. }
  19235. // SetActionForward sets the "action_forward" field.
  19236. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  19237. m.action_forward = &ctf
  19238. }
  19239. // ActionForward returns the value of the "action_forward" field in the mutation.
  19240. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  19241. v := m.action_forward
  19242. if v == nil {
  19243. return
  19244. }
  19245. return *v, true
  19246. }
  19247. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  19248. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19250. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  19251. if !m.op.Is(OpUpdateOne) {
  19252. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  19253. }
  19254. if m.id == nil || m.oldValue == nil {
  19255. return v, errors.New("OldActionForward requires an ID field in the mutation")
  19256. }
  19257. oldValue, err := m.oldValue(ctx)
  19258. if err != nil {
  19259. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  19260. }
  19261. return oldValue.ActionForward, nil
  19262. }
  19263. // ClearActionForward clears the value of the "action_forward" field.
  19264. func (m *SopStageMutation) ClearActionForward() {
  19265. m.action_forward = nil
  19266. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  19267. }
  19268. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  19269. func (m *SopStageMutation) ActionForwardCleared() bool {
  19270. _, ok := m.clearedFields[sopstage.FieldActionForward]
  19271. return ok
  19272. }
  19273. // ResetActionForward resets all changes to the "action_forward" field.
  19274. func (m *SopStageMutation) ResetActionForward() {
  19275. m.action_forward = nil
  19276. delete(m.clearedFields, sopstage.FieldActionForward)
  19277. }
  19278. // SetIndexSort sets the "index_sort" field.
  19279. func (m *SopStageMutation) SetIndexSort(i int) {
  19280. m.index_sort = &i
  19281. m.addindex_sort = nil
  19282. }
  19283. // IndexSort returns the value of the "index_sort" field in the mutation.
  19284. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  19285. v := m.index_sort
  19286. if v == nil {
  19287. return
  19288. }
  19289. return *v, true
  19290. }
  19291. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  19292. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19294. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  19295. if !m.op.Is(OpUpdateOne) {
  19296. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  19297. }
  19298. if m.id == nil || m.oldValue == nil {
  19299. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  19300. }
  19301. oldValue, err := m.oldValue(ctx)
  19302. if err != nil {
  19303. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  19304. }
  19305. return oldValue.IndexSort, nil
  19306. }
  19307. // AddIndexSort adds i to the "index_sort" field.
  19308. func (m *SopStageMutation) AddIndexSort(i int) {
  19309. if m.addindex_sort != nil {
  19310. *m.addindex_sort += i
  19311. } else {
  19312. m.addindex_sort = &i
  19313. }
  19314. }
  19315. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  19316. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  19317. v := m.addindex_sort
  19318. if v == nil {
  19319. return
  19320. }
  19321. return *v, true
  19322. }
  19323. // ClearIndexSort clears the value of the "index_sort" field.
  19324. func (m *SopStageMutation) ClearIndexSort() {
  19325. m.index_sort = nil
  19326. m.addindex_sort = nil
  19327. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  19328. }
  19329. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  19330. func (m *SopStageMutation) IndexSortCleared() bool {
  19331. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  19332. return ok
  19333. }
  19334. // ResetIndexSort resets all changes to the "index_sort" field.
  19335. func (m *SopStageMutation) ResetIndexSort() {
  19336. m.index_sort = nil
  19337. m.addindex_sort = nil
  19338. delete(m.clearedFields, sopstage.FieldIndexSort)
  19339. }
  19340. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  19341. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  19342. m.sop_task = &id
  19343. }
  19344. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  19345. func (m *SopStageMutation) ClearSopTask() {
  19346. m.clearedsop_task = true
  19347. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  19348. }
  19349. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  19350. func (m *SopStageMutation) SopTaskCleared() bool {
  19351. return m.clearedsop_task
  19352. }
  19353. // SopTaskID returns the "sop_task" edge ID in the mutation.
  19354. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  19355. if m.sop_task != nil {
  19356. return *m.sop_task, true
  19357. }
  19358. return
  19359. }
  19360. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  19361. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19362. // SopTaskID instead. It exists only for internal usage by the builders.
  19363. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  19364. if id := m.sop_task; id != nil {
  19365. ids = append(ids, *id)
  19366. }
  19367. return
  19368. }
  19369. // ResetSopTask resets all changes to the "sop_task" edge.
  19370. func (m *SopStageMutation) ResetSopTask() {
  19371. m.sop_task = nil
  19372. m.clearedsop_task = false
  19373. }
  19374. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  19375. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  19376. if m.stage_nodes == nil {
  19377. m.stage_nodes = make(map[uint64]struct{})
  19378. }
  19379. for i := range ids {
  19380. m.stage_nodes[ids[i]] = struct{}{}
  19381. }
  19382. }
  19383. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  19384. func (m *SopStageMutation) ClearStageNodes() {
  19385. m.clearedstage_nodes = true
  19386. }
  19387. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  19388. func (m *SopStageMutation) StageNodesCleared() bool {
  19389. return m.clearedstage_nodes
  19390. }
  19391. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  19392. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  19393. if m.removedstage_nodes == nil {
  19394. m.removedstage_nodes = make(map[uint64]struct{})
  19395. }
  19396. for i := range ids {
  19397. delete(m.stage_nodes, ids[i])
  19398. m.removedstage_nodes[ids[i]] = struct{}{}
  19399. }
  19400. }
  19401. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  19402. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  19403. for id := range m.removedstage_nodes {
  19404. ids = append(ids, id)
  19405. }
  19406. return
  19407. }
  19408. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  19409. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  19410. for id := range m.stage_nodes {
  19411. ids = append(ids, id)
  19412. }
  19413. return
  19414. }
  19415. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  19416. func (m *SopStageMutation) ResetStageNodes() {
  19417. m.stage_nodes = nil
  19418. m.clearedstage_nodes = false
  19419. m.removedstage_nodes = nil
  19420. }
  19421. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  19422. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  19423. if m.stage_messages == nil {
  19424. m.stage_messages = make(map[uint64]struct{})
  19425. }
  19426. for i := range ids {
  19427. m.stage_messages[ids[i]] = struct{}{}
  19428. }
  19429. }
  19430. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  19431. func (m *SopStageMutation) ClearStageMessages() {
  19432. m.clearedstage_messages = true
  19433. }
  19434. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  19435. func (m *SopStageMutation) StageMessagesCleared() bool {
  19436. return m.clearedstage_messages
  19437. }
  19438. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  19439. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  19440. if m.removedstage_messages == nil {
  19441. m.removedstage_messages = make(map[uint64]struct{})
  19442. }
  19443. for i := range ids {
  19444. delete(m.stage_messages, ids[i])
  19445. m.removedstage_messages[ids[i]] = struct{}{}
  19446. }
  19447. }
  19448. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  19449. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  19450. for id := range m.removedstage_messages {
  19451. ids = append(ids, id)
  19452. }
  19453. return
  19454. }
  19455. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  19456. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  19457. for id := range m.stage_messages {
  19458. ids = append(ids, id)
  19459. }
  19460. return
  19461. }
  19462. // ResetStageMessages resets all changes to the "stage_messages" edge.
  19463. func (m *SopStageMutation) ResetStageMessages() {
  19464. m.stage_messages = nil
  19465. m.clearedstage_messages = false
  19466. m.removedstage_messages = nil
  19467. }
  19468. // Where appends a list predicates to the SopStageMutation builder.
  19469. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  19470. m.predicates = append(m.predicates, ps...)
  19471. }
  19472. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  19473. // users can use type-assertion to append predicates that do not depend on any generated package.
  19474. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  19475. p := make([]predicate.SopStage, len(ps))
  19476. for i := range ps {
  19477. p[i] = ps[i]
  19478. }
  19479. m.Where(p...)
  19480. }
  19481. // Op returns the operation name.
  19482. func (m *SopStageMutation) Op() Op {
  19483. return m.op
  19484. }
  19485. // SetOp allows setting the mutation operation.
  19486. func (m *SopStageMutation) SetOp(op Op) {
  19487. m.op = op
  19488. }
  19489. // Type returns the node type of this mutation (SopStage).
  19490. func (m *SopStageMutation) Type() string {
  19491. return m.typ
  19492. }
  19493. // Fields returns all fields that were changed during this mutation. Note that in
  19494. // order to get all numeric fields that were incremented/decremented, call
  19495. // AddedFields().
  19496. func (m *SopStageMutation) Fields() []string {
  19497. fields := make([]string, 0, 14)
  19498. if m.created_at != nil {
  19499. fields = append(fields, sopstage.FieldCreatedAt)
  19500. }
  19501. if m.updated_at != nil {
  19502. fields = append(fields, sopstage.FieldUpdatedAt)
  19503. }
  19504. if m.status != nil {
  19505. fields = append(fields, sopstage.FieldStatus)
  19506. }
  19507. if m.deleted_at != nil {
  19508. fields = append(fields, sopstage.FieldDeletedAt)
  19509. }
  19510. if m.sop_task != nil {
  19511. fields = append(fields, sopstage.FieldTaskID)
  19512. }
  19513. if m.name != nil {
  19514. fields = append(fields, sopstage.FieldName)
  19515. }
  19516. if m.condition_type != nil {
  19517. fields = append(fields, sopstage.FieldConditionType)
  19518. }
  19519. if m.condition_operator != nil {
  19520. fields = append(fields, sopstage.FieldConditionOperator)
  19521. }
  19522. if m.condition_list != nil {
  19523. fields = append(fields, sopstage.FieldConditionList)
  19524. }
  19525. if m.action_message != nil {
  19526. fields = append(fields, sopstage.FieldActionMessage)
  19527. }
  19528. if m.action_label_add != nil {
  19529. fields = append(fields, sopstage.FieldActionLabelAdd)
  19530. }
  19531. if m.action_label_del != nil {
  19532. fields = append(fields, sopstage.FieldActionLabelDel)
  19533. }
  19534. if m.action_forward != nil {
  19535. fields = append(fields, sopstage.FieldActionForward)
  19536. }
  19537. if m.index_sort != nil {
  19538. fields = append(fields, sopstage.FieldIndexSort)
  19539. }
  19540. return fields
  19541. }
  19542. // Field returns the value of a field with the given name. The second boolean
  19543. // return value indicates that this field was not set, or was not defined in the
  19544. // schema.
  19545. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  19546. switch name {
  19547. case sopstage.FieldCreatedAt:
  19548. return m.CreatedAt()
  19549. case sopstage.FieldUpdatedAt:
  19550. return m.UpdatedAt()
  19551. case sopstage.FieldStatus:
  19552. return m.Status()
  19553. case sopstage.FieldDeletedAt:
  19554. return m.DeletedAt()
  19555. case sopstage.FieldTaskID:
  19556. return m.TaskID()
  19557. case sopstage.FieldName:
  19558. return m.Name()
  19559. case sopstage.FieldConditionType:
  19560. return m.ConditionType()
  19561. case sopstage.FieldConditionOperator:
  19562. return m.ConditionOperator()
  19563. case sopstage.FieldConditionList:
  19564. return m.ConditionList()
  19565. case sopstage.FieldActionMessage:
  19566. return m.ActionMessage()
  19567. case sopstage.FieldActionLabelAdd:
  19568. return m.ActionLabelAdd()
  19569. case sopstage.FieldActionLabelDel:
  19570. return m.ActionLabelDel()
  19571. case sopstage.FieldActionForward:
  19572. return m.ActionForward()
  19573. case sopstage.FieldIndexSort:
  19574. return m.IndexSort()
  19575. }
  19576. return nil, false
  19577. }
  19578. // OldField returns the old value of the field from the database. An error is
  19579. // returned if the mutation operation is not UpdateOne, or the query to the
  19580. // database failed.
  19581. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19582. switch name {
  19583. case sopstage.FieldCreatedAt:
  19584. return m.OldCreatedAt(ctx)
  19585. case sopstage.FieldUpdatedAt:
  19586. return m.OldUpdatedAt(ctx)
  19587. case sopstage.FieldStatus:
  19588. return m.OldStatus(ctx)
  19589. case sopstage.FieldDeletedAt:
  19590. return m.OldDeletedAt(ctx)
  19591. case sopstage.FieldTaskID:
  19592. return m.OldTaskID(ctx)
  19593. case sopstage.FieldName:
  19594. return m.OldName(ctx)
  19595. case sopstage.FieldConditionType:
  19596. return m.OldConditionType(ctx)
  19597. case sopstage.FieldConditionOperator:
  19598. return m.OldConditionOperator(ctx)
  19599. case sopstage.FieldConditionList:
  19600. return m.OldConditionList(ctx)
  19601. case sopstage.FieldActionMessage:
  19602. return m.OldActionMessage(ctx)
  19603. case sopstage.FieldActionLabelAdd:
  19604. return m.OldActionLabelAdd(ctx)
  19605. case sopstage.FieldActionLabelDel:
  19606. return m.OldActionLabelDel(ctx)
  19607. case sopstage.FieldActionForward:
  19608. return m.OldActionForward(ctx)
  19609. case sopstage.FieldIndexSort:
  19610. return m.OldIndexSort(ctx)
  19611. }
  19612. return nil, fmt.Errorf("unknown SopStage field %s", name)
  19613. }
  19614. // SetField sets the value of a field with the given name. It returns an error if
  19615. // the field is not defined in the schema, or if the type mismatched the field
  19616. // type.
  19617. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  19618. switch name {
  19619. case sopstage.FieldCreatedAt:
  19620. v, ok := value.(time.Time)
  19621. if !ok {
  19622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19623. }
  19624. m.SetCreatedAt(v)
  19625. return nil
  19626. case sopstage.FieldUpdatedAt:
  19627. v, ok := value.(time.Time)
  19628. if !ok {
  19629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19630. }
  19631. m.SetUpdatedAt(v)
  19632. return nil
  19633. case sopstage.FieldStatus:
  19634. v, ok := value.(uint8)
  19635. if !ok {
  19636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19637. }
  19638. m.SetStatus(v)
  19639. return nil
  19640. case sopstage.FieldDeletedAt:
  19641. v, ok := value.(time.Time)
  19642. if !ok {
  19643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19644. }
  19645. m.SetDeletedAt(v)
  19646. return nil
  19647. case sopstage.FieldTaskID:
  19648. v, ok := value.(uint64)
  19649. if !ok {
  19650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19651. }
  19652. m.SetTaskID(v)
  19653. return nil
  19654. case sopstage.FieldName:
  19655. v, ok := value.(string)
  19656. if !ok {
  19657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19658. }
  19659. m.SetName(v)
  19660. return nil
  19661. case sopstage.FieldConditionType:
  19662. v, ok := value.(int)
  19663. if !ok {
  19664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19665. }
  19666. m.SetConditionType(v)
  19667. return nil
  19668. case sopstage.FieldConditionOperator:
  19669. v, ok := value.(int)
  19670. if !ok {
  19671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19672. }
  19673. m.SetConditionOperator(v)
  19674. return nil
  19675. case sopstage.FieldConditionList:
  19676. v, ok := value.([]custom_types.Condition)
  19677. if !ok {
  19678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19679. }
  19680. m.SetConditionList(v)
  19681. return nil
  19682. case sopstage.FieldActionMessage:
  19683. v, ok := value.([]custom_types.Action)
  19684. if !ok {
  19685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19686. }
  19687. m.SetActionMessage(v)
  19688. return nil
  19689. case sopstage.FieldActionLabelAdd:
  19690. v, ok := value.([]uint64)
  19691. if !ok {
  19692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19693. }
  19694. m.SetActionLabelAdd(v)
  19695. return nil
  19696. case sopstage.FieldActionLabelDel:
  19697. v, ok := value.([]uint64)
  19698. if !ok {
  19699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19700. }
  19701. m.SetActionLabelDel(v)
  19702. return nil
  19703. case sopstage.FieldActionForward:
  19704. v, ok := value.(*custom_types.ActionForward)
  19705. if !ok {
  19706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19707. }
  19708. m.SetActionForward(v)
  19709. return nil
  19710. case sopstage.FieldIndexSort:
  19711. v, ok := value.(int)
  19712. if !ok {
  19713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19714. }
  19715. m.SetIndexSort(v)
  19716. return nil
  19717. }
  19718. return fmt.Errorf("unknown SopStage field %s", name)
  19719. }
  19720. // AddedFields returns all numeric fields that were incremented/decremented during
  19721. // this mutation.
  19722. func (m *SopStageMutation) AddedFields() []string {
  19723. var fields []string
  19724. if m.addstatus != nil {
  19725. fields = append(fields, sopstage.FieldStatus)
  19726. }
  19727. if m.addcondition_type != nil {
  19728. fields = append(fields, sopstage.FieldConditionType)
  19729. }
  19730. if m.addcondition_operator != nil {
  19731. fields = append(fields, sopstage.FieldConditionOperator)
  19732. }
  19733. if m.addindex_sort != nil {
  19734. fields = append(fields, sopstage.FieldIndexSort)
  19735. }
  19736. return fields
  19737. }
  19738. // AddedField returns the numeric value that was incremented/decremented on a field
  19739. // with the given name. The second boolean return value indicates that this field
  19740. // was not set, or was not defined in the schema.
  19741. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  19742. switch name {
  19743. case sopstage.FieldStatus:
  19744. return m.AddedStatus()
  19745. case sopstage.FieldConditionType:
  19746. return m.AddedConditionType()
  19747. case sopstage.FieldConditionOperator:
  19748. return m.AddedConditionOperator()
  19749. case sopstage.FieldIndexSort:
  19750. return m.AddedIndexSort()
  19751. }
  19752. return nil, false
  19753. }
  19754. // AddField adds the value to the field with the given name. It returns an error if
  19755. // the field is not defined in the schema, or if the type mismatched the field
  19756. // type.
  19757. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  19758. switch name {
  19759. case sopstage.FieldStatus:
  19760. v, ok := value.(int8)
  19761. if !ok {
  19762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19763. }
  19764. m.AddStatus(v)
  19765. return nil
  19766. case sopstage.FieldConditionType:
  19767. v, ok := value.(int)
  19768. if !ok {
  19769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19770. }
  19771. m.AddConditionType(v)
  19772. return nil
  19773. case sopstage.FieldConditionOperator:
  19774. v, ok := value.(int)
  19775. if !ok {
  19776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19777. }
  19778. m.AddConditionOperator(v)
  19779. return nil
  19780. case sopstage.FieldIndexSort:
  19781. v, ok := value.(int)
  19782. if !ok {
  19783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19784. }
  19785. m.AddIndexSort(v)
  19786. return nil
  19787. }
  19788. return fmt.Errorf("unknown SopStage numeric field %s", name)
  19789. }
  19790. // ClearedFields returns all nullable fields that were cleared during this
  19791. // mutation.
  19792. func (m *SopStageMutation) ClearedFields() []string {
  19793. var fields []string
  19794. if m.FieldCleared(sopstage.FieldStatus) {
  19795. fields = append(fields, sopstage.FieldStatus)
  19796. }
  19797. if m.FieldCleared(sopstage.FieldDeletedAt) {
  19798. fields = append(fields, sopstage.FieldDeletedAt)
  19799. }
  19800. if m.FieldCleared(sopstage.FieldActionMessage) {
  19801. fields = append(fields, sopstage.FieldActionMessage)
  19802. }
  19803. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  19804. fields = append(fields, sopstage.FieldActionLabelAdd)
  19805. }
  19806. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  19807. fields = append(fields, sopstage.FieldActionLabelDel)
  19808. }
  19809. if m.FieldCleared(sopstage.FieldActionForward) {
  19810. fields = append(fields, sopstage.FieldActionForward)
  19811. }
  19812. if m.FieldCleared(sopstage.FieldIndexSort) {
  19813. fields = append(fields, sopstage.FieldIndexSort)
  19814. }
  19815. return fields
  19816. }
  19817. // FieldCleared returns a boolean indicating if a field with the given name was
  19818. // cleared in this mutation.
  19819. func (m *SopStageMutation) FieldCleared(name string) bool {
  19820. _, ok := m.clearedFields[name]
  19821. return ok
  19822. }
  19823. // ClearField clears the value of the field with the given name. It returns an
  19824. // error if the field is not defined in the schema.
  19825. func (m *SopStageMutation) ClearField(name string) error {
  19826. switch name {
  19827. case sopstage.FieldStatus:
  19828. m.ClearStatus()
  19829. return nil
  19830. case sopstage.FieldDeletedAt:
  19831. m.ClearDeletedAt()
  19832. return nil
  19833. case sopstage.FieldActionMessage:
  19834. m.ClearActionMessage()
  19835. return nil
  19836. case sopstage.FieldActionLabelAdd:
  19837. m.ClearActionLabelAdd()
  19838. return nil
  19839. case sopstage.FieldActionLabelDel:
  19840. m.ClearActionLabelDel()
  19841. return nil
  19842. case sopstage.FieldActionForward:
  19843. m.ClearActionForward()
  19844. return nil
  19845. case sopstage.FieldIndexSort:
  19846. m.ClearIndexSort()
  19847. return nil
  19848. }
  19849. return fmt.Errorf("unknown SopStage nullable field %s", name)
  19850. }
  19851. // ResetField resets all changes in the mutation for the field with the given name.
  19852. // It returns an error if the field is not defined in the schema.
  19853. func (m *SopStageMutation) ResetField(name string) error {
  19854. switch name {
  19855. case sopstage.FieldCreatedAt:
  19856. m.ResetCreatedAt()
  19857. return nil
  19858. case sopstage.FieldUpdatedAt:
  19859. m.ResetUpdatedAt()
  19860. return nil
  19861. case sopstage.FieldStatus:
  19862. m.ResetStatus()
  19863. return nil
  19864. case sopstage.FieldDeletedAt:
  19865. m.ResetDeletedAt()
  19866. return nil
  19867. case sopstage.FieldTaskID:
  19868. m.ResetTaskID()
  19869. return nil
  19870. case sopstage.FieldName:
  19871. m.ResetName()
  19872. return nil
  19873. case sopstage.FieldConditionType:
  19874. m.ResetConditionType()
  19875. return nil
  19876. case sopstage.FieldConditionOperator:
  19877. m.ResetConditionOperator()
  19878. return nil
  19879. case sopstage.FieldConditionList:
  19880. m.ResetConditionList()
  19881. return nil
  19882. case sopstage.FieldActionMessage:
  19883. m.ResetActionMessage()
  19884. return nil
  19885. case sopstage.FieldActionLabelAdd:
  19886. m.ResetActionLabelAdd()
  19887. return nil
  19888. case sopstage.FieldActionLabelDel:
  19889. m.ResetActionLabelDel()
  19890. return nil
  19891. case sopstage.FieldActionForward:
  19892. m.ResetActionForward()
  19893. return nil
  19894. case sopstage.FieldIndexSort:
  19895. m.ResetIndexSort()
  19896. return nil
  19897. }
  19898. return fmt.Errorf("unknown SopStage field %s", name)
  19899. }
  19900. // AddedEdges returns all edge names that were set/added in this mutation.
  19901. func (m *SopStageMutation) AddedEdges() []string {
  19902. edges := make([]string, 0, 3)
  19903. if m.sop_task != nil {
  19904. edges = append(edges, sopstage.EdgeSopTask)
  19905. }
  19906. if m.stage_nodes != nil {
  19907. edges = append(edges, sopstage.EdgeStageNodes)
  19908. }
  19909. if m.stage_messages != nil {
  19910. edges = append(edges, sopstage.EdgeStageMessages)
  19911. }
  19912. return edges
  19913. }
  19914. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19915. // name in this mutation.
  19916. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  19917. switch name {
  19918. case sopstage.EdgeSopTask:
  19919. if id := m.sop_task; id != nil {
  19920. return []ent.Value{*id}
  19921. }
  19922. case sopstage.EdgeStageNodes:
  19923. ids := make([]ent.Value, 0, len(m.stage_nodes))
  19924. for id := range m.stage_nodes {
  19925. ids = append(ids, id)
  19926. }
  19927. return ids
  19928. case sopstage.EdgeStageMessages:
  19929. ids := make([]ent.Value, 0, len(m.stage_messages))
  19930. for id := range m.stage_messages {
  19931. ids = append(ids, id)
  19932. }
  19933. return ids
  19934. }
  19935. return nil
  19936. }
  19937. // RemovedEdges returns all edge names that were removed in this mutation.
  19938. func (m *SopStageMutation) RemovedEdges() []string {
  19939. edges := make([]string, 0, 3)
  19940. if m.removedstage_nodes != nil {
  19941. edges = append(edges, sopstage.EdgeStageNodes)
  19942. }
  19943. if m.removedstage_messages != nil {
  19944. edges = append(edges, sopstage.EdgeStageMessages)
  19945. }
  19946. return edges
  19947. }
  19948. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19949. // the given name in this mutation.
  19950. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  19951. switch name {
  19952. case sopstage.EdgeStageNodes:
  19953. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  19954. for id := range m.removedstage_nodes {
  19955. ids = append(ids, id)
  19956. }
  19957. return ids
  19958. case sopstage.EdgeStageMessages:
  19959. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  19960. for id := range m.removedstage_messages {
  19961. ids = append(ids, id)
  19962. }
  19963. return ids
  19964. }
  19965. return nil
  19966. }
  19967. // ClearedEdges returns all edge names that were cleared in this mutation.
  19968. func (m *SopStageMutation) ClearedEdges() []string {
  19969. edges := make([]string, 0, 3)
  19970. if m.clearedsop_task {
  19971. edges = append(edges, sopstage.EdgeSopTask)
  19972. }
  19973. if m.clearedstage_nodes {
  19974. edges = append(edges, sopstage.EdgeStageNodes)
  19975. }
  19976. if m.clearedstage_messages {
  19977. edges = append(edges, sopstage.EdgeStageMessages)
  19978. }
  19979. return edges
  19980. }
  19981. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19982. // was cleared in this mutation.
  19983. func (m *SopStageMutation) EdgeCleared(name string) bool {
  19984. switch name {
  19985. case sopstage.EdgeSopTask:
  19986. return m.clearedsop_task
  19987. case sopstage.EdgeStageNodes:
  19988. return m.clearedstage_nodes
  19989. case sopstage.EdgeStageMessages:
  19990. return m.clearedstage_messages
  19991. }
  19992. return false
  19993. }
  19994. // ClearEdge clears the value of the edge with the given name. It returns an error
  19995. // if that edge is not defined in the schema.
  19996. func (m *SopStageMutation) ClearEdge(name string) error {
  19997. switch name {
  19998. case sopstage.EdgeSopTask:
  19999. m.ClearSopTask()
  20000. return nil
  20001. }
  20002. return fmt.Errorf("unknown SopStage unique edge %s", name)
  20003. }
  20004. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20005. // It returns an error if the edge is not defined in the schema.
  20006. func (m *SopStageMutation) ResetEdge(name string) error {
  20007. switch name {
  20008. case sopstage.EdgeSopTask:
  20009. m.ResetSopTask()
  20010. return nil
  20011. case sopstage.EdgeStageNodes:
  20012. m.ResetStageNodes()
  20013. return nil
  20014. case sopstage.EdgeStageMessages:
  20015. m.ResetStageMessages()
  20016. return nil
  20017. }
  20018. return fmt.Errorf("unknown SopStage edge %s", name)
  20019. }
  20020. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  20021. type SopTaskMutation struct {
  20022. config
  20023. op Op
  20024. typ string
  20025. id *uint64
  20026. created_at *time.Time
  20027. updated_at *time.Time
  20028. status *uint8
  20029. addstatus *int8
  20030. deleted_at *time.Time
  20031. name *string
  20032. bot_wxid_list *[]string
  20033. appendbot_wxid_list []string
  20034. _type *int
  20035. add_type *int
  20036. plan_start_time *time.Time
  20037. plan_end_time *time.Time
  20038. creator_id *string
  20039. organization_id *uint64
  20040. addorganization_id *int64
  20041. token *[]string
  20042. appendtoken []string
  20043. clearedFields map[string]struct{}
  20044. task_stages map[uint64]struct{}
  20045. removedtask_stages map[uint64]struct{}
  20046. clearedtask_stages bool
  20047. done bool
  20048. oldValue func(context.Context) (*SopTask, error)
  20049. predicates []predicate.SopTask
  20050. }
  20051. var _ ent.Mutation = (*SopTaskMutation)(nil)
  20052. // soptaskOption allows management of the mutation configuration using functional options.
  20053. type soptaskOption func(*SopTaskMutation)
  20054. // newSopTaskMutation creates new mutation for the SopTask entity.
  20055. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  20056. m := &SopTaskMutation{
  20057. config: c,
  20058. op: op,
  20059. typ: TypeSopTask,
  20060. clearedFields: make(map[string]struct{}),
  20061. }
  20062. for _, opt := range opts {
  20063. opt(m)
  20064. }
  20065. return m
  20066. }
  20067. // withSopTaskID sets the ID field of the mutation.
  20068. func withSopTaskID(id uint64) soptaskOption {
  20069. return func(m *SopTaskMutation) {
  20070. var (
  20071. err error
  20072. once sync.Once
  20073. value *SopTask
  20074. )
  20075. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  20076. once.Do(func() {
  20077. if m.done {
  20078. err = errors.New("querying old values post mutation is not allowed")
  20079. } else {
  20080. value, err = m.Client().SopTask.Get(ctx, id)
  20081. }
  20082. })
  20083. return value, err
  20084. }
  20085. m.id = &id
  20086. }
  20087. }
  20088. // withSopTask sets the old SopTask of the mutation.
  20089. func withSopTask(node *SopTask) soptaskOption {
  20090. return func(m *SopTaskMutation) {
  20091. m.oldValue = func(context.Context) (*SopTask, error) {
  20092. return node, nil
  20093. }
  20094. m.id = &node.ID
  20095. }
  20096. }
  20097. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20098. // executed in a transaction (ent.Tx), a transactional client is returned.
  20099. func (m SopTaskMutation) Client() *Client {
  20100. client := &Client{config: m.config}
  20101. client.init()
  20102. return client
  20103. }
  20104. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20105. // it returns an error otherwise.
  20106. func (m SopTaskMutation) Tx() (*Tx, error) {
  20107. if _, ok := m.driver.(*txDriver); !ok {
  20108. return nil, errors.New("ent: mutation is not running in a transaction")
  20109. }
  20110. tx := &Tx{config: m.config}
  20111. tx.init()
  20112. return tx, nil
  20113. }
  20114. // SetID sets the value of the id field. Note that this
  20115. // operation is only accepted on creation of SopTask entities.
  20116. func (m *SopTaskMutation) SetID(id uint64) {
  20117. m.id = &id
  20118. }
  20119. // ID returns the ID value in the mutation. Note that the ID is only available
  20120. // if it was provided to the builder or after it was returned from the database.
  20121. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  20122. if m.id == nil {
  20123. return
  20124. }
  20125. return *m.id, true
  20126. }
  20127. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20128. // That means, if the mutation is applied within a transaction with an isolation level such
  20129. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20130. // or updated by the mutation.
  20131. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  20132. switch {
  20133. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20134. id, exists := m.ID()
  20135. if exists {
  20136. return []uint64{id}, nil
  20137. }
  20138. fallthrough
  20139. case m.op.Is(OpUpdate | OpDelete):
  20140. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  20141. default:
  20142. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20143. }
  20144. }
  20145. // SetCreatedAt sets the "created_at" field.
  20146. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  20147. m.created_at = &t
  20148. }
  20149. // CreatedAt returns the value of the "created_at" field in the mutation.
  20150. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  20151. v := m.created_at
  20152. if v == nil {
  20153. return
  20154. }
  20155. return *v, true
  20156. }
  20157. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  20158. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20160. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20161. if !m.op.Is(OpUpdateOne) {
  20162. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20163. }
  20164. if m.id == nil || m.oldValue == nil {
  20165. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20166. }
  20167. oldValue, err := m.oldValue(ctx)
  20168. if err != nil {
  20169. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20170. }
  20171. return oldValue.CreatedAt, nil
  20172. }
  20173. // ResetCreatedAt resets all changes to the "created_at" field.
  20174. func (m *SopTaskMutation) ResetCreatedAt() {
  20175. m.created_at = nil
  20176. }
  20177. // SetUpdatedAt sets the "updated_at" field.
  20178. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  20179. m.updated_at = &t
  20180. }
  20181. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20182. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  20183. v := m.updated_at
  20184. if v == nil {
  20185. return
  20186. }
  20187. return *v, true
  20188. }
  20189. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  20190. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20192. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20193. if !m.op.Is(OpUpdateOne) {
  20194. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20195. }
  20196. if m.id == nil || m.oldValue == nil {
  20197. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20198. }
  20199. oldValue, err := m.oldValue(ctx)
  20200. if err != nil {
  20201. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20202. }
  20203. return oldValue.UpdatedAt, nil
  20204. }
  20205. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20206. func (m *SopTaskMutation) ResetUpdatedAt() {
  20207. m.updated_at = nil
  20208. }
  20209. // SetStatus sets the "status" field.
  20210. func (m *SopTaskMutation) SetStatus(u uint8) {
  20211. m.status = &u
  20212. m.addstatus = nil
  20213. }
  20214. // Status returns the value of the "status" field in the mutation.
  20215. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  20216. v := m.status
  20217. if v == nil {
  20218. return
  20219. }
  20220. return *v, true
  20221. }
  20222. // OldStatus returns the old "status" field's value of the SopTask entity.
  20223. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20225. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20226. if !m.op.Is(OpUpdateOne) {
  20227. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20228. }
  20229. if m.id == nil || m.oldValue == nil {
  20230. return v, errors.New("OldStatus requires an ID field in the mutation")
  20231. }
  20232. oldValue, err := m.oldValue(ctx)
  20233. if err != nil {
  20234. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20235. }
  20236. return oldValue.Status, nil
  20237. }
  20238. // AddStatus adds u to the "status" field.
  20239. func (m *SopTaskMutation) AddStatus(u int8) {
  20240. if m.addstatus != nil {
  20241. *m.addstatus += u
  20242. } else {
  20243. m.addstatus = &u
  20244. }
  20245. }
  20246. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20247. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  20248. v := m.addstatus
  20249. if v == nil {
  20250. return
  20251. }
  20252. return *v, true
  20253. }
  20254. // ClearStatus clears the value of the "status" field.
  20255. func (m *SopTaskMutation) ClearStatus() {
  20256. m.status = nil
  20257. m.addstatus = nil
  20258. m.clearedFields[soptask.FieldStatus] = struct{}{}
  20259. }
  20260. // StatusCleared returns if the "status" field was cleared in this mutation.
  20261. func (m *SopTaskMutation) StatusCleared() bool {
  20262. _, ok := m.clearedFields[soptask.FieldStatus]
  20263. return ok
  20264. }
  20265. // ResetStatus resets all changes to the "status" field.
  20266. func (m *SopTaskMutation) ResetStatus() {
  20267. m.status = nil
  20268. m.addstatus = nil
  20269. delete(m.clearedFields, soptask.FieldStatus)
  20270. }
  20271. // SetDeletedAt sets the "deleted_at" field.
  20272. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  20273. m.deleted_at = &t
  20274. }
  20275. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20276. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  20277. v := m.deleted_at
  20278. if v == nil {
  20279. return
  20280. }
  20281. return *v, true
  20282. }
  20283. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  20284. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20286. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20287. if !m.op.Is(OpUpdateOne) {
  20288. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20289. }
  20290. if m.id == nil || m.oldValue == nil {
  20291. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20292. }
  20293. oldValue, err := m.oldValue(ctx)
  20294. if err != nil {
  20295. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20296. }
  20297. return oldValue.DeletedAt, nil
  20298. }
  20299. // ClearDeletedAt clears the value of the "deleted_at" field.
  20300. func (m *SopTaskMutation) ClearDeletedAt() {
  20301. m.deleted_at = nil
  20302. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  20303. }
  20304. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20305. func (m *SopTaskMutation) DeletedAtCleared() bool {
  20306. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  20307. return ok
  20308. }
  20309. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20310. func (m *SopTaskMutation) ResetDeletedAt() {
  20311. m.deleted_at = nil
  20312. delete(m.clearedFields, soptask.FieldDeletedAt)
  20313. }
  20314. // SetName sets the "name" field.
  20315. func (m *SopTaskMutation) SetName(s string) {
  20316. m.name = &s
  20317. }
  20318. // Name returns the value of the "name" field in the mutation.
  20319. func (m *SopTaskMutation) Name() (r string, exists bool) {
  20320. v := m.name
  20321. if v == nil {
  20322. return
  20323. }
  20324. return *v, true
  20325. }
  20326. // OldName returns the old "name" field's value of the SopTask entity.
  20327. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20329. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  20330. if !m.op.Is(OpUpdateOne) {
  20331. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20332. }
  20333. if m.id == nil || m.oldValue == nil {
  20334. return v, errors.New("OldName requires an ID field in the mutation")
  20335. }
  20336. oldValue, err := m.oldValue(ctx)
  20337. if err != nil {
  20338. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20339. }
  20340. return oldValue.Name, nil
  20341. }
  20342. // ResetName resets all changes to the "name" field.
  20343. func (m *SopTaskMutation) ResetName() {
  20344. m.name = nil
  20345. }
  20346. // SetBotWxidList sets the "bot_wxid_list" field.
  20347. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  20348. m.bot_wxid_list = &s
  20349. m.appendbot_wxid_list = nil
  20350. }
  20351. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  20352. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  20353. v := m.bot_wxid_list
  20354. if v == nil {
  20355. return
  20356. }
  20357. return *v, true
  20358. }
  20359. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  20360. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20362. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  20363. if !m.op.Is(OpUpdateOne) {
  20364. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  20365. }
  20366. if m.id == nil || m.oldValue == nil {
  20367. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  20368. }
  20369. oldValue, err := m.oldValue(ctx)
  20370. if err != nil {
  20371. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  20372. }
  20373. return oldValue.BotWxidList, nil
  20374. }
  20375. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  20376. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  20377. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  20378. }
  20379. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  20380. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  20381. if len(m.appendbot_wxid_list) == 0 {
  20382. return nil, false
  20383. }
  20384. return m.appendbot_wxid_list, true
  20385. }
  20386. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  20387. func (m *SopTaskMutation) ClearBotWxidList() {
  20388. m.bot_wxid_list = nil
  20389. m.appendbot_wxid_list = nil
  20390. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  20391. }
  20392. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  20393. func (m *SopTaskMutation) BotWxidListCleared() bool {
  20394. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  20395. return ok
  20396. }
  20397. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  20398. func (m *SopTaskMutation) ResetBotWxidList() {
  20399. m.bot_wxid_list = nil
  20400. m.appendbot_wxid_list = nil
  20401. delete(m.clearedFields, soptask.FieldBotWxidList)
  20402. }
  20403. // SetType sets the "type" field.
  20404. func (m *SopTaskMutation) SetType(i int) {
  20405. m._type = &i
  20406. m.add_type = nil
  20407. }
  20408. // GetType returns the value of the "type" field in the mutation.
  20409. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  20410. v := m._type
  20411. if v == nil {
  20412. return
  20413. }
  20414. return *v, true
  20415. }
  20416. // OldType returns the old "type" field's value of the SopTask entity.
  20417. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20419. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  20420. if !m.op.Is(OpUpdateOne) {
  20421. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20422. }
  20423. if m.id == nil || m.oldValue == nil {
  20424. return v, errors.New("OldType requires an ID field in the mutation")
  20425. }
  20426. oldValue, err := m.oldValue(ctx)
  20427. if err != nil {
  20428. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20429. }
  20430. return oldValue.Type, nil
  20431. }
  20432. // AddType adds i to the "type" field.
  20433. func (m *SopTaskMutation) AddType(i int) {
  20434. if m.add_type != nil {
  20435. *m.add_type += i
  20436. } else {
  20437. m.add_type = &i
  20438. }
  20439. }
  20440. // AddedType returns the value that was added to the "type" field in this mutation.
  20441. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  20442. v := m.add_type
  20443. if v == nil {
  20444. return
  20445. }
  20446. return *v, true
  20447. }
  20448. // ResetType resets all changes to the "type" field.
  20449. func (m *SopTaskMutation) ResetType() {
  20450. m._type = nil
  20451. m.add_type = nil
  20452. }
  20453. // SetPlanStartTime sets the "plan_start_time" field.
  20454. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  20455. m.plan_start_time = &t
  20456. }
  20457. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  20458. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  20459. v := m.plan_start_time
  20460. if v == nil {
  20461. return
  20462. }
  20463. return *v, true
  20464. }
  20465. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  20466. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20468. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  20469. if !m.op.Is(OpUpdateOne) {
  20470. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  20471. }
  20472. if m.id == nil || m.oldValue == nil {
  20473. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  20474. }
  20475. oldValue, err := m.oldValue(ctx)
  20476. if err != nil {
  20477. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  20478. }
  20479. return oldValue.PlanStartTime, nil
  20480. }
  20481. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  20482. func (m *SopTaskMutation) ClearPlanStartTime() {
  20483. m.plan_start_time = nil
  20484. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  20485. }
  20486. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  20487. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  20488. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  20489. return ok
  20490. }
  20491. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  20492. func (m *SopTaskMutation) ResetPlanStartTime() {
  20493. m.plan_start_time = nil
  20494. delete(m.clearedFields, soptask.FieldPlanStartTime)
  20495. }
  20496. // SetPlanEndTime sets the "plan_end_time" field.
  20497. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  20498. m.plan_end_time = &t
  20499. }
  20500. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  20501. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  20502. v := m.plan_end_time
  20503. if v == nil {
  20504. return
  20505. }
  20506. return *v, true
  20507. }
  20508. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  20509. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20511. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  20512. if !m.op.Is(OpUpdateOne) {
  20513. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  20514. }
  20515. if m.id == nil || m.oldValue == nil {
  20516. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  20517. }
  20518. oldValue, err := m.oldValue(ctx)
  20519. if err != nil {
  20520. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  20521. }
  20522. return oldValue.PlanEndTime, nil
  20523. }
  20524. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  20525. func (m *SopTaskMutation) ClearPlanEndTime() {
  20526. m.plan_end_time = nil
  20527. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  20528. }
  20529. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  20530. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  20531. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  20532. return ok
  20533. }
  20534. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  20535. func (m *SopTaskMutation) ResetPlanEndTime() {
  20536. m.plan_end_time = nil
  20537. delete(m.clearedFields, soptask.FieldPlanEndTime)
  20538. }
  20539. // SetCreatorID sets the "creator_id" field.
  20540. func (m *SopTaskMutation) SetCreatorID(s string) {
  20541. m.creator_id = &s
  20542. }
  20543. // CreatorID returns the value of the "creator_id" field in the mutation.
  20544. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  20545. v := m.creator_id
  20546. if v == nil {
  20547. return
  20548. }
  20549. return *v, true
  20550. }
  20551. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  20552. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20554. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  20555. if !m.op.Is(OpUpdateOne) {
  20556. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  20557. }
  20558. if m.id == nil || m.oldValue == nil {
  20559. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  20560. }
  20561. oldValue, err := m.oldValue(ctx)
  20562. if err != nil {
  20563. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  20564. }
  20565. return oldValue.CreatorID, nil
  20566. }
  20567. // ClearCreatorID clears the value of the "creator_id" field.
  20568. func (m *SopTaskMutation) ClearCreatorID() {
  20569. m.creator_id = nil
  20570. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  20571. }
  20572. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  20573. func (m *SopTaskMutation) CreatorIDCleared() bool {
  20574. _, ok := m.clearedFields[soptask.FieldCreatorID]
  20575. return ok
  20576. }
  20577. // ResetCreatorID resets all changes to the "creator_id" field.
  20578. func (m *SopTaskMutation) ResetCreatorID() {
  20579. m.creator_id = nil
  20580. delete(m.clearedFields, soptask.FieldCreatorID)
  20581. }
  20582. // SetOrganizationID sets the "organization_id" field.
  20583. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  20584. m.organization_id = &u
  20585. m.addorganization_id = nil
  20586. }
  20587. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20588. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  20589. v := m.organization_id
  20590. if v == nil {
  20591. return
  20592. }
  20593. return *v, true
  20594. }
  20595. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  20596. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20598. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20599. if !m.op.Is(OpUpdateOne) {
  20600. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20601. }
  20602. if m.id == nil || m.oldValue == nil {
  20603. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20604. }
  20605. oldValue, err := m.oldValue(ctx)
  20606. if err != nil {
  20607. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20608. }
  20609. return oldValue.OrganizationID, nil
  20610. }
  20611. // AddOrganizationID adds u to the "organization_id" field.
  20612. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  20613. if m.addorganization_id != nil {
  20614. *m.addorganization_id += u
  20615. } else {
  20616. m.addorganization_id = &u
  20617. }
  20618. }
  20619. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20620. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  20621. v := m.addorganization_id
  20622. if v == nil {
  20623. return
  20624. }
  20625. return *v, true
  20626. }
  20627. // ClearOrganizationID clears the value of the "organization_id" field.
  20628. func (m *SopTaskMutation) ClearOrganizationID() {
  20629. m.organization_id = nil
  20630. m.addorganization_id = nil
  20631. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  20632. }
  20633. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20634. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  20635. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  20636. return ok
  20637. }
  20638. // ResetOrganizationID resets all changes to the "organization_id" field.
  20639. func (m *SopTaskMutation) ResetOrganizationID() {
  20640. m.organization_id = nil
  20641. m.addorganization_id = nil
  20642. delete(m.clearedFields, soptask.FieldOrganizationID)
  20643. }
  20644. // SetToken sets the "token" field.
  20645. func (m *SopTaskMutation) SetToken(s []string) {
  20646. m.token = &s
  20647. m.appendtoken = nil
  20648. }
  20649. // Token returns the value of the "token" field in the mutation.
  20650. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  20651. v := m.token
  20652. if v == nil {
  20653. return
  20654. }
  20655. return *v, true
  20656. }
  20657. // OldToken returns the old "token" field's value of the SopTask entity.
  20658. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20660. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  20661. if !m.op.Is(OpUpdateOne) {
  20662. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20663. }
  20664. if m.id == nil || m.oldValue == nil {
  20665. return v, errors.New("OldToken requires an ID field in the mutation")
  20666. }
  20667. oldValue, err := m.oldValue(ctx)
  20668. if err != nil {
  20669. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20670. }
  20671. return oldValue.Token, nil
  20672. }
  20673. // AppendToken adds s to the "token" field.
  20674. func (m *SopTaskMutation) AppendToken(s []string) {
  20675. m.appendtoken = append(m.appendtoken, s...)
  20676. }
  20677. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  20678. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  20679. if len(m.appendtoken) == 0 {
  20680. return nil, false
  20681. }
  20682. return m.appendtoken, true
  20683. }
  20684. // ClearToken clears the value of the "token" field.
  20685. func (m *SopTaskMutation) ClearToken() {
  20686. m.token = nil
  20687. m.appendtoken = nil
  20688. m.clearedFields[soptask.FieldToken] = struct{}{}
  20689. }
  20690. // TokenCleared returns if the "token" field was cleared in this mutation.
  20691. func (m *SopTaskMutation) TokenCleared() bool {
  20692. _, ok := m.clearedFields[soptask.FieldToken]
  20693. return ok
  20694. }
  20695. // ResetToken resets all changes to the "token" field.
  20696. func (m *SopTaskMutation) ResetToken() {
  20697. m.token = nil
  20698. m.appendtoken = nil
  20699. delete(m.clearedFields, soptask.FieldToken)
  20700. }
  20701. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  20702. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  20703. if m.task_stages == nil {
  20704. m.task_stages = make(map[uint64]struct{})
  20705. }
  20706. for i := range ids {
  20707. m.task_stages[ids[i]] = struct{}{}
  20708. }
  20709. }
  20710. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  20711. func (m *SopTaskMutation) ClearTaskStages() {
  20712. m.clearedtask_stages = true
  20713. }
  20714. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  20715. func (m *SopTaskMutation) TaskStagesCleared() bool {
  20716. return m.clearedtask_stages
  20717. }
  20718. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  20719. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  20720. if m.removedtask_stages == nil {
  20721. m.removedtask_stages = make(map[uint64]struct{})
  20722. }
  20723. for i := range ids {
  20724. delete(m.task_stages, ids[i])
  20725. m.removedtask_stages[ids[i]] = struct{}{}
  20726. }
  20727. }
  20728. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  20729. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  20730. for id := range m.removedtask_stages {
  20731. ids = append(ids, id)
  20732. }
  20733. return
  20734. }
  20735. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  20736. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  20737. for id := range m.task_stages {
  20738. ids = append(ids, id)
  20739. }
  20740. return
  20741. }
  20742. // ResetTaskStages resets all changes to the "task_stages" edge.
  20743. func (m *SopTaskMutation) ResetTaskStages() {
  20744. m.task_stages = nil
  20745. m.clearedtask_stages = false
  20746. m.removedtask_stages = nil
  20747. }
  20748. // Where appends a list predicates to the SopTaskMutation builder.
  20749. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  20750. m.predicates = append(m.predicates, ps...)
  20751. }
  20752. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  20753. // users can use type-assertion to append predicates that do not depend on any generated package.
  20754. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  20755. p := make([]predicate.SopTask, len(ps))
  20756. for i := range ps {
  20757. p[i] = ps[i]
  20758. }
  20759. m.Where(p...)
  20760. }
  20761. // Op returns the operation name.
  20762. func (m *SopTaskMutation) Op() Op {
  20763. return m.op
  20764. }
  20765. // SetOp allows setting the mutation operation.
  20766. func (m *SopTaskMutation) SetOp(op Op) {
  20767. m.op = op
  20768. }
  20769. // Type returns the node type of this mutation (SopTask).
  20770. func (m *SopTaskMutation) Type() string {
  20771. return m.typ
  20772. }
  20773. // Fields returns all fields that were changed during this mutation. Note that in
  20774. // order to get all numeric fields that were incremented/decremented, call
  20775. // AddedFields().
  20776. func (m *SopTaskMutation) Fields() []string {
  20777. fields := make([]string, 0, 12)
  20778. if m.created_at != nil {
  20779. fields = append(fields, soptask.FieldCreatedAt)
  20780. }
  20781. if m.updated_at != nil {
  20782. fields = append(fields, soptask.FieldUpdatedAt)
  20783. }
  20784. if m.status != nil {
  20785. fields = append(fields, soptask.FieldStatus)
  20786. }
  20787. if m.deleted_at != nil {
  20788. fields = append(fields, soptask.FieldDeletedAt)
  20789. }
  20790. if m.name != nil {
  20791. fields = append(fields, soptask.FieldName)
  20792. }
  20793. if m.bot_wxid_list != nil {
  20794. fields = append(fields, soptask.FieldBotWxidList)
  20795. }
  20796. if m._type != nil {
  20797. fields = append(fields, soptask.FieldType)
  20798. }
  20799. if m.plan_start_time != nil {
  20800. fields = append(fields, soptask.FieldPlanStartTime)
  20801. }
  20802. if m.plan_end_time != nil {
  20803. fields = append(fields, soptask.FieldPlanEndTime)
  20804. }
  20805. if m.creator_id != nil {
  20806. fields = append(fields, soptask.FieldCreatorID)
  20807. }
  20808. if m.organization_id != nil {
  20809. fields = append(fields, soptask.FieldOrganizationID)
  20810. }
  20811. if m.token != nil {
  20812. fields = append(fields, soptask.FieldToken)
  20813. }
  20814. return fields
  20815. }
  20816. // Field returns the value of a field with the given name. The second boolean
  20817. // return value indicates that this field was not set, or was not defined in the
  20818. // schema.
  20819. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  20820. switch name {
  20821. case soptask.FieldCreatedAt:
  20822. return m.CreatedAt()
  20823. case soptask.FieldUpdatedAt:
  20824. return m.UpdatedAt()
  20825. case soptask.FieldStatus:
  20826. return m.Status()
  20827. case soptask.FieldDeletedAt:
  20828. return m.DeletedAt()
  20829. case soptask.FieldName:
  20830. return m.Name()
  20831. case soptask.FieldBotWxidList:
  20832. return m.BotWxidList()
  20833. case soptask.FieldType:
  20834. return m.GetType()
  20835. case soptask.FieldPlanStartTime:
  20836. return m.PlanStartTime()
  20837. case soptask.FieldPlanEndTime:
  20838. return m.PlanEndTime()
  20839. case soptask.FieldCreatorID:
  20840. return m.CreatorID()
  20841. case soptask.FieldOrganizationID:
  20842. return m.OrganizationID()
  20843. case soptask.FieldToken:
  20844. return m.Token()
  20845. }
  20846. return nil, false
  20847. }
  20848. // OldField returns the old value of the field from the database. An error is
  20849. // returned if the mutation operation is not UpdateOne, or the query to the
  20850. // database failed.
  20851. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20852. switch name {
  20853. case soptask.FieldCreatedAt:
  20854. return m.OldCreatedAt(ctx)
  20855. case soptask.FieldUpdatedAt:
  20856. return m.OldUpdatedAt(ctx)
  20857. case soptask.FieldStatus:
  20858. return m.OldStatus(ctx)
  20859. case soptask.FieldDeletedAt:
  20860. return m.OldDeletedAt(ctx)
  20861. case soptask.FieldName:
  20862. return m.OldName(ctx)
  20863. case soptask.FieldBotWxidList:
  20864. return m.OldBotWxidList(ctx)
  20865. case soptask.FieldType:
  20866. return m.OldType(ctx)
  20867. case soptask.FieldPlanStartTime:
  20868. return m.OldPlanStartTime(ctx)
  20869. case soptask.FieldPlanEndTime:
  20870. return m.OldPlanEndTime(ctx)
  20871. case soptask.FieldCreatorID:
  20872. return m.OldCreatorID(ctx)
  20873. case soptask.FieldOrganizationID:
  20874. return m.OldOrganizationID(ctx)
  20875. case soptask.FieldToken:
  20876. return m.OldToken(ctx)
  20877. }
  20878. return nil, fmt.Errorf("unknown SopTask field %s", name)
  20879. }
  20880. // SetField sets the value of a field with the given name. It returns an error if
  20881. // the field is not defined in the schema, or if the type mismatched the field
  20882. // type.
  20883. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  20884. switch name {
  20885. case soptask.FieldCreatedAt:
  20886. v, ok := value.(time.Time)
  20887. if !ok {
  20888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20889. }
  20890. m.SetCreatedAt(v)
  20891. return nil
  20892. case soptask.FieldUpdatedAt:
  20893. v, ok := value.(time.Time)
  20894. if !ok {
  20895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20896. }
  20897. m.SetUpdatedAt(v)
  20898. return nil
  20899. case soptask.FieldStatus:
  20900. v, ok := value.(uint8)
  20901. if !ok {
  20902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20903. }
  20904. m.SetStatus(v)
  20905. return nil
  20906. case soptask.FieldDeletedAt:
  20907. v, ok := value.(time.Time)
  20908. if !ok {
  20909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20910. }
  20911. m.SetDeletedAt(v)
  20912. return nil
  20913. case soptask.FieldName:
  20914. v, ok := value.(string)
  20915. if !ok {
  20916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20917. }
  20918. m.SetName(v)
  20919. return nil
  20920. case soptask.FieldBotWxidList:
  20921. v, ok := value.([]string)
  20922. if !ok {
  20923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20924. }
  20925. m.SetBotWxidList(v)
  20926. return nil
  20927. case soptask.FieldType:
  20928. v, ok := value.(int)
  20929. if !ok {
  20930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20931. }
  20932. m.SetType(v)
  20933. return nil
  20934. case soptask.FieldPlanStartTime:
  20935. v, ok := value.(time.Time)
  20936. if !ok {
  20937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20938. }
  20939. m.SetPlanStartTime(v)
  20940. return nil
  20941. case soptask.FieldPlanEndTime:
  20942. v, ok := value.(time.Time)
  20943. if !ok {
  20944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20945. }
  20946. m.SetPlanEndTime(v)
  20947. return nil
  20948. case soptask.FieldCreatorID:
  20949. v, ok := value.(string)
  20950. if !ok {
  20951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20952. }
  20953. m.SetCreatorID(v)
  20954. return nil
  20955. case soptask.FieldOrganizationID:
  20956. v, ok := value.(uint64)
  20957. if !ok {
  20958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20959. }
  20960. m.SetOrganizationID(v)
  20961. return nil
  20962. case soptask.FieldToken:
  20963. v, ok := value.([]string)
  20964. if !ok {
  20965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20966. }
  20967. m.SetToken(v)
  20968. return nil
  20969. }
  20970. return fmt.Errorf("unknown SopTask field %s", name)
  20971. }
  20972. // AddedFields returns all numeric fields that were incremented/decremented during
  20973. // this mutation.
  20974. func (m *SopTaskMutation) AddedFields() []string {
  20975. var fields []string
  20976. if m.addstatus != nil {
  20977. fields = append(fields, soptask.FieldStatus)
  20978. }
  20979. if m.add_type != nil {
  20980. fields = append(fields, soptask.FieldType)
  20981. }
  20982. if m.addorganization_id != nil {
  20983. fields = append(fields, soptask.FieldOrganizationID)
  20984. }
  20985. return fields
  20986. }
  20987. // AddedField returns the numeric value that was incremented/decremented on a field
  20988. // with the given name. The second boolean return value indicates that this field
  20989. // was not set, or was not defined in the schema.
  20990. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  20991. switch name {
  20992. case soptask.FieldStatus:
  20993. return m.AddedStatus()
  20994. case soptask.FieldType:
  20995. return m.AddedType()
  20996. case soptask.FieldOrganizationID:
  20997. return m.AddedOrganizationID()
  20998. }
  20999. return nil, false
  21000. }
  21001. // AddField adds the value to the field with the given name. It returns an error if
  21002. // the field is not defined in the schema, or if the type mismatched the field
  21003. // type.
  21004. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  21005. switch name {
  21006. case soptask.FieldStatus:
  21007. v, ok := value.(int8)
  21008. if !ok {
  21009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21010. }
  21011. m.AddStatus(v)
  21012. return nil
  21013. case soptask.FieldType:
  21014. v, ok := value.(int)
  21015. if !ok {
  21016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21017. }
  21018. m.AddType(v)
  21019. return nil
  21020. case soptask.FieldOrganizationID:
  21021. v, ok := value.(int64)
  21022. if !ok {
  21023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21024. }
  21025. m.AddOrganizationID(v)
  21026. return nil
  21027. }
  21028. return fmt.Errorf("unknown SopTask numeric field %s", name)
  21029. }
  21030. // ClearedFields returns all nullable fields that were cleared during this
  21031. // mutation.
  21032. func (m *SopTaskMutation) ClearedFields() []string {
  21033. var fields []string
  21034. if m.FieldCleared(soptask.FieldStatus) {
  21035. fields = append(fields, soptask.FieldStatus)
  21036. }
  21037. if m.FieldCleared(soptask.FieldDeletedAt) {
  21038. fields = append(fields, soptask.FieldDeletedAt)
  21039. }
  21040. if m.FieldCleared(soptask.FieldBotWxidList) {
  21041. fields = append(fields, soptask.FieldBotWxidList)
  21042. }
  21043. if m.FieldCleared(soptask.FieldPlanStartTime) {
  21044. fields = append(fields, soptask.FieldPlanStartTime)
  21045. }
  21046. if m.FieldCleared(soptask.FieldPlanEndTime) {
  21047. fields = append(fields, soptask.FieldPlanEndTime)
  21048. }
  21049. if m.FieldCleared(soptask.FieldCreatorID) {
  21050. fields = append(fields, soptask.FieldCreatorID)
  21051. }
  21052. if m.FieldCleared(soptask.FieldOrganizationID) {
  21053. fields = append(fields, soptask.FieldOrganizationID)
  21054. }
  21055. if m.FieldCleared(soptask.FieldToken) {
  21056. fields = append(fields, soptask.FieldToken)
  21057. }
  21058. return fields
  21059. }
  21060. // FieldCleared returns a boolean indicating if a field with the given name was
  21061. // cleared in this mutation.
  21062. func (m *SopTaskMutation) FieldCleared(name string) bool {
  21063. _, ok := m.clearedFields[name]
  21064. return ok
  21065. }
  21066. // ClearField clears the value of the field with the given name. It returns an
  21067. // error if the field is not defined in the schema.
  21068. func (m *SopTaskMutation) ClearField(name string) error {
  21069. switch name {
  21070. case soptask.FieldStatus:
  21071. m.ClearStatus()
  21072. return nil
  21073. case soptask.FieldDeletedAt:
  21074. m.ClearDeletedAt()
  21075. return nil
  21076. case soptask.FieldBotWxidList:
  21077. m.ClearBotWxidList()
  21078. return nil
  21079. case soptask.FieldPlanStartTime:
  21080. m.ClearPlanStartTime()
  21081. return nil
  21082. case soptask.FieldPlanEndTime:
  21083. m.ClearPlanEndTime()
  21084. return nil
  21085. case soptask.FieldCreatorID:
  21086. m.ClearCreatorID()
  21087. return nil
  21088. case soptask.FieldOrganizationID:
  21089. m.ClearOrganizationID()
  21090. return nil
  21091. case soptask.FieldToken:
  21092. m.ClearToken()
  21093. return nil
  21094. }
  21095. return fmt.Errorf("unknown SopTask nullable field %s", name)
  21096. }
  21097. // ResetField resets all changes in the mutation for the field with the given name.
  21098. // It returns an error if the field is not defined in the schema.
  21099. func (m *SopTaskMutation) ResetField(name string) error {
  21100. switch name {
  21101. case soptask.FieldCreatedAt:
  21102. m.ResetCreatedAt()
  21103. return nil
  21104. case soptask.FieldUpdatedAt:
  21105. m.ResetUpdatedAt()
  21106. return nil
  21107. case soptask.FieldStatus:
  21108. m.ResetStatus()
  21109. return nil
  21110. case soptask.FieldDeletedAt:
  21111. m.ResetDeletedAt()
  21112. return nil
  21113. case soptask.FieldName:
  21114. m.ResetName()
  21115. return nil
  21116. case soptask.FieldBotWxidList:
  21117. m.ResetBotWxidList()
  21118. return nil
  21119. case soptask.FieldType:
  21120. m.ResetType()
  21121. return nil
  21122. case soptask.FieldPlanStartTime:
  21123. m.ResetPlanStartTime()
  21124. return nil
  21125. case soptask.FieldPlanEndTime:
  21126. m.ResetPlanEndTime()
  21127. return nil
  21128. case soptask.FieldCreatorID:
  21129. m.ResetCreatorID()
  21130. return nil
  21131. case soptask.FieldOrganizationID:
  21132. m.ResetOrganizationID()
  21133. return nil
  21134. case soptask.FieldToken:
  21135. m.ResetToken()
  21136. return nil
  21137. }
  21138. return fmt.Errorf("unknown SopTask field %s", name)
  21139. }
  21140. // AddedEdges returns all edge names that were set/added in this mutation.
  21141. func (m *SopTaskMutation) AddedEdges() []string {
  21142. edges := make([]string, 0, 1)
  21143. if m.task_stages != nil {
  21144. edges = append(edges, soptask.EdgeTaskStages)
  21145. }
  21146. return edges
  21147. }
  21148. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21149. // name in this mutation.
  21150. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  21151. switch name {
  21152. case soptask.EdgeTaskStages:
  21153. ids := make([]ent.Value, 0, len(m.task_stages))
  21154. for id := range m.task_stages {
  21155. ids = append(ids, id)
  21156. }
  21157. return ids
  21158. }
  21159. return nil
  21160. }
  21161. // RemovedEdges returns all edge names that were removed in this mutation.
  21162. func (m *SopTaskMutation) RemovedEdges() []string {
  21163. edges := make([]string, 0, 1)
  21164. if m.removedtask_stages != nil {
  21165. edges = append(edges, soptask.EdgeTaskStages)
  21166. }
  21167. return edges
  21168. }
  21169. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21170. // the given name in this mutation.
  21171. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  21172. switch name {
  21173. case soptask.EdgeTaskStages:
  21174. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  21175. for id := range m.removedtask_stages {
  21176. ids = append(ids, id)
  21177. }
  21178. return ids
  21179. }
  21180. return nil
  21181. }
  21182. // ClearedEdges returns all edge names that were cleared in this mutation.
  21183. func (m *SopTaskMutation) ClearedEdges() []string {
  21184. edges := make([]string, 0, 1)
  21185. if m.clearedtask_stages {
  21186. edges = append(edges, soptask.EdgeTaskStages)
  21187. }
  21188. return edges
  21189. }
  21190. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21191. // was cleared in this mutation.
  21192. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  21193. switch name {
  21194. case soptask.EdgeTaskStages:
  21195. return m.clearedtask_stages
  21196. }
  21197. return false
  21198. }
  21199. // ClearEdge clears the value of the edge with the given name. It returns an error
  21200. // if that edge is not defined in the schema.
  21201. func (m *SopTaskMutation) ClearEdge(name string) error {
  21202. switch name {
  21203. }
  21204. return fmt.Errorf("unknown SopTask unique edge %s", name)
  21205. }
  21206. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21207. // It returns an error if the edge is not defined in the schema.
  21208. func (m *SopTaskMutation) ResetEdge(name string) error {
  21209. switch name {
  21210. case soptask.EdgeTaskStages:
  21211. m.ResetTaskStages()
  21212. return nil
  21213. }
  21214. return fmt.Errorf("unknown SopTask edge %s", name)
  21215. }
  21216. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  21217. type TokenMutation struct {
  21218. config
  21219. op Op
  21220. typ string
  21221. id *uint64
  21222. created_at *time.Time
  21223. updated_at *time.Time
  21224. deleted_at *time.Time
  21225. expire_at *time.Time
  21226. token *string
  21227. mac *string
  21228. organization_id *uint64
  21229. addorganization_id *int64
  21230. custom_agent_base *string
  21231. custom_agent_key *string
  21232. openai_base *string
  21233. openai_key *string
  21234. clearedFields map[string]struct{}
  21235. agent *uint64
  21236. clearedagent bool
  21237. done bool
  21238. oldValue func(context.Context) (*Token, error)
  21239. predicates []predicate.Token
  21240. }
  21241. var _ ent.Mutation = (*TokenMutation)(nil)
  21242. // tokenOption allows management of the mutation configuration using functional options.
  21243. type tokenOption func(*TokenMutation)
  21244. // newTokenMutation creates new mutation for the Token entity.
  21245. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  21246. m := &TokenMutation{
  21247. config: c,
  21248. op: op,
  21249. typ: TypeToken,
  21250. clearedFields: make(map[string]struct{}),
  21251. }
  21252. for _, opt := range opts {
  21253. opt(m)
  21254. }
  21255. return m
  21256. }
  21257. // withTokenID sets the ID field of the mutation.
  21258. func withTokenID(id uint64) tokenOption {
  21259. return func(m *TokenMutation) {
  21260. var (
  21261. err error
  21262. once sync.Once
  21263. value *Token
  21264. )
  21265. m.oldValue = func(ctx context.Context) (*Token, error) {
  21266. once.Do(func() {
  21267. if m.done {
  21268. err = errors.New("querying old values post mutation is not allowed")
  21269. } else {
  21270. value, err = m.Client().Token.Get(ctx, id)
  21271. }
  21272. })
  21273. return value, err
  21274. }
  21275. m.id = &id
  21276. }
  21277. }
  21278. // withToken sets the old Token of the mutation.
  21279. func withToken(node *Token) tokenOption {
  21280. return func(m *TokenMutation) {
  21281. m.oldValue = func(context.Context) (*Token, error) {
  21282. return node, nil
  21283. }
  21284. m.id = &node.ID
  21285. }
  21286. }
  21287. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21288. // executed in a transaction (ent.Tx), a transactional client is returned.
  21289. func (m TokenMutation) Client() *Client {
  21290. client := &Client{config: m.config}
  21291. client.init()
  21292. return client
  21293. }
  21294. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21295. // it returns an error otherwise.
  21296. func (m TokenMutation) Tx() (*Tx, error) {
  21297. if _, ok := m.driver.(*txDriver); !ok {
  21298. return nil, errors.New("ent: mutation is not running in a transaction")
  21299. }
  21300. tx := &Tx{config: m.config}
  21301. tx.init()
  21302. return tx, nil
  21303. }
  21304. // SetID sets the value of the id field. Note that this
  21305. // operation is only accepted on creation of Token entities.
  21306. func (m *TokenMutation) SetID(id uint64) {
  21307. m.id = &id
  21308. }
  21309. // ID returns the ID value in the mutation. Note that the ID is only available
  21310. // if it was provided to the builder or after it was returned from the database.
  21311. func (m *TokenMutation) ID() (id uint64, exists bool) {
  21312. if m.id == nil {
  21313. return
  21314. }
  21315. return *m.id, true
  21316. }
  21317. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21318. // That means, if the mutation is applied within a transaction with an isolation level such
  21319. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21320. // or updated by the mutation.
  21321. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  21322. switch {
  21323. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21324. id, exists := m.ID()
  21325. if exists {
  21326. return []uint64{id}, nil
  21327. }
  21328. fallthrough
  21329. case m.op.Is(OpUpdate | OpDelete):
  21330. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  21331. default:
  21332. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21333. }
  21334. }
  21335. // SetCreatedAt sets the "created_at" field.
  21336. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  21337. m.created_at = &t
  21338. }
  21339. // CreatedAt returns the value of the "created_at" field in the mutation.
  21340. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  21341. v := m.created_at
  21342. if v == nil {
  21343. return
  21344. }
  21345. return *v, true
  21346. }
  21347. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  21348. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21350. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21351. if !m.op.Is(OpUpdateOne) {
  21352. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21353. }
  21354. if m.id == nil || m.oldValue == nil {
  21355. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21356. }
  21357. oldValue, err := m.oldValue(ctx)
  21358. if err != nil {
  21359. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21360. }
  21361. return oldValue.CreatedAt, nil
  21362. }
  21363. // ResetCreatedAt resets all changes to the "created_at" field.
  21364. func (m *TokenMutation) ResetCreatedAt() {
  21365. m.created_at = nil
  21366. }
  21367. // SetUpdatedAt sets the "updated_at" field.
  21368. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  21369. m.updated_at = &t
  21370. }
  21371. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21372. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  21373. v := m.updated_at
  21374. if v == nil {
  21375. return
  21376. }
  21377. return *v, true
  21378. }
  21379. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  21380. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21382. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21383. if !m.op.Is(OpUpdateOne) {
  21384. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21385. }
  21386. if m.id == nil || m.oldValue == nil {
  21387. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21388. }
  21389. oldValue, err := m.oldValue(ctx)
  21390. if err != nil {
  21391. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21392. }
  21393. return oldValue.UpdatedAt, nil
  21394. }
  21395. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21396. func (m *TokenMutation) ResetUpdatedAt() {
  21397. m.updated_at = nil
  21398. }
  21399. // SetDeletedAt sets the "deleted_at" field.
  21400. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  21401. m.deleted_at = &t
  21402. }
  21403. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21404. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  21405. v := m.deleted_at
  21406. if v == nil {
  21407. return
  21408. }
  21409. return *v, true
  21410. }
  21411. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  21412. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21414. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21415. if !m.op.Is(OpUpdateOne) {
  21416. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21417. }
  21418. if m.id == nil || m.oldValue == nil {
  21419. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21420. }
  21421. oldValue, err := m.oldValue(ctx)
  21422. if err != nil {
  21423. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21424. }
  21425. return oldValue.DeletedAt, nil
  21426. }
  21427. // ClearDeletedAt clears the value of the "deleted_at" field.
  21428. func (m *TokenMutation) ClearDeletedAt() {
  21429. m.deleted_at = nil
  21430. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  21431. }
  21432. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21433. func (m *TokenMutation) DeletedAtCleared() bool {
  21434. _, ok := m.clearedFields[token.FieldDeletedAt]
  21435. return ok
  21436. }
  21437. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21438. func (m *TokenMutation) ResetDeletedAt() {
  21439. m.deleted_at = nil
  21440. delete(m.clearedFields, token.FieldDeletedAt)
  21441. }
  21442. // SetExpireAt sets the "expire_at" field.
  21443. func (m *TokenMutation) SetExpireAt(t time.Time) {
  21444. m.expire_at = &t
  21445. }
  21446. // ExpireAt returns the value of the "expire_at" field in the mutation.
  21447. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  21448. v := m.expire_at
  21449. if v == nil {
  21450. return
  21451. }
  21452. return *v, true
  21453. }
  21454. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  21455. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21457. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  21458. if !m.op.Is(OpUpdateOne) {
  21459. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  21460. }
  21461. if m.id == nil || m.oldValue == nil {
  21462. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  21463. }
  21464. oldValue, err := m.oldValue(ctx)
  21465. if err != nil {
  21466. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  21467. }
  21468. return oldValue.ExpireAt, nil
  21469. }
  21470. // ClearExpireAt clears the value of the "expire_at" field.
  21471. func (m *TokenMutation) ClearExpireAt() {
  21472. m.expire_at = nil
  21473. m.clearedFields[token.FieldExpireAt] = struct{}{}
  21474. }
  21475. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  21476. func (m *TokenMutation) ExpireAtCleared() bool {
  21477. _, ok := m.clearedFields[token.FieldExpireAt]
  21478. return ok
  21479. }
  21480. // ResetExpireAt resets all changes to the "expire_at" field.
  21481. func (m *TokenMutation) ResetExpireAt() {
  21482. m.expire_at = nil
  21483. delete(m.clearedFields, token.FieldExpireAt)
  21484. }
  21485. // SetToken sets the "token" field.
  21486. func (m *TokenMutation) SetToken(s string) {
  21487. m.token = &s
  21488. }
  21489. // Token returns the value of the "token" field in the mutation.
  21490. func (m *TokenMutation) Token() (r string, exists bool) {
  21491. v := m.token
  21492. if v == nil {
  21493. return
  21494. }
  21495. return *v, true
  21496. }
  21497. // OldToken returns the old "token" field's value of the Token entity.
  21498. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21500. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  21501. if !m.op.Is(OpUpdateOne) {
  21502. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  21503. }
  21504. if m.id == nil || m.oldValue == nil {
  21505. return v, errors.New("OldToken requires an ID field in the mutation")
  21506. }
  21507. oldValue, err := m.oldValue(ctx)
  21508. if err != nil {
  21509. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  21510. }
  21511. return oldValue.Token, nil
  21512. }
  21513. // ClearToken clears the value of the "token" field.
  21514. func (m *TokenMutation) ClearToken() {
  21515. m.token = nil
  21516. m.clearedFields[token.FieldToken] = struct{}{}
  21517. }
  21518. // TokenCleared returns if the "token" field was cleared in this mutation.
  21519. func (m *TokenMutation) TokenCleared() bool {
  21520. _, ok := m.clearedFields[token.FieldToken]
  21521. return ok
  21522. }
  21523. // ResetToken resets all changes to the "token" field.
  21524. func (m *TokenMutation) ResetToken() {
  21525. m.token = nil
  21526. delete(m.clearedFields, token.FieldToken)
  21527. }
  21528. // SetMAC sets the "mac" field.
  21529. func (m *TokenMutation) SetMAC(s string) {
  21530. m.mac = &s
  21531. }
  21532. // MAC returns the value of the "mac" field in the mutation.
  21533. func (m *TokenMutation) MAC() (r string, exists bool) {
  21534. v := m.mac
  21535. if v == nil {
  21536. return
  21537. }
  21538. return *v, true
  21539. }
  21540. // OldMAC returns the old "mac" field's value of the Token entity.
  21541. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21543. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  21544. if !m.op.Is(OpUpdateOne) {
  21545. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  21546. }
  21547. if m.id == nil || m.oldValue == nil {
  21548. return v, errors.New("OldMAC requires an ID field in the mutation")
  21549. }
  21550. oldValue, err := m.oldValue(ctx)
  21551. if err != nil {
  21552. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  21553. }
  21554. return oldValue.MAC, nil
  21555. }
  21556. // ClearMAC clears the value of the "mac" field.
  21557. func (m *TokenMutation) ClearMAC() {
  21558. m.mac = nil
  21559. m.clearedFields[token.FieldMAC] = struct{}{}
  21560. }
  21561. // MACCleared returns if the "mac" field was cleared in this mutation.
  21562. func (m *TokenMutation) MACCleared() bool {
  21563. _, ok := m.clearedFields[token.FieldMAC]
  21564. return ok
  21565. }
  21566. // ResetMAC resets all changes to the "mac" field.
  21567. func (m *TokenMutation) ResetMAC() {
  21568. m.mac = nil
  21569. delete(m.clearedFields, token.FieldMAC)
  21570. }
  21571. // SetOrganizationID sets the "organization_id" field.
  21572. func (m *TokenMutation) SetOrganizationID(u uint64) {
  21573. m.organization_id = &u
  21574. m.addorganization_id = nil
  21575. }
  21576. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21577. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  21578. v := m.organization_id
  21579. if v == nil {
  21580. return
  21581. }
  21582. return *v, true
  21583. }
  21584. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  21585. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21587. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21588. if !m.op.Is(OpUpdateOne) {
  21589. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21590. }
  21591. if m.id == nil || m.oldValue == nil {
  21592. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21593. }
  21594. oldValue, err := m.oldValue(ctx)
  21595. if err != nil {
  21596. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21597. }
  21598. return oldValue.OrganizationID, nil
  21599. }
  21600. // AddOrganizationID adds u to the "organization_id" field.
  21601. func (m *TokenMutation) AddOrganizationID(u int64) {
  21602. if m.addorganization_id != nil {
  21603. *m.addorganization_id += u
  21604. } else {
  21605. m.addorganization_id = &u
  21606. }
  21607. }
  21608. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21609. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  21610. v := m.addorganization_id
  21611. if v == nil {
  21612. return
  21613. }
  21614. return *v, true
  21615. }
  21616. // ResetOrganizationID resets all changes to the "organization_id" field.
  21617. func (m *TokenMutation) ResetOrganizationID() {
  21618. m.organization_id = nil
  21619. m.addorganization_id = nil
  21620. }
  21621. // SetAgentID sets the "agent_id" field.
  21622. func (m *TokenMutation) SetAgentID(u uint64) {
  21623. m.agent = &u
  21624. }
  21625. // AgentID returns the value of the "agent_id" field in the mutation.
  21626. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  21627. v := m.agent
  21628. if v == nil {
  21629. return
  21630. }
  21631. return *v, true
  21632. }
  21633. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  21634. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21636. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  21637. if !m.op.Is(OpUpdateOne) {
  21638. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  21639. }
  21640. if m.id == nil || m.oldValue == nil {
  21641. return v, errors.New("OldAgentID requires an ID field in the mutation")
  21642. }
  21643. oldValue, err := m.oldValue(ctx)
  21644. if err != nil {
  21645. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  21646. }
  21647. return oldValue.AgentID, nil
  21648. }
  21649. // ResetAgentID resets all changes to the "agent_id" field.
  21650. func (m *TokenMutation) ResetAgentID() {
  21651. m.agent = nil
  21652. }
  21653. // SetCustomAgentBase sets the "custom_agent_base" field.
  21654. func (m *TokenMutation) SetCustomAgentBase(s string) {
  21655. m.custom_agent_base = &s
  21656. }
  21657. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  21658. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  21659. v := m.custom_agent_base
  21660. if v == nil {
  21661. return
  21662. }
  21663. return *v, true
  21664. }
  21665. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  21666. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21668. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  21669. if !m.op.Is(OpUpdateOne) {
  21670. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  21671. }
  21672. if m.id == nil || m.oldValue == nil {
  21673. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  21674. }
  21675. oldValue, err := m.oldValue(ctx)
  21676. if err != nil {
  21677. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  21678. }
  21679. return oldValue.CustomAgentBase, nil
  21680. }
  21681. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  21682. func (m *TokenMutation) ClearCustomAgentBase() {
  21683. m.custom_agent_base = nil
  21684. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  21685. }
  21686. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  21687. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  21688. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  21689. return ok
  21690. }
  21691. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  21692. func (m *TokenMutation) ResetCustomAgentBase() {
  21693. m.custom_agent_base = nil
  21694. delete(m.clearedFields, token.FieldCustomAgentBase)
  21695. }
  21696. // SetCustomAgentKey sets the "custom_agent_key" field.
  21697. func (m *TokenMutation) SetCustomAgentKey(s string) {
  21698. m.custom_agent_key = &s
  21699. }
  21700. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  21701. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  21702. v := m.custom_agent_key
  21703. if v == nil {
  21704. return
  21705. }
  21706. return *v, true
  21707. }
  21708. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  21709. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21711. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  21712. if !m.op.Is(OpUpdateOne) {
  21713. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  21714. }
  21715. if m.id == nil || m.oldValue == nil {
  21716. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  21717. }
  21718. oldValue, err := m.oldValue(ctx)
  21719. if err != nil {
  21720. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  21721. }
  21722. return oldValue.CustomAgentKey, nil
  21723. }
  21724. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  21725. func (m *TokenMutation) ClearCustomAgentKey() {
  21726. m.custom_agent_key = nil
  21727. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  21728. }
  21729. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  21730. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  21731. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  21732. return ok
  21733. }
  21734. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  21735. func (m *TokenMutation) ResetCustomAgentKey() {
  21736. m.custom_agent_key = nil
  21737. delete(m.clearedFields, token.FieldCustomAgentKey)
  21738. }
  21739. // SetOpenaiBase sets the "openai_base" field.
  21740. func (m *TokenMutation) SetOpenaiBase(s string) {
  21741. m.openai_base = &s
  21742. }
  21743. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  21744. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  21745. v := m.openai_base
  21746. if v == nil {
  21747. return
  21748. }
  21749. return *v, true
  21750. }
  21751. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  21752. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21754. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  21755. if !m.op.Is(OpUpdateOne) {
  21756. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  21757. }
  21758. if m.id == nil || m.oldValue == nil {
  21759. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  21760. }
  21761. oldValue, err := m.oldValue(ctx)
  21762. if err != nil {
  21763. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  21764. }
  21765. return oldValue.OpenaiBase, nil
  21766. }
  21767. // ClearOpenaiBase clears the value of the "openai_base" field.
  21768. func (m *TokenMutation) ClearOpenaiBase() {
  21769. m.openai_base = nil
  21770. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  21771. }
  21772. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  21773. func (m *TokenMutation) OpenaiBaseCleared() bool {
  21774. _, ok := m.clearedFields[token.FieldOpenaiBase]
  21775. return ok
  21776. }
  21777. // ResetOpenaiBase resets all changes to the "openai_base" field.
  21778. func (m *TokenMutation) ResetOpenaiBase() {
  21779. m.openai_base = nil
  21780. delete(m.clearedFields, token.FieldOpenaiBase)
  21781. }
  21782. // SetOpenaiKey sets the "openai_key" field.
  21783. func (m *TokenMutation) SetOpenaiKey(s string) {
  21784. m.openai_key = &s
  21785. }
  21786. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  21787. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  21788. v := m.openai_key
  21789. if v == nil {
  21790. return
  21791. }
  21792. return *v, true
  21793. }
  21794. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  21795. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21797. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  21798. if !m.op.Is(OpUpdateOne) {
  21799. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  21800. }
  21801. if m.id == nil || m.oldValue == nil {
  21802. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  21803. }
  21804. oldValue, err := m.oldValue(ctx)
  21805. if err != nil {
  21806. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  21807. }
  21808. return oldValue.OpenaiKey, nil
  21809. }
  21810. // ClearOpenaiKey clears the value of the "openai_key" field.
  21811. func (m *TokenMutation) ClearOpenaiKey() {
  21812. m.openai_key = nil
  21813. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  21814. }
  21815. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  21816. func (m *TokenMutation) OpenaiKeyCleared() bool {
  21817. _, ok := m.clearedFields[token.FieldOpenaiKey]
  21818. return ok
  21819. }
  21820. // ResetOpenaiKey resets all changes to the "openai_key" field.
  21821. func (m *TokenMutation) ResetOpenaiKey() {
  21822. m.openai_key = nil
  21823. delete(m.clearedFields, token.FieldOpenaiKey)
  21824. }
  21825. // ClearAgent clears the "agent" edge to the Agent entity.
  21826. func (m *TokenMutation) ClearAgent() {
  21827. m.clearedagent = true
  21828. m.clearedFields[token.FieldAgentID] = struct{}{}
  21829. }
  21830. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  21831. func (m *TokenMutation) AgentCleared() bool {
  21832. return m.clearedagent
  21833. }
  21834. // AgentIDs returns the "agent" edge IDs in the mutation.
  21835. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21836. // AgentID instead. It exists only for internal usage by the builders.
  21837. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  21838. if id := m.agent; id != nil {
  21839. ids = append(ids, *id)
  21840. }
  21841. return
  21842. }
  21843. // ResetAgent resets all changes to the "agent" edge.
  21844. func (m *TokenMutation) ResetAgent() {
  21845. m.agent = nil
  21846. m.clearedagent = false
  21847. }
  21848. // Where appends a list predicates to the TokenMutation builder.
  21849. func (m *TokenMutation) Where(ps ...predicate.Token) {
  21850. m.predicates = append(m.predicates, ps...)
  21851. }
  21852. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  21853. // users can use type-assertion to append predicates that do not depend on any generated package.
  21854. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  21855. p := make([]predicate.Token, len(ps))
  21856. for i := range ps {
  21857. p[i] = ps[i]
  21858. }
  21859. m.Where(p...)
  21860. }
  21861. // Op returns the operation name.
  21862. func (m *TokenMutation) Op() Op {
  21863. return m.op
  21864. }
  21865. // SetOp allows setting the mutation operation.
  21866. func (m *TokenMutation) SetOp(op Op) {
  21867. m.op = op
  21868. }
  21869. // Type returns the node type of this mutation (Token).
  21870. func (m *TokenMutation) Type() string {
  21871. return m.typ
  21872. }
  21873. // Fields returns all fields that were changed during this mutation. Note that in
  21874. // order to get all numeric fields that were incremented/decremented, call
  21875. // AddedFields().
  21876. func (m *TokenMutation) Fields() []string {
  21877. fields := make([]string, 0, 12)
  21878. if m.created_at != nil {
  21879. fields = append(fields, token.FieldCreatedAt)
  21880. }
  21881. if m.updated_at != nil {
  21882. fields = append(fields, token.FieldUpdatedAt)
  21883. }
  21884. if m.deleted_at != nil {
  21885. fields = append(fields, token.FieldDeletedAt)
  21886. }
  21887. if m.expire_at != nil {
  21888. fields = append(fields, token.FieldExpireAt)
  21889. }
  21890. if m.token != nil {
  21891. fields = append(fields, token.FieldToken)
  21892. }
  21893. if m.mac != nil {
  21894. fields = append(fields, token.FieldMAC)
  21895. }
  21896. if m.organization_id != nil {
  21897. fields = append(fields, token.FieldOrganizationID)
  21898. }
  21899. if m.agent != nil {
  21900. fields = append(fields, token.FieldAgentID)
  21901. }
  21902. if m.custom_agent_base != nil {
  21903. fields = append(fields, token.FieldCustomAgentBase)
  21904. }
  21905. if m.custom_agent_key != nil {
  21906. fields = append(fields, token.FieldCustomAgentKey)
  21907. }
  21908. if m.openai_base != nil {
  21909. fields = append(fields, token.FieldOpenaiBase)
  21910. }
  21911. if m.openai_key != nil {
  21912. fields = append(fields, token.FieldOpenaiKey)
  21913. }
  21914. return fields
  21915. }
  21916. // Field returns the value of a field with the given name. The second boolean
  21917. // return value indicates that this field was not set, or was not defined in the
  21918. // schema.
  21919. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  21920. switch name {
  21921. case token.FieldCreatedAt:
  21922. return m.CreatedAt()
  21923. case token.FieldUpdatedAt:
  21924. return m.UpdatedAt()
  21925. case token.FieldDeletedAt:
  21926. return m.DeletedAt()
  21927. case token.FieldExpireAt:
  21928. return m.ExpireAt()
  21929. case token.FieldToken:
  21930. return m.Token()
  21931. case token.FieldMAC:
  21932. return m.MAC()
  21933. case token.FieldOrganizationID:
  21934. return m.OrganizationID()
  21935. case token.FieldAgentID:
  21936. return m.AgentID()
  21937. case token.FieldCustomAgentBase:
  21938. return m.CustomAgentBase()
  21939. case token.FieldCustomAgentKey:
  21940. return m.CustomAgentKey()
  21941. case token.FieldOpenaiBase:
  21942. return m.OpenaiBase()
  21943. case token.FieldOpenaiKey:
  21944. return m.OpenaiKey()
  21945. }
  21946. return nil, false
  21947. }
  21948. // OldField returns the old value of the field from the database. An error is
  21949. // returned if the mutation operation is not UpdateOne, or the query to the
  21950. // database failed.
  21951. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21952. switch name {
  21953. case token.FieldCreatedAt:
  21954. return m.OldCreatedAt(ctx)
  21955. case token.FieldUpdatedAt:
  21956. return m.OldUpdatedAt(ctx)
  21957. case token.FieldDeletedAt:
  21958. return m.OldDeletedAt(ctx)
  21959. case token.FieldExpireAt:
  21960. return m.OldExpireAt(ctx)
  21961. case token.FieldToken:
  21962. return m.OldToken(ctx)
  21963. case token.FieldMAC:
  21964. return m.OldMAC(ctx)
  21965. case token.FieldOrganizationID:
  21966. return m.OldOrganizationID(ctx)
  21967. case token.FieldAgentID:
  21968. return m.OldAgentID(ctx)
  21969. case token.FieldCustomAgentBase:
  21970. return m.OldCustomAgentBase(ctx)
  21971. case token.FieldCustomAgentKey:
  21972. return m.OldCustomAgentKey(ctx)
  21973. case token.FieldOpenaiBase:
  21974. return m.OldOpenaiBase(ctx)
  21975. case token.FieldOpenaiKey:
  21976. return m.OldOpenaiKey(ctx)
  21977. }
  21978. return nil, fmt.Errorf("unknown Token field %s", name)
  21979. }
  21980. // SetField sets the value of a field with the given name. It returns an error if
  21981. // the field is not defined in the schema, or if the type mismatched the field
  21982. // type.
  21983. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  21984. switch name {
  21985. case token.FieldCreatedAt:
  21986. v, ok := value.(time.Time)
  21987. if !ok {
  21988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21989. }
  21990. m.SetCreatedAt(v)
  21991. return nil
  21992. case token.FieldUpdatedAt:
  21993. v, ok := value.(time.Time)
  21994. if !ok {
  21995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21996. }
  21997. m.SetUpdatedAt(v)
  21998. return nil
  21999. case token.FieldDeletedAt:
  22000. v, ok := value.(time.Time)
  22001. if !ok {
  22002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22003. }
  22004. m.SetDeletedAt(v)
  22005. return nil
  22006. case token.FieldExpireAt:
  22007. v, ok := value.(time.Time)
  22008. if !ok {
  22009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22010. }
  22011. m.SetExpireAt(v)
  22012. return nil
  22013. case token.FieldToken:
  22014. v, ok := value.(string)
  22015. if !ok {
  22016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22017. }
  22018. m.SetToken(v)
  22019. return nil
  22020. case token.FieldMAC:
  22021. v, ok := value.(string)
  22022. if !ok {
  22023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22024. }
  22025. m.SetMAC(v)
  22026. return nil
  22027. case token.FieldOrganizationID:
  22028. v, ok := value.(uint64)
  22029. if !ok {
  22030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22031. }
  22032. m.SetOrganizationID(v)
  22033. return nil
  22034. case token.FieldAgentID:
  22035. v, ok := value.(uint64)
  22036. if !ok {
  22037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22038. }
  22039. m.SetAgentID(v)
  22040. return nil
  22041. case token.FieldCustomAgentBase:
  22042. v, ok := value.(string)
  22043. if !ok {
  22044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22045. }
  22046. m.SetCustomAgentBase(v)
  22047. return nil
  22048. case token.FieldCustomAgentKey:
  22049. v, ok := value.(string)
  22050. if !ok {
  22051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22052. }
  22053. m.SetCustomAgentKey(v)
  22054. return nil
  22055. case token.FieldOpenaiBase:
  22056. v, ok := value.(string)
  22057. if !ok {
  22058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22059. }
  22060. m.SetOpenaiBase(v)
  22061. return nil
  22062. case token.FieldOpenaiKey:
  22063. v, ok := value.(string)
  22064. if !ok {
  22065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22066. }
  22067. m.SetOpenaiKey(v)
  22068. return nil
  22069. }
  22070. return fmt.Errorf("unknown Token field %s", name)
  22071. }
  22072. // AddedFields returns all numeric fields that were incremented/decremented during
  22073. // this mutation.
  22074. func (m *TokenMutation) AddedFields() []string {
  22075. var fields []string
  22076. if m.addorganization_id != nil {
  22077. fields = append(fields, token.FieldOrganizationID)
  22078. }
  22079. return fields
  22080. }
  22081. // AddedField returns the numeric value that was incremented/decremented on a field
  22082. // with the given name. The second boolean return value indicates that this field
  22083. // was not set, or was not defined in the schema.
  22084. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  22085. switch name {
  22086. case token.FieldOrganizationID:
  22087. return m.AddedOrganizationID()
  22088. }
  22089. return nil, false
  22090. }
  22091. // AddField adds the value to the field with the given name. It returns an error if
  22092. // the field is not defined in the schema, or if the type mismatched the field
  22093. // type.
  22094. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  22095. switch name {
  22096. case token.FieldOrganizationID:
  22097. v, ok := value.(int64)
  22098. if !ok {
  22099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22100. }
  22101. m.AddOrganizationID(v)
  22102. return nil
  22103. }
  22104. return fmt.Errorf("unknown Token numeric field %s", name)
  22105. }
  22106. // ClearedFields returns all nullable fields that were cleared during this
  22107. // mutation.
  22108. func (m *TokenMutation) ClearedFields() []string {
  22109. var fields []string
  22110. if m.FieldCleared(token.FieldDeletedAt) {
  22111. fields = append(fields, token.FieldDeletedAt)
  22112. }
  22113. if m.FieldCleared(token.FieldExpireAt) {
  22114. fields = append(fields, token.FieldExpireAt)
  22115. }
  22116. if m.FieldCleared(token.FieldToken) {
  22117. fields = append(fields, token.FieldToken)
  22118. }
  22119. if m.FieldCleared(token.FieldMAC) {
  22120. fields = append(fields, token.FieldMAC)
  22121. }
  22122. if m.FieldCleared(token.FieldCustomAgentBase) {
  22123. fields = append(fields, token.FieldCustomAgentBase)
  22124. }
  22125. if m.FieldCleared(token.FieldCustomAgentKey) {
  22126. fields = append(fields, token.FieldCustomAgentKey)
  22127. }
  22128. if m.FieldCleared(token.FieldOpenaiBase) {
  22129. fields = append(fields, token.FieldOpenaiBase)
  22130. }
  22131. if m.FieldCleared(token.FieldOpenaiKey) {
  22132. fields = append(fields, token.FieldOpenaiKey)
  22133. }
  22134. return fields
  22135. }
  22136. // FieldCleared returns a boolean indicating if a field with the given name was
  22137. // cleared in this mutation.
  22138. func (m *TokenMutation) FieldCleared(name string) bool {
  22139. _, ok := m.clearedFields[name]
  22140. return ok
  22141. }
  22142. // ClearField clears the value of the field with the given name. It returns an
  22143. // error if the field is not defined in the schema.
  22144. func (m *TokenMutation) ClearField(name string) error {
  22145. switch name {
  22146. case token.FieldDeletedAt:
  22147. m.ClearDeletedAt()
  22148. return nil
  22149. case token.FieldExpireAt:
  22150. m.ClearExpireAt()
  22151. return nil
  22152. case token.FieldToken:
  22153. m.ClearToken()
  22154. return nil
  22155. case token.FieldMAC:
  22156. m.ClearMAC()
  22157. return nil
  22158. case token.FieldCustomAgentBase:
  22159. m.ClearCustomAgentBase()
  22160. return nil
  22161. case token.FieldCustomAgentKey:
  22162. m.ClearCustomAgentKey()
  22163. return nil
  22164. case token.FieldOpenaiBase:
  22165. m.ClearOpenaiBase()
  22166. return nil
  22167. case token.FieldOpenaiKey:
  22168. m.ClearOpenaiKey()
  22169. return nil
  22170. }
  22171. return fmt.Errorf("unknown Token nullable field %s", name)
  22172. }
  22173. // ResetField resets all changes in the mutation for the field with the given name.
  22174. // It returns an error if the field is not defined in the schema.
  22175. func (m *TokenMutation) ResetField(name string) error {
  22176. switch name {
  22177. case token.FieldCreatedAt:
  22178. m.ResetCreatedAt()
  22179. return nil
  22180. case token.FieldUpdatedAt:
  22181. m.ResetUpdatedAt()
  22182. return nil
  22183. case token.FieldDeletedAt:
  22184. m.ResetDeletedAt()
  22185. return nil
  22186. case token.FieldExpireAt:
  22187. m.ResetExpireAt()
  22188. return nil
  22189. case token.FieldToken:
  22190. m.ResetToken()
  22191. return nil
  22192. case token.FieldMAC:
  22193. m.ResetMAC()
  22194. return nil
  22195. case token.FieldOrganizationID:
  22196. m.ResetOrganizationID()
  22197. return nil
  22198. case token.FieldAgentID:
  22199. m.ResetAgentID()
  22200. return nil
  22201. case token.FieldCustomAgentBase:
  22202. m.ResetCustomAgentBase()
  22203. return nil
  22204. case token.FieldCustomAgentKey:
  22205. m.ResetCustomAgentKey()
  22206. return nil
  22207. case token.FieldOpenaiBase:
  22208. m.ResetOpenaiBase()
  22209. return nil
  22210. case token.FieldOpenaiKey:
  22211. m.ResetOpenaiKey()
  22212. return nil
  22213. }
  22214. return fmt.Errorf("unknown Token field %s", name)
  22215. }
  22216. // AddedEdges returns all edge names that were set/added in this mutation.
  22217. func (m *TokenMutation) AddedEdges() []string {
  22218. edges := make([]string, 0, 1)
  22219. if m.agent != nil {
  22220. edges = append(edges, token.EdgeAgent)
  22221. }
  22222. return edges
  22223. }
  22224. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22225. // name in this mutation.
  22226. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  22227. switch name {
  22228. case token.EdgeAgent:
  22229. if id := m.agent; id != nil {
  22230. return []ent.Value{*id}
  22231. }
  22232. }
  22233. return nil
  22234. }
  22235. // RemovedEdges returns all edge names that were removed in this mutation.
  22236. func (m *TokenMutation) RemovedEdges() []string {
  22237. edges := make([]string, 0, 1)
  22238. return edges
  22239. }
  22240. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22241. // the given name in this mutation.
  22242. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  22243. return nil
  22244. }
  22245. // ClearedEdges returns all edge names that were cleared in this mutation.
  22246. func (m *TokenMutation) ClearedEdges() []string {
  22247. edges := make([]string, 0, 1)
  22248. if m.clearedagent {
  22249. edges = append(edges, token.EdgeAgent)
  22250. }
  22251. return edges
  22252. }
  22253. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22254. // was cleared in this mutation.
  22255. func (m *TokenMutation) EdgeCleared(name string) bool {
  22256. switch name {
  22257. case token.EdgeAgent:
  22258. return m.clearedagent
  22259. }
  22260. return false
  22261. }
  22262. // ClearEdge clears the value of the edge with the given name. It returns an error
  22263. // if that edge is not defined in the schema.
  22264. func (m *TokenMutation) ClearEdge(name string) error {
  22265. switch name {
  22266. case token.EdgeAgent:
  22267. m.ClearAgent()
  22268. return nil
  22269. }
  22270. return fmt.Errorf("unknown Token unique edge %s", name)
  22271. }
  22272. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22273. // It returns an error if the edge is not defined in the schema.
  22274. func (m *TokenMutation) ResetEdge(name string) error {
  22275. switch name {
  22276. case token.EdgeAgent:
  22277. m.ResetAgent()
  22278. return nil
  22279. }
  22280. return fmt.Errorf("unknown Token edge %s", name)
  22281. }
  22282. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  22283. type TutorialMutation struct {
  22284. config
  22285. op Op
  22286. typ string
  22287. id *uint64
  22288. created_at *time.Time
  22289. updated_at *time.Time
  22290. deleted_at *time.Time
  22291. index *int
  22292. addindex *int
  22293. title *string
  22294. content *string
  22295. organization_id *uint64
  22296. addorganization_id *int64
  22297. clearedFields map[string]struct{}
  22298. employee *uint64
  22299. clearedemployee bool
  22300. done bool
  22301. oldValue func(context.Context) (*Tutorial, error)
  22302. predicates []predicate.Tutorial
  22303. }
  22304. var _ ent.Mutation = (*TutorialMutation)(nil)
  22305. // tutorialOption allows management of the mutation configuration using functional options.
  22306. type tutorialOption func(*TutorialMutation)
  22307. // newTutorialMutation creates new mutation for the Tutorial entity.
  22308. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  22309. m := &TutorialMutation{
  22310. config: c,
  22311. op: op,
  22312. typ: TypeTutorial,
  22313. clearedFields: make(map[string]struct{}),
  22314. }
  22315. for _, opt := range opts {
  22316. opt(m)
  22317. }
  22318. return m
  22319. }
  22320. // withTutorialID sets the ID field of the mutation.
  22321. func withTutorialID(id uint64) tutorialOption {
  22322. return func(m *TutorialMutation) {
  22323. var (
  22324. err error
  22325. once sync.Once
  22326. value *Tutorial
  22327. )
  22328. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  22329. once.Do(func() {
  22330. if m.done {
  22331. err = errors.New("querying old values post mutation is not allowed")
  22332. } else {
  22333. value, err = m.Client().Tutorial.Get(ctx, id)
  22334. }
  22335. })
  22336. return value, err
  22337. }
  22338. m.id = &id
  22339. }
  22340. }
  22341. // withTutorial sets the old Tutorial of the mutation.
  22342. func withTutorial(node *Tutorial) tutorialOption {
  22343. return func(m *TutorialMutation) {
  22344. m.oldValue = func(context.Context) (*Tutorial, error) {
  22345. return node, nil
  22346. }
  22347. m.id = &node.ID
  22348. }
  22349. }
  22350. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22351. // executed in a transaction (ent.Tx), a transactional client is returned.
  22352. func (m TutorialMutation) Client() *Client {
  22353. client := &Client{config: m.config}
  22354. client.init()
  22355. return client
  22356. }
  22357. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22358. // it returns an error otherwise.
  22359. func (m TutorialMutation) Tx() (*Tx, error) {
  22360. if _, ok := m.driver.(*txDriver); !ok {
  22361. return nil, errors.New("ent: mutation is not running in a transaction")
  22362. }
  22363. tx := &Tx{config: m.config}
  22364. tx.init()
  22365. return tx, nil
  22366. }
  22367. // SetID sets the value of the id field. Note that this
  22368. // operation is only accepted on creation of Tutorial entities.
  22369. func (m *TutorialMutation) SetID(id uint64) {
  22370. m.id = &id
  22371. }
  22372. // ID returns the ID value in the mutation. Note that the ID is only available
  22373. // if it was provided to the builder or after it was returned from the database.
  22374. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  22375. if m.id == nil {
  22376. return
  22377. }
  22378. return *m.id, true
  22379. }
  22380. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22381. // That means, if the mutation is applied within a transaction with an isolation level such
  22382. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22383. // or updated by the mutation.
  22384. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  22385. switch {
  22386. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22387. id, exists := m.ID()
  22388. if exists {
  22389. return []uint64{id}, nil
  22390. }
  22391. fallthrough
  22392. case m.op.Is(OpUpdate | OpDelete):
  22393. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  22394. default:
  22395. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22396. }
  22397. }
  22398. // SetCreatedAt sets the "created_at" field.
  22399. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  22400. m.created_at = &t
  22401. }
  22402. // CreatedAt returns the value of the "created_at" field in the mutation.
  22403. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  22404. v := m.created_at
  22405. if v == nil {
  22406. return
  22407. }
  22408. return *v, true
  22409. }
  22410. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  22411. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22413. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22414. if !m.op.Is(OpUpdateOne) {
  22415. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22416. }
  22417. if m.id == nil || m.oldValue == nil {
  22418. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22419. }
  22420. oldValue, err := m.oldValue(ctx)
  22421. if err != nil {
  22422. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22423. }
  22424. return oldValue.CreatedAt, nil
  22425. }
  22426. // ResetCreatedAt resets all changes to the "created_at" field.
  22427. func (m *TutorialMutation) ResetCreatedAt() {
  22428. m.created_at = nil
  22429. }
  22430. // SetUpdatedAt sets the "updated_at" field.
  22431. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  22432. m.updated_at = &t
  22433. }
  22434. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22435. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  22436. v := m.updated_at
  22437. if v == nil {
  22438. return
  22439. }
  22440. return *v, true
  22441. }
  22442. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  22443. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22445. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22446. if !m.op.Is(OpUpdateOne) {
  22447. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22448. }
  22449. if m.id == nil || m.oldValue == nil {
  22450. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22451. }
  22452. oldValue, err := m.oldValue(ctx)
  22453. if err != nil {
  22454. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22455. }
  22456. return oldValue.UpdatedAt, nil
  22457. }
  22458. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22459. func (m *TutorialMutation) ResetUpdatedAt() {
  22460. m.updated_at = nil
  22461. }
  22462. // SetDeletedAt sets the "deleted_at" field.
  22463. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  22464. m.deleted_at = &t
  22465. }
  22466. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22467. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  22468. v := m.deleted_at
  22469. if v == nil {
  22470. return
  22471. }
  22472. return *v, true
  22473. }
  22474. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  22475. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22477. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22478. if !m.op.Is(OpUpdateOne) {
  22479. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22480. }
  22481. if m.id == nil || m.oldValue == nil {
  22482. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22483. }
  22484. oldValue, err := m.oldValue(ctx)
  22485. if err != nil {
  22486. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22487. }
  22488. return oldValue.DeletedAt, nil
  22489. }
  22490. // ClearDeletedAt clears the value of the "deleted_at" field.
  22491. func (m *TutorialMutation) ClearDeletedAt() {
  22492. m.deleted_at = nil
  22493. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  22494. }
  22495. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22496. func (m *TutorialMutation) DeletedAtCleared() bool {
  22497. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  22498. return ok
  22499. }
  22500. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22501. func (m *TutorialMutation) ResetDeletedAt() {
  22502. m.deleted_at = nil
  22503. delete(m.clearedFields, tutorial.FieldDeletedAt)
  22504. }
  22505. // SetEmployeeID sets the "employee_id" field.
  22506. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  22507. m.employee = &u
  22508. }
  22509. // EmployeeID returns the value of the "employee_id" field in the mutation.
  22510. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  22511. v := m.employee
  22512. if v == nil {
  22513. return
  22514. }
  22515. return *v, true
  22516. }
  22517. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  22518. // If the Tutorial 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 *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  22521. if !m.op.Is(OpUpdateOne) {
  22522. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  22523. }
  22524. if m.id == nil || m.oldValue == nil {
  22525. return v, errors.New("OldEmployeeID 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 OldEmployeeID: %w", err)
  22530. }
  22531. return oldValue.EmployeeID, nil
  22532. }
  22533. // ResetEmployeeID resets all changes to the "employee_id" field.
  22534. func (m *TutorialMutation) ResetEmployeeID() {
  22535. m.employee = nil
  22536. }
  22537. // SetIndex sets the "index" field.
  22538. func (m *TutorialMutation) SetIndex(i int) {
  22539. m.index = &i
  22540. m.addindex = nil
  22541. }
  22542. // Index returns the value of the "index" field in the mutation.
  22543. func (m *TutorialMutation) Index() (r int, exists bool) {
  22544. v := m.index
  22545. if v == nil {
  22546. return
  22547. }
  22548. return *v, true
  22549. }
  22550. // OldIndex returns the old "index" field's value of the Tutorial entity.
  22551. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22553. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  22554. if !m.op.Is(OpUpdateOne) {
  22555. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  22556. }
  22557. if m.id == nil || m.oldValue == nil {
  22558. return v, errors.New("OldIndex requires an ID field in the mutation")
  22559. }
  22560. oldValue, err := m.oldValue(ctx)
  22561. if err != nil {
  22562. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  22563. }
  22564. return oldValue.Index, nil
  22565. }
  22566. // AddIndex adds i to the "index" field.
  22567. func (m *TutorialMutation) AddIndex(i int) {
  22568. if m.addindex != nil {
  22569. *m.addindex += i
  22570. } else {
  22571. m.addindex = &i
  22572. }
  22573. }
  22574. // AddedIndex returns the value that was added to the "index" field in this mutation.
  22575. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  22576. v := m.addindex
  22577. if v == nil {
  22578. return
  22579. }
  22580. return *v, true
  22581. }
  22582. // ResetIndex resets all changes to the "index" field.
  22583. func (m *TutorialMutation) ResetIndex() {
  22584. m.index = nil
  22585. m.addindex = nil
  22586. }
  22587. // SetTitle sets the "title" field.
  22588. func (m *TutorialMutation) SetTitle(s string) {
  22589. m.title = &s
  22590. }
  22591. // Title returns the value of the "title" field in the mutation.
  22592. func (m *TutorialMutation) Title() (r string, exists bool) {
  22593. v := m.title
  22594. if v == nil {
  22595. return
  22596. }
  22597. return *v, true
  22598. }
  22599. // OldTitle returns the old "title" field's value of the Tutorial entity.
  22600. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22602. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  22603. if !m.op.Is(OpUpdateOne) {
  22604. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  22605. }
  22606. if m.id == nil || m.oldValue == nil {
  22607. return v, errors.New("OldTitle requires an ID field in the mutation")
  22608. }
  22609. oldValue, err := m.oldValue(ctx)
  22610. if err != nil {
  22611. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  22612. }
  22613. return oldValue.Title, nil
  22614. }
  22615. // ResetTitle resets all changes to the "title" field.
  22616. func (m *TutorialMutation) ResetTitle() {
  22617. m.title = nil
  22618. }
  22619. // SetContent sets the "content" field.
  22620. func (m *TutorialMutation) SetContent(s string) {
  22621. m.content = &s
  22622. }
  22623. // Content returns the value of the "content" field in the mutation.
  22624. func (m *TutorialMutation) Content() (r string, exists bool) {
  22625. v := m.content
  22626. if v == nil {
  22627. return
  22628. }
  22629. return *v, true
  22630. }
  22631. // OldContent returns the old "content" field's value of the Tutorial entity.
  22632. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22634. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  22635. if !m.op.Is(OpUpdateOne) {
  22636. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22637. }
  22638. if m.id == nil || m.oldValue == nil {
  22639. return v, errors.New("OldContent requires an ID field in the mutation")
  22640. }
  22641. oldValue, err := m.oldValue(ctx)
  22642. if err != nil {
  22643. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22644. }
  22645. return oldValue.Content, nil
  22646. }
  22647. // ResetContent resets all changes to the "content" field.
  22648. func (m *TutorialMutation) ResetContent() {
  22649. m.content = nil
  22650. }
  22651. // SetOrganizationID sets the "organization_id" field.
  22652. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  22653. m.organization_id = &u
  22654. m.addorganization_id = nil
  22655. }
  22656. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22657. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  22658. v := m.organization_id
  22659. if v == nil {
  22660. return
  22661. }
  22662. return *v, true
  22663. }
  22664. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  22665. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22667. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22668. if !m.op.Is(OpUpdateOne) {
  22669. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22670. }
  22671. if m.id == nil || m.oldValue == nil {
  22672. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22673. }
  22674. oldValue, err := m.oldValue(ctx)
  22675. if err != nil {
  22676. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22677. }
  22678. return oldValue.OrganizationID, nil
  22679. }
  22680. // AddOrganizationID adds u to the "organization_id" field.
  22681. func (m *TutorialMutation) AddOrganizationID(u int64) {
  22682. if m.addorganization_id != nil {
  22683. *m.addorganization_id += u
  22684. } else {
  22685. m.addorganization_id = &u
  22686. }
  22687. }
  22688. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22689. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  22690. v := m.addorganization_id
  22691. if v == nil {
  22692. return
  22693. }
  22694. return *v, true
  22695. }
  22696. // ResetOrganizationID resets all changes to the "organization_id" field.
  22697. func (m *TutorialMutation) ResetOrganizationID() {
  22698. m.organization_id = nil
  22699. m.addorganization_id = nil
  22700. }
  22701. // ClearEmployee clears the "employee" edge to the Employee entity.
  22702. func (m *TutorialMutation) ClearEmployee() {
  22703. m.clearedemployee = true
  22704. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  22705. }
  22706. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  22707. func (m *TutorialMutation) EmployeeCleared() bool {
  22708. return m.clearedemployee
  22709. }
  22710. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  22711. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22712. // EmployeeID instead. It exists only for internal usage by the builders.
  22713. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  22714. if id := m.employee; id != nil {
  22715. ids = append(ids, *id)
  22716. }
  22717. return
  22718. }
  22719. // ResetEmployee resets all changes to the "employee" edge.
  22720. func (m *TutorialMutation) ResetEmployee() {
  22721. m.employee = nil
  22722. m.clearedemployee = false
  22723. }
  22724. // Where appends a list predicates to the TutorialMutation builder.
  22725. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  22726. m.predicates = append(m.predicates, ps...)
  22727. }
  22728. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  22729. // users can use type-assertion to append predicates that do not depend on any generated package.
  22730. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  22731. p := make([]predicate.Tutorial, len(ps))
  22732. for i := range ps {
  22733. p[i] = ps[i]
  22734. }
  22735. m.Where(p...)
  22736. }
  22737. // Op returns the operation name.
  22738. func (m *TutorialMutation) Op() Op {
  22739. return m.op
  22740. }
  22741. // SetOp allows setting the mutation operation.
  22742. func (m *TutorialMutation) SetOp(op Op) {
  22743. m.op = op
  22744. }
  22745. // Type returns the node type of this mutation (Tutorial).
  22746. func (m *TutorialMutation) Type() string {
  22747. return m.typ
  22748. }
  22749. // Fields returns all fields that were changed during this mutation. Note that in
  22750. // order to get all numeric fields that were incremented/decremented, call
  22751. // AddedFields().
  22752. func (m *TutorialMutation) Fields() []string {
  22753. fields := make([]string, 0, 8)
  22754. if m.created_at != nil {
  22755. fields = append(fields, tutorial.FieldCreatedAt)
  22756. }
  22757. if m.updated_at != nil {
  22758. fields = append(fields, tutorial.FieldUpdatedAt)
  22759. }
  22760. if m.deleted_at != nil {
  22761. fields = append(fields, tutorial.FieldDeletedAt)
  22762. }
  22763. if m.employee != nil {
  22764. fields = append(fields, tutorial.FieldEmployeeID)
  22765. }
  22766. if m.index != nil {
  22767. fields = append(fields, tutorial.FieldIndex)
  22768. }
  22769. if m.title != nil {
  22770. fields = append(fields, tutorial.FieldTitle)
  22771. }
  22772. if m.content != nil {
  22773. fields = append(fields, tutorial.FieldContent)
  22774. }
  22775. if m.organization_id != nil {
  22776. fields = append(fields, tutorial.FieldOrganizationID)
  22777. }
  22778. return fields
  22779. }
  22780. // Field returns the value of a field with the given name. The second boolean
  22781. // return value indicates that this field was not set, or was not defined in the
  22782. // schema.
  22783. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  22784. switch name {
  22785. case tutorial.FieldCreatedAt:
  22786. return m.CreatedAt()
  22787. case tutorial.FieldUpdatedAt:
  22788. return m.UpdatedAt()
  22789. case tutorial.FieldDeletedAt:
  22790. return m.DeletedAt()
  22791. case tutorial.FieldEmployeeID:
  22792. return m.EmployeeID()
  22793. case tutorial.FieldIndex:
  22794. return m.Index()
  22795. case tutorial.FieldTitle:
  22796. return m.Title()
  22797. case tutorial.FieldContent:
  22798. return m.Content()
  22799. case tutorial.FieldOrganizationID:
  22800. return m.OrganizationID()
  22801. }
  22802. return nil, false
  22803. }
  22804. // OldField returns the old value of the field from the database. An error is
  22805. // returned if the mutation operation is not UpdateOne, or the query to the
  22806. // database failed.
  22807. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22808. switch name {
  22809. case tutorial.FieldCreatedAt:
  22810. return m.OldCreatedAt(ctx)
  22811. case tutorial.FieldUpdatedAt:
  22812. return m.OldUpdatedAt(ctx)
  22813. case tutorial.FieldDeletedAt:
  22814. return m.OldDeletedAt(ctx)
  22815. case tutorial.FieldEmployeeID:
  22816. return m.OldEmployeeID(ctx)
  22817. case tutorial.FieldIndex:
  22818. return m.OldIndex(ctx)
  22819. case tutorial.FieldTitle:
  22820. return m.OldTitle(ctx)
  22821. case tutorial.FieldContent:
  22822. return m.OldContent(ctx)
  22823. case tutorial.FieldOrganizationID:
  22824. return m.OldOrganizationID(ctx)
  22825. }
  22826. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  22827. }
  22828. // SetField sets the value of a field with the given name. It returns an error if
  22829. // the field is not defined in the schema, or if the type mismatched the field
  22830. // type.
  22831. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  22832. switch name {
  22833. case tutorial.FieldCreatedAt:
  22834. v, ok := value.(time.Time)
  22835. if !ok {
  22836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22837. }
  22838. m.SetCreatedAt(v)
  22839. return nil
  22840. case tutorial.FieldUpdatedAt:
  22841. v, ok := value.(time.Time)
  22842. if !ok {
  22843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22844. }
  22845. m.SetUpdatedAt(v)
  22846. return nil
  22847. case tutorial.FieldDeletedAt:
  22848. v, ok := value.(time.Time)
  22849. if !ok {
  22850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22851. }
  22852. m.SetDeletedAt(v)
  22853. return nil
  22854. case tutorial.FieldEmployeeID:
  22855. v, ok := value.(uint64)
  22856. if !ok {
  22857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22858. }
  22859. m.SetEmployeeID(v)
  22860. return nil
  22861. case tutorial.FieldIndex:
  22862. v, ok := value.(int)
  22863. if !ok {
  22864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22865. }
  22866. m.SetIndex(v)
  22867. return nil
  22868. case tutorial.FieldTitle:
  22869. v, ok := value.(string)
  22870. if !ok {
  22871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22872. }
  22873. m.SetTitle(v)
  22874. return nil
  22875. case tutorial.FieldContent:
  22876. v, ok := value.(string)
  22877. if !ok {
  22878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22879. }
  22880. m.SetContent(v)
  22881. return nil
  22882. case tutorial.FieldOrganizationID:
  22883. v, ok := value.(uint64)
  22884. if !ok {
  22885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22886. }
  22887. m.SetOrganizationID(v)
  22888. return nil
  22889. }
  22890. return fmt.Errorf("unknown Tutorial field %s", name)
  22891. }
  22892. // AddedFields returns all numeric fields that were incremented/decremented during
  22893. // this mutation.
  22894. func (m *TutorialMutation) AddedFields() []string {
  22895. var fields []string
  22896. if m.addindex != nil {
  22897. fields = append(fields, tutorial.FieldIndex)
  22898. }
  22899. if m.addorganization_id != nil {
  22900. fields = append(fields, tutorial.FieldOrganizationID)
  22901. }
  22902. return fields
  22903. }
  22904. // AddedField returns the numeric value that was incremented/decremented on a field
  22905. // with the given name. The second boolean return value indicates that this field
  22906. // was not set, or was not defined in the schema.
  22907. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  22908. switch name {
  22909. case tutorial.FieldIndex:
  22910. return m.AddedIndex()
  22911. case tutorial.FieldOrganizationID:
  22912. return m.AddedOrganizationID()
  22913. }
  22914. return nil, false
  22915. }
  22916. // AddField adds the value to the field with the given name. It returns an error if
  22917. // the field is not defined in the schema, or if the type mismatched the field
  22918. // type.
  22919. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  22920. switch name {
  22921. case tutorial.FieldIndex:
  22922. v, ok := value.(int)
  22923. if !ok {
  22924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22925. }
  22926. m.AddIndex(v)
  22927. return nil
  22928. case tutorial.FieldOrganizationID:
  22929. v, ok := value.(int64)
  22930. if !ok {
  22931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22932. }
  22933. m.AddOrganizationID(v)
  22934. return nil
  22935. }
  22936. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  22937. }
  22938. // ClearedFields returns all nullable fields that were cleared during this
  22939. // mutation.
  22940. func (m *TutorialMutation) ClearedFields() []string {
  22941. var fields []string
  22942. if m.FieldCleared(tutorial.FieldDeletedAt) {
  22943. fields = append(fields, tutorial.FieldDeletedAt)
  22944. }
  22945. return fields
  22946. }
  22947. // FieldCleared returns a boolean indicating if a field with the given name was
  22948. // cleared in this mutation.
  22949. func (m *TutorialMutation) FieldCleared(name string) bool {
  22950. _, ok := m.clearedFields[name]
  22951. return ok
  22952. }
  22953. // ClearField clears the value of the field with the given name. It returns an
  22954. // error if the field is not defined in the schema.
  22955. func (m *TutorialMutation) ClearField(name string) error {
  22956. switch name {
  22957. case tutorial.FieldDeletedAt:
  22958. m.ClearDeletedAt()
  22959. return nil
  22960. }
  22961. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  22962. }
  22963. // ResetField resets all changes in the mutation for the field with the given name.
  22964. // It returns an error if the field is not defined in the schema.
  22965. func (m *TutorialMutation) ResetField(name string) error {
  22966. switch name {
  22967. case tutorial.FieldCreatedAt:
  22968. m.ResetCreatedAt()
  22969. return nil
  22970. case tutorial.FieldUpdatedAt:
  22971. m.ResetUpdatedAt()
  22972. return nil
  22973. case tutorial.FieldDeletedAt:
  22974. m.ResetDeletedAt()
  22975. return nil
  22976. case tutorial.FieldEmployeeID:
  22977. m.ResetEmployeeID()
  22978. return nil
  22979. case tutorial.FieldIndex:
  22980. m.ResetIndex()
  22981. return nil
  22982. case tutorial.FieldTitle:
  22983. m.ResetTitle()
  22984. return nil
  22985. case tutorial.FieldContent:
  22986. m.ResetContent()
  22987. return nil
  22988. case tutorial.FieldOrganizationID:
  22989. m.ResetOrganizationID()
  22990. return nil
  22991. }
  22992. return fmt.Errorf("unknown Tutorial field %s", name)
  22993. }
  22994. // AddedEdges returns all edge names that were set/added in this mutation.
  22995. func (m *TutorialMutation) AddedEdges() []string {
  22996. edges := make([]string, 0, 1)
  22997. if m.employee != nil {
  22998. edges = append(edges, tutorial.EdgeEmployee)
  22999. }
  23000. return edges
  23001. }
  23002. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23003. // name in this mutation.
  23004. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  23005. switch name {
  23006. case tutorial.EdgeEmployee:
  23007. if id := m.employee; id != nil {
  23008. return []ent.Value{*id}
  23009. }
  23010. }
  23011. return nil
  23012. }
  23013. // RemovedEdges returns all edge names that were removed in this mutation.
  23014. func (m *TutorialMutation) RemovedEdges() []string {
  23015. edges := make([]string, 0, 1)
  23016. return edges
  23017. }
  23018. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23019. // the given name in this mutation.
  23020. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  23021. return nil
  23022. }
  23023. // ClearedEdges returns all edge names that were cleared in this mutation.
  23024. func (m *TutorialMutation) ClearedEdges() []string {
  23025. edges := make([]string, 0, 1)
  23026. if m.clearedemployee {
  23027. edges = append(edges, tutorial.EdgeEmployee)
  23028. }
  23029. return edges
  23030. }
  23031. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23032. // was cleared in this mutation.
  23033. func (m *TutorialMutation) EdgeCleared(name string) bool {
  23034. switch name {
  23035. case tutorial.EdgeEmployee:
  23036. return m.clearedemployee
  23037. }
  23038. return false
  23039. }
  23040. // ClearEdge clears the value of the edge with the given name. It returns an error
  23041. // if that edge is not defined in the schema.
  23042. func (m *TutorialMutation) ClearEdge(name string) error {
  23043. switch name {
  23044. case tutorial.EdgeEmployee:
  23045. m.ClearEmployee()
  23046. return nil
  23047. }
  23048. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  23049. }
  23050. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23051. // It returns an error if the edge is not defined in the schema.
  23052. func (m *TutorialMutation) ResetEdge(name string) error {
  23053. switch name {
  23054. case tutorial.EdgeEmployee:
  23055. m.ResetEmployee()
  23056. return nil
  23057. }
  23058. return fmt.Errorf("unknown Tutorial edge %s", name)
  23059. }
  23060. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  23061. type UsageDetailMutation struct {
  23062. config
  23063. op Op
  23064. typ string
  23065. id *uint64
  23066. created_at *time.Time
  23067. updated_at *time.Time
  23068. status *uint8
  23069. addstatus *int8
  23070. _type *int
  23071. add_type *int
  23072. bot_id *string
  23073. receiver_id *string
  23074. app *int
  23075. addapp *int
  23076. session_id *uint64
  23077. addsession_id *int64
  23078. request *string
  23079. response *string
  23080. total_tokens *uint64
  23081. addtotal_tokens *int64
  23082. prompt_tokens *uint64
  23083. addprompt_tokens *int64
  23084. completion_tokens *uint64
  23085. addcompletion_tokens *int64
  23086. organization_id *uint64
  23087. addorganization_id *int64
  23088. clearedFields map[string]struct{}
  23089. done bool
  23090. oldValue func(context.Context) (*UsageDetail, error)
  23091. predicates []predicate.UsageDetail
  23092. }
  23093. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  23094. // usagedetailOption allows management of the mutation configuration using functional options.
  23095. type usagedetailOption func(*UsageDetailMutation)
  23096. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  23097. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  23098. m := &UsageDetailMutation{
  23099. config: c,
  23100. op: op,
  23101. typ: TypeUsageDetail,
  23102. clearedFields: make(map[string]struct{}),
  23103. }
  23104. for _, opt := range opts {
  23105. opt(m)
  23106. }
  23107. return m
  23108. }
  23109. // withUsageDetailID sets the ID field of the mutation.
  23110. func withUsageDetailID(id uint64) usagedetailOption {
  23111. return func(m *UsageDetailMutation) {
  23112. var (
  23113. err error
  23114. once sync.Once
  23115. value *UsageDetail
  23116. )
  23117. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  23118. once.Do(func() {
  23119. if m.done {
  23120. err = errors.New("querying old values post mutation is not allowed")
  23121. } else {
  23122. value, err = m.Client().UsageDetail.Get(ctx, id)
  23123. }
  23124. })
  23125. return value, err
  23126. }
  23127. m.id = &id
  23128. }
  23129. }
  23130. // withUsageDetail sets the old UsageDetail of the mutation.
  23131. func withUsageDetail(node *UsageDetail) usagedetailOption {
  23132. return func(m *UsageDetailMutation) {
  23133. m.oldValue = func(context.Context) (*UsageDetail, error) {
  23134. return node, nil
  23135. }
  23136. m.id = &node.ID
  23137. }
  23138. }
  23139. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23140. // executed in a transaction (ent.Tx), a transactional client is returned.
  23141. func (m UsageDetailMutation) Client() *Client {
  23142. client := &Client{config: m.config}
  23143. client.init()
  23144. return client
  23145. }
  23146. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23147. // it returns an error otherwise.
  23148. func (m UsageDetailMutation) Tx() (*Tx, error) {
  23149. if _, ok := m.driver.(*txDriver); !ok {
  23150. return nil, errors.New("ent: mutation is not running in a transaction")
  23151. }
  23152. tx := &Tx{config: m.config}
  23153. tx.init()
  23154. return tx, nil
  23155. }
  23156. // SetID sets the value of the id field. Note that this
  23157. // operation is only accepted on creation of UsageDetail entities.
  23158. func (m *UsageDetailMutation) SetID(id uint64) {
  23159. m.id = &id
  23160. }
  23161. // ID returns the ID value in the mutation. Note that the ID is only available
  23162. // if it was provided to the builder or after it was returned from the database.
  23163. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  23164. if m.id == nil {
  23165. return
  23166. }
  23167. return *m.id, true
  23168. }
  23169. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23170. // That means, if the mutation is applied within a transaction with an isolation level such
  23171. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23172. // or updated by the mutation.
  23173. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  23174. switch {
  23175. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23176. id, exists := m.ID()
  23177. if exists {
  23178. return []uint64{id}, nil
  23179. }
  23180. fallthrough
  23181. case m.op.Is(OpUpdate | OpDelete):
  23182. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  23183. default:
  23184. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23185. }
  23186. }
  23187. // SetCreatedAt sets the "created_at" field.
  23188. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  23189. m.created_at = &t
  23190. }
  23191. // CreatedAt returns the value of the "created_at" field in the mutation.
  23192. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  23193. v := m.created_at
  23194. if v == nil {
  23195. return
  23196. }
  23197. return *v, true
  23198. }
  23199. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  23200. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23202. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23203. if !m.op.Is(OpUpdateOne) {
  23204. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23205. }
  23206. if m.id == nil || m.oldValue == nil {
  23207. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23208. }
  23209. oldValue, err := m.oldValue(ctx)
  23210. if err != nil {
  23211. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23212. }
  23213. return oldValue.CreatedAt, nil
  23214. }
  23215. // ResetCreatedAt resets all changes to the "created_at" field.
  23216. func (m *UsageDetailMutation) ResetCreatedAt() {
  23217. m.created_at = nil
  23218. }
  23219. // SetUpdatedAt sets the "updated_at" field.
  23220. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  23221. m.updated_at = &t
  23222. }
  23223. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23224. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  23225. v := m.updated_at
  23226. if v == nil {
  23227. return
  23228. }
  23229. return *v, true
  23230. }
  23231. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  23232. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23234. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23235. if !m.op.Is(OpUpdateOne) {
  23236. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23237. }
  23238. if m.id == nil || m.oldValue == nil {
  23239. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23240. }
  23241. oldValue, err := m.oldValue(ctx)
  23242. if err != nil {
  23243. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23244. }
  23245. return oldValue.UpdatedAt, nil
  23246. }
  23247. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23248. func (m *UsageDetailMutation) ResetUpdatedAt() {
  23249. m.updated_at = nil
  23250. }
  23251. // SetStatus sets the "status" field.
  23252. func (m *UsageDetailMutation) SetStatus(u uint8) {
  23253. m.status = &u
  23254. m.addstatus = nil
  23255. }
  23256. // Status returns the value of the "status" field in the mutation.
  23257. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  23258. v := m.status
  23259. if v == nil {
  23260. return
  23261. }
  23262. return *v, true
  23263. }
  23264. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  23265. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23267. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23268. if !m.op.Is(OpUpdateOne) {
  23269. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23270. }
  23271. if m.id == nil || m.oldValue == nil {
  23272. return v, errors.New("OldStatus requires an ID field in the mutation")
  23273. }
  23274. oldValue, err := m.oldValue(ctx)
  23275. if err != nil {
  23276. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23277. }
  23278. return oldValue.Status, nil
  23279. }
  23280. // AddStatus adds u to the "status" field.
  23281. func (m *UsageDetailMutation) AddStatus(u int8) {
  23282. if m.addstatus != nil {
  23283. *m.addstatus += u
  23284. } else {
  23285. m.addstatus = &u
  23286. }
  23287. }
  23288. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23289. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  23290. v := m.addstatus
  23291. if v == nil {
  23292. return
  23293. }
  23294. return *v, true
  23295. }
  23296. // ClearStatus clears the value of the "status" field.
  23297. func (m *UsageDetailMutation) ClearStatus() {
  23298. m.status = nil
  23299. m.addstatus = nil
  23300. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  23301. }
  23302. // StatusCleared returns if the "status" field was cleared in this mutation.
  23303. func (m *UsageDetailMutation) StatusCleared() bool {
  23304. _, ok := m.clearedFields[usagedetail.FieldStatus]
  23305. return ok
  23306. }
  23307. // ResetStatus resets all changes to the "status" field.
  23308. func (m *UsageDetailMutation) ResetStatus() {
  23309. m.status = nil
  23310. m.addstatus = nil
  23311. delete(m.clearedFields, usagedetail.FieldStatus)
  23312. }
  23313. // SetType sets the "type" field.
  23314. func (m *UsageDetailMutation) SetType(i int) {
  23315. m._type = &i
  23316. m.add_type = nil
  23317. }
  23318. // GetType returns the value of the "type" field in the mutation.
  23319. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  23320. v := m._type
  23321. if v == nil {
  23322. return
  23323. }
  23324. return *v, true
  23325. }
  23326. // OldType returns the old "type" field's value of the UsageDetail entity.
  23327. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23329. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  23330. if !m.op.Is(OpUpdateOne) {
  23331. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23332. }
  23333. if m.id == nil || m.oldValue == nil {
  23334. return v, errors.New("OldType requires an ID field in the mutation")
  23335. }
  23336. oldValue, err := m.oldValue(ctx)
  23337. if err != nil {
  23338. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23339. }
  23340. return oldValue.Type, nil
  23341. }
  23342. // AddType adds i to the "type" field.
  23343. func (m *UsageDetailMutation) AddType(i int) {
  23344. if m.add_type != nil {
  23345. *m.add_type += i
  23346. } else {
  23347. m.add_type = &i
  23348. }
  23349. }
  23350. // AddedType returns the value that was added to the "type" field in this mutation.
  23351. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  23352. v := m.add_type
  23353. if v == nil {
  23354. return
  23355. }
  23356. return *v, true
  23357. }
  23358. // ClearType clears the value of the "type" field.
  23359. func (m *UsageDetailMutation) ClearType() {
  23360. m._type = nil
  23361. m.add_type = nil
  23362. m.clearedFields[usagedetail.FieldType] = struct{}{}
  23363. }
  23364. // TypeCleared returns if the "type" field was cleared in this mutation.
  23365. func (m *UsageDetailMutation) TypeCleared() bool {
  23366. _, ok := m.clearedFields[usagedetail.FieldType]
  23367. return ok
  23368. }
  23369. // ResetType resets all changes to the "type" field.
  23370. func (m *UsageDetailMutation) ResetType() {
  23371. m._type = nil
  23372. m.add_type = nil
  23373. delete(m.clearedFields, usagedetail.FieldType)
  23374. }
  23375. // SetBotID sets the "bot_id" field.
  23376. func (m *UsageDetailMutation) SetBotID(s string) {
  23377. m.bot_id = &s
  23378. }
  23379. // BotID returns the value of the "bot_id" field in the mutation.
  23380. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  23381. v := m.bot_id
  23382. if v == nil {
  23383. return
  23384. }
  23385. return *v, true
  23386. }
  23387. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  23388. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23390. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  23391. if !m.op.Is(OpUpdateOne) {
  23392. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  23393. }
  23394. if m.id == nil || m.oldValue == nil {
  23395. return v, errors.New("OldBotID requires an ID field in the mutation")
  23396. }
  23397. oldValue, err := m.oldValue(ctx)
  23398. if err != nil {
  23399. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  23400. }
  23401. return oldValue.BotID, nil
  23402. }
  23403. // ResetBotID resets all changes to the "bot_id" field.
  23404. func (m *UsageDetailMutation) ResetBotID() {
  23405. m.bot_id = nil
  23406. }
  23407. // SetReceiverID sets the "receiver_id" field.
  23408. func (m *UsageDetailMutation) SetReceiverID(s string) {
  23409. m.receiver_id = &s
  23410. }
  23411. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  23412. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  23413. v := m.receiver_id
  23414. if v == nil {
  23415. return
  23416. }
  23417. return *v, true
  23418. }
  23419. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  23420. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23422. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  23423. if !m.op.Is(OpUpdateOne) {
  23424. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  23425. }
  23426. if m.id == nil || m.oldValue == nil {
  23427. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  23428. }
  23429. oldValue, err := m.oldValue(ctx)
  23430. if err != nil {
  23431. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  23432. }
  23433. return oldValue.ReceiverID, nil
  23434. }
  23435. // ResetReceiverID resets all changes to the "receiver_id" field.
  23436. func (m *UsageDetailMutation) ResetReceiverID() {
  23437. m.receiver_id = nil
  23438. }
  23439. // SetApp sets the "app" field.
  23440. func (m *UsageDetailMutation) SetApp(i int) {
  23441. m.app = &i
  23442. m.addapp = nil
  23443. }
  23444. // App returns the value of the "app" field in the mutation.
  23445. func (m *UsageDetailMutation) App() (r int, exists bool) {
  23446. v := m.app
  23447. if v == nil {
  23448. return
  23449. }
  23450. return *v, true
  23451. }
  23452. // OldApp returns the old "app" field's value of the UsageDetail entity.
  23453. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23455. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  23456. if !m.op.Is(OpUpdateOne) {
  23457. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  23458. }
  23459. if m.id == nil || m.oldValue == nil {
  23460. return v, errors.New("OldApp requires an ID field in the mutation")
  23461. }
  23462. oldValue, err := m.oldValue(ctx)
  23463. if err != nil {
  23464. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  23465. }
  23466. return oldValue.App, nil
  23467. }
  23468. // AddApp adds i to the "app" field.
  23469. func (m *UsageDetailMutation) AddApp(i int) {
  23470. if m.addapp != nil {
  23471. *m.addapp += i
  23472. } else {
  23473. m.addapp = &i
  23474. }
  23475. }
  23476. // AddedApp returns the value that was added to the "app" field in this mutation.
  23477. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  23478. v := m.addapp
  23479. if v == nil {
  23480. return
  23481. }
  23482. return *v, true
  23483. }
  23484. // ClearApp clears the value of the "app" field.
  23485. func (m *UsageDetailMutation) ClearApp() {
  23486. m.app = nil
  23487. m.addapp = nil
  23488. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  23489. }
  23490. // AppCleared returns if the "app" field was cleared in this mutation.
  23491. func (m *UsageDetailMutation) AppCleared() bool {
  23492. _, ok := m.clearedFields[usagedetail.FieldApp]
  23493. return ok
  23494. }
  23495. // ResetApp resets all changes to the "app" field.
  23496. func (m *UsageDetailMutation) ResetApp() {
  23497. m.app = nil
  23498. m.addapp = nil
  23499. delete(m.clearedFields, usagedetail.FieldApp)
  23500. }
  23501. // SetSessionID sets the "session_id" field.
  23502. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  23503. m.session_id = &u
  23504. m.addsession_id = nil
  23505. }
  23506. // SessionID returns the value of the "session_id" field in the mutation.
  23507. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  23508. v := m.session_id
  23509. if v == nil {
  23510. return
  23511. }
  23512. return *v, true
  23513. }
  23514. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  23515. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23517. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  23518. if !m.op.Is(OpUpdateOne) {
  23519. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  23520. }
  23521. if m.id == nil || m.oldValue == nil {
  23522. return v, errors.New("OldSessionID requires an ID field in the mutation")
  23523. }
  23524. oldValue, err := m.oldValue(ctx)
  23525. if err != nil {
  23526. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  23527. }
  23528. return oldValue.SessionID, nil
  23529. }
  23530. // AddSessionID adds u to the "session_id" field.
  23531. func (m *UsageDetailMutation) AddSessionID(u int64) {
  23532. if m.addsession_id != nil {
  23533. *m.addsession_id += u
  23534. } else {
  23535. m.addsession_id = &u
  23536. }
  23537. }
  23538. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  23539. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  23540. v := m.addsession_id
  23541. if v == nil {
  23542. return
  23543. }
  23544. return *v, true
  23545. }
  23546. // ClearSessionID clears the value of the "session_id" field.
  23547. func (m *UsageDetailMutation) ClearSessionID() {
  23548. m.session_id = nil
  23549. m.addsession_id = nil
  23550. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  23551. }
  23552. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  23553. func (m *UsageDetailMutation) SessionIDCleared() bool {
  23554. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  23555. return ok
  23556. }
  23557. // ResetSessionID resets all changes to the "session_id" field.
  23558. func (m *UsageDetailMutation) ResetSessionID() {
  23559. m.session_id = nil
  23560. m.addsession_id = nil
  23561. delete(m.clearedFields, usagedetail.FieldSessionID)
  23562. }
  23563. // SetRequest sets the "request" field.
  23564. func (m *UsageDetailMutation) SetRequest(s string) {
  23565. m.request = &s
  23566. }
  23567. // Request returns the value of the "request" field in the mutation.
  23568. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  23569. v := m.request
  23570. if v == nil {
  23571. return
  23572. }
  23573. return *v, true
  23574. }
  23575. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  23576. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23578. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  23579. if !m.op.Is(OpUpdateOne) {
  23580. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  23581. }
  23582. if m.id == nil || m.oldValue == nil {
  23583. return v, errors.New("OldRequest requires an ID field in the mutation")
  23584. }
  23585. oldValue, err := m.oldValue(ctx)
  23586. if err != nil {
  23587. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  23588. }
  23589. return oldValue.Request, nil
  23590. }
  23591. // ResetRequest resets all changes to the "request" field.
  23592. func (m *UsageDetailMutation) ResetRequest() {
  23593. m.request = nil
  23594. }
  23595. // SetResponse sets the "response" field.
  23596. func (m *UsageDetailMutation) SetResponse(s string) {
  23597. m.response = &s
  23598. }
  23599. // Response returns the value of the "response" field in the mutation.
  23600. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  23601. v := m.response
  23602. if v == nil {
  23603. return
  23604. }
  23605. return *v, true
  23606. }
  23607. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  23608. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23610. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  23611. if !m.op.Is(OpUpdateOne) {
  23612. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  23613. }
  23614. if m.id == nil || m.oldValue == nil {
  23615. return v, errors.New("OldResponse requires an ID field in the mutation")
  23616. }
  23617. oldValue, err := m.oldValue(ctx)
  23618. if err != nil {
  23619. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  23620. }
  23621. return oldValue.Response, nil
  23622. }
  23623. // ResetResponse resets all changes to the "response" field.
  23624. func (m *UsageDetailMutation) ResetResponse() {
  23625. m.response = nil
  23626. }
  23627. // SetTotalTokens sets the "total_tokens" field.
  23628. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  23629. m.total_tokens = &u
  23630. m.addtotal_tokens = nil
  23631. }
  23632. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  23633. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  23634. v := m.total_tokens
  23635. if v == nil {
  23636. return
  23637. }
  23638. return *v, true
  23639. }
  23640. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  23641. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23643. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  23644. if !m.op.Is(OpUpdateOne) {
  23645. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  23646. }
  23647. if m.id == nil || m.oldValue == nil {
  23648. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  23649. }
  23650. oldValue, err := m.oldValue(ctx)
  23651. if err != nil {
  23652. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  23653. }
  23654. return oldValue.TotalTokens, nil
  23655. }
  23656. // AddTotalTokens adds u to the "total_tokens" field.
  23657. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  23658. if m.addtotal_tokens != nil {
  23659. *m.addtotal_tokens += u
  23660. } else {
  23661. m.addtotal_tokens = &u
  23662. }
  23663. }
  23664. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  23665. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  23666. v := m.addtotal_tokens
  23667. if v == nil {
  23668. return
  23669. }
  23670. return *v, true
  23671. }
  23672. // ClearTotalTokens clears the value of the "total_tokens" field.
  23673. func (m *UsageDetailMutation) ClearTotalTokens() {
  23674. m.total_tokens = nil
  23675. m.addtotal_tokens = nil
  23676. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  23677. }
  23678. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  23679. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  23680. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  23681. return ok
  23682. }
  23683. // ResetTotalTokens resets all changes to the "total_tokens" field.
  23684. func (m *UsageDetailMutation) ResetTotalTokens() {
  23685. m.total_tokens = nil
  23686. m.addtotal_tokens = nil
  23687. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  23688. }
  23689. // SetPromptTokens sets the "prompt_tokens" field.
  23690. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  23691. m.prompt_tokens = &u
  23692. m.addprompt_tokens = nil
  23693. }
  23694. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  23695. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  23696. v := m.prompt_tokens
  23697. if v == nil {
  23698. return
  23699. }
  23700. return *v, true
  23701. }
  23702. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  23703. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23705. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  23706. if !m.op.Is(OpUpdateOne) {
  23707. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  23708. }
  23709. if m.id == nil || m.oldValue == nil {
  23710. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  23711. }
  23712. oldValue, err := m.oldValue(ctx)
  23713. if err != nil {
  23714. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  23715. }
  23716. return oldValue.PromptTokens, nil
  23717. }
  23718. // AddPromptTokens adds u to the "prompt_tokens" field.
  23719. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  23720. if m.addprompt_tokens != nil {
  23721. *m.addprompt_tokens += u
  23722. } else {
  23723. m.addprompt_tokens = &u
  23724. }
  23725. }
  23726. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  23727. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  23728. v := m.addprompt_tokens
  23729. if v == nil {
  23730. return
  23731. }
  23732. return *v, true
  23733. }
  23734. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  23735. func (m *UsageDetailMutation) ClearPromptTokens() {
  23736. m.prompt_tokens = nil
  23737. m.addprompt_tokens = nil
  23738. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  23739. }
  23740. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  23741. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  23742. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  23743. return ok
  23744. }
  23745. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  23746. func (m *UsageDetailMutation) ResetPromptTokens() {
  23747. m.prompt_tokens = nil
  23748. m.addprompt_tokens = nil
  23749. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  23750. }
  23751. // SetCompletionTokens sets the "completion_tokens" field.
  23752. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  23753. m.completion_tokens = &u
  23754. m.addcompletion_tokens = nil
  23755. }
  23756. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  23757. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  23758. v := m.completion_tokens
  23759. if v == nil {
  23760. return
  23761. }
  23762. return *v, true
  23763. }
  23764. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  23765. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23767. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  23768. if !m.op.Is(OpUpdateOne) {
  23769. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  23770. }
  23771. if m.id == nil || m.oldValue == nil {
  23772. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  23773. }
  23774. oldValue, err := m.oldValue(ctx)
  23775. if err != nil {
  23776. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  23777. }
  23778. return oldValue.CompletionTokens, nil
  23779. }
  23780. // AddCompletionTokens adds u to the "completion_tokens" field.
  23781. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  23782. if m.addcompletion_tokens != nil {
  23783. *m.addcompletion_tokens += u
  23784. } else {
  23785. m.addcompletion_tokens = &u
  23786. }
  23787. }
  23788. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  23789. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  23790. v := m.addcompletion_tokens
  23791. if v == nil {
  23792. return
  23793. }
  23794. return *v, true
  23795. }
  23796. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  23797. func (m *UsageDetailMutation) ClearCompletionTokens() {
  23798. m.completion_tokens = nil
  23799. m.addcompletion_tokens = nil
  23800. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  23801. }
  23802. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  23803. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  23804. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  23805. return ok
  23806. }
  23807. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  23808. func (m *UsageDetailMutation) ResetCompletionTokens() {
  23809. m.completion_tokens = nil
  23810. m.addcompletion_tokens = nil
  23811. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  23812. }
  23813. // SetOrganizationID sets the "organization_id" field.
  23814. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  23815. m.organization_id = &u
  23816. m.addorganization_id = nil
  23817. }
  23818. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23819. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  23820. v := m.organization_id
  23821. if v == nil {
  23822. return
  23823. }
  23824. return *v, true
  23825. }
  23826. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  23827. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23829. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23830. if !m.op.Is(OpUpdateOne) {
  23831. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23832. }
  23833. if m.id == nil || m.oldValue == nil {
  23834. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23835. }
  23836. oldValue, err := m.oldValue(ctx)
  23837. if err != nil {
  23838. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23839. }
  23840. return oldValue.OrganizationID, nil
  23841. }
  23842. // AddOrganizationID adds u to the "organization_id" field.
  23843. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  23844. if m.addorganization_id != nil {
  23845. *m.addorganization_id += u
  23846. } else {
  23847. m.addorganization_id = &u
  23848. }
  23849. }
  23850. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23851. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  23852. v := m.addorganization_id
  23853. if v == nil {
  23854. return
  23855. }
  23856. return *v, true
  23857. }
  23858. // ClearOrganizationID clears the value of the "organization_id" field.
  23859. func (m *UsageDetailMutation) ClearOrganizationID() {
  23860. m.organization_id = nil
  23861. m.addorganization_id = nil
  23862. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  23863. }
  23864. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23865. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  23866. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  23867. return ok
  23868. }
  23869. // ResetOrganizationID resets all changes to the "organization_id" field.
  23870. func (m *UsageDetailMutation) ResetOrganizationID() {
  23871. m.organization_id = nil
  23872. m.addorganization_id = nil
  23873. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  23874. }
  23875. // Where appends a list predicates to the UsageDetailMutation builder.
  23876. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  23877. m.predicates = append(m.predicates, ps...)
  23878. }
  23879. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  23880. // users can use type-assertion to append predicates that do not depend on any generated package.
  23881. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  23882. p := make([]predicate.UsageDetail, len(ps))
  23883. for i := range ps {
  23884. p[i] = ps[i]
  23885. }
  23886. m.Where(p...)
  23887. }
  23888. // Op returns the operation name.
  23889. func (m *UsageDetailMutation) Op() Op {
  23890. return m.op
  23891. }
  23892. // SetOp allows setting the mutation operation.
  23893. func (m *UsageDetailMutation) SetOp(op Op) {
  23894. m.op = op
  23895. }
  23896. // Type returns the node type of this mutation (UsageDetail).
  23897. func (m *UsageDetailMutation) Type() string {
  23898. return m.typ
  23899. }
  23900. // Fields returns all fields that were changed during this mutation. Note that in
  23901. // order to get all numeric fields that were incremented/decremented, call
  23902. // AddedFields().
  23903. func (m *UsageDetailMutation) Fields() []string {
  23904. fields := make([]string, 0, 14)
  23905. if m.created_at != nil {
  23906. fields = append(fields, usagedetail.FieldCreatedAt)
  23907. }
  23908. if m.updated_at != nil {
  23909. fields = append(fields, usagedetail.FieldUpdatedAt)
  23910. }
  23911. if m.status != nil {
  23912. fields = append(fields, usagedetail.FieldStatus)
  23913. }
  23914. if m._type != nil {
  23915. fields = append(fields, usagedetail.FieldType)
  23916. }
  23917. if m.bot_id != nil {
  23918. fields = append(fields, usagedetail.FieldBotID)
  23919. }
  23920. if m.receiver_id != nil {
  23921. fields = append(fields, usagedetail.FieldReceiverID)
  23922. }
  23923. if m.app != nil {
  23924. fields = append(fields, usagedetail.FieldApp)
  23925. }
  23926. if m.session_id != nil {
  23927. fields = append(fields, usagedetail.FieldSessionID)
  23928. }
  23929. if m.request != nil {
  23930. fields = append(fields, usagedetail.FieldRequest)
  23931. }
  23932. if m.response != nil {
  23933. fields = append(fields, usagedetail.FieldResponse)
  23934. }
  23935. if m.total_tokens != nil {
  23936. fields = append(fields, usagedetail.FieldTotalTokens)
  23937. }
  23938. if m.prompt_tokens != nil {
  23939. fields = append(fields, usagedetail.FieldPromptTokens)
  23940. }
  23941. if m.completion_tokens != nil {
  23942. fields = append(fields, usagedetail.FieldCompletionTokens)
  23943. }
  23944. if m.organization_id != nil {
  23945. fields = append(fields, usagedetail.FieldOrganizationID)
  23946. }
  23947. return fields
  23948. }
  23949. // Field returns the value of a field with the given name. The second boolean
  23950. // return value indicates that this field was not set, or was not defined in the
  23951. // schema.
  23952. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  23953. switch name {
  23954. case usagedetail.FieldCreatedAt:
  23955. return m.CreatedAt()
  23956. case usagedetail.FieldUpdatedAt:
  23957. return m.UpdatedAt()
  23958. case usagedetail.FieldStatus:
  23959. return m.Status()
  23960. case usagedetail.FieldType:
  23961. return m.GetType()
  23962. case usagedetail.FieldBotID:
  23963. return m.BotID()
  23964. case usagedetail.FieldReceiverID:
  23965. return m.ReceiverID()
  23966. case usagedetail.FieldApp:
  23967. return m.App()
  23968. case usagedetail.FieldSessionID:
  23969. return m.SessionID()
  23970. case usagedetail.FieldRequest:
  23971. return m.Request()
  23972. case usagedetail.FieldResponse:
  23973. return m.Response()
  23974. case usagedetail.FieldTotalTokens:
  23975. return m.TotalTokens()
  23976. case usagedetail.FieldPromptTokens:
  23977. return m.PromptTokens()
  23978. case usagedetail.FieldCompletionTokens:
  23979. return m.CompletionTokens()
  23980. case usagedetail.FieldOrganizationID:
  23981. return m.OrganizationID()
  23982. }
  23983. return nil, false
  23984. }
  23985. // OldField returns the old value of the field from the database. An error is
  23986. // returned if the mutation operation is not UpdateOne, or the query to the
  23987. // database failed.
  23988. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23989. switch name {
  23990. case usagedetail.FieldCreatedAt:
  23991. return m.OldCreatedAt(ctx)
  23992. case usagedetail.FieldUpdatedAt:
  23993. return m.OldUpdatedAt(ctx)
  23994. case usagedetail.FieldStatus:
  23995. return m.OldStatus(ctx)
  23996. case usagedetail.FieldType:
  23997. return m.OldType(ctx)
  23998. case usagedetail.FieldBotID:
  23999. return m.OldBotID(ctx)
  24000. case usagedetail.FieldReceiverID:
  24001. return m.OldReceiverID(ctx)
  24002. case usagedetail.FieldApp:
  24003. return m.OldApp(ctx)
  24004. case usagedetail.FieldSessionID:
  24005. return m.OldSessionID(ctx)
  24006. case usagedetail.FieldRequest:
  24007. return m.OldRequest(ctx)
  24008. case usagedetail.FieldResponse:
  24009. return m.OldResponse(ctx)
  24010. case usagedetail.FieldTotalTokens:
  24011. return m.OldTotalTokens(ctx)
  24012. case usagedetail.FieldPromptTokens:
  24013. return m.OldPromptTokens(ctx)
  24014. case usagedetail.FieldCompletionTokens:
  24015. return m.OldCompletionTokens(ctx)
  24016. case usagedetail.FieldOrganizationID:
  24017. return m.OldOrganizationID(ctx)
  24018. }
  24019. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  24020. }
  24021. // SetField sets the value of a field with the given name. It returns an error if
  24022. // the field is not defined in the schema, or if the type mismatched the field
  24023. // type.
  24024. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  24025. switch name {
  24026. case usagedetail.FieldCreatedAt:
  24027. v, ok := value.(time.Time)
  24028. if !ok {
  24029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24030. }
  24031. m.SetCreatedAt(v)
  24032. return nil
  24033. case usagedetail.FieldUpdatedAt:
  24034. v, ok := value.(time.Time)
  24035. if !ok {
  24036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24037. }
  24038. m.SetUpdatedAt(v)
  24039. return nil
  24040. case usagedetail.FieldStatus:
  24041. v, ok := value.(uint8)
  24042. if !ok {
  24043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24044. }
  24045. m.SetStatus(v)
  24046. return nil
  24047. case usagedetail.FieldType:
  24048. v, ok := value.(int)
  24049. if !ok {
  24050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24051. }
  24052. m.SetType(v)
  24053. return nil
  24054. case usagedetail.FieldBotID:
  24055. v, ok := value.(string)
  24056. if !ok {
  24057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24058. }
  24059. m.SetBotID(v)
  24060. return nil
  24061. case usagedetail.FieldReceiverID:
  24062. v, ok := value.(string)
  24063. if !ok {
  24064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24065. }
  24066. m.SetReceiverID(v)
  24067. return nil
  24068. case usagedetail.FieldApp:
  24069. v, ok := value.(int)
  24070. if !ok {
  24071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24072. }
  24073. m.SetApp(v)
  24074. return nil
  24075. case usagedetail.FieldSessionID:
  24076. v, ok := value.(uint64)
  24077. if !ok {
  24078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24079. }
  24080. m.SetSessionID(v)
  24081. return nil
  24082. case usagedetail.FieldRequest:
  24083. v, ok := value.(string)
  24084. if !ok {
  24085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24086. }
  24087. m.SetRequest(v)
  24088. return nil
  24089. case usagedetail.FieldResponse:
  24090. v, ok := value.(string)
  24091. if !ok {
  24092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24093. }
  24094. m.SetResponse(v)
  24095. return nil
  24096. case usagedetail.FieldTotalTokens:
  24097. v, ok := value.(uint64)
  24098. if !ok {
  24099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24100. }
  24101. m.SetTotalTokens(v)
  24102. return nil
  24103. case usagedetail.FieldPromptTokens:
  24104. v, ok := value.(uint64)
  24105. if !ok {
  24106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24107. }
  24108. m.SetPromptTokens(v)
  24109. return nil
  24110. case usagedetail.FieldCompletionTokens:
  24111. v, ok := value.(uint64)
  24112. if !ok {
  24113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24114. }
  24115. m.SetCompletionTokens(v)
  24116. return nil
  24117. case usagedetail.FieldOrganizationID:
  24118. v, ok := value.(uint64)
  24119. if !ok {
  24120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24121. }
  24122. m.SetOrganizationID(v)
  24123. return nil
  24124. }
  24125. return fmt.Errorf("unknown UsageDetail field %s", name)
  24126. }
  24127. // AddedFields returns all numeric fields that were incremented/decremented during
  24128. // this mutation.
  24129. func (m *UsageDetailMutation) AddedFields() []string {
  24130. var fields []string
  24131. if m.addstatus != nil {
  24132. fields = append(fields, usagedetail.FieldStatus)
  24133. }
  24134. if m.add_type != nil {
  24135. fields = append(fields, usagedetail.FieldType)
  24136. }
  24137. if m.addapp != nil {
  24138. fields = append(fields, usagedetail.FieldApp)
  24139. }
  24140. if m.addsession_id != nil {
  24141. fields = append(fields, usagedetail.FieldSessionID)
  24142. }
  24143. if m.addtotal_tokens != nil {
  24144. fields = append(fields, usagedetail.FieldTotalTokens)
  24145. }
  24146. if m.addprompt_tokens != nil {
  24147. fields = append(fields, usagedetail.FieldPromptTokens)
  24148. }
  24149. if m.addcompletion_tokens != nil {
  24150. fields = append(fields, usagedetail.FieldCompletionTokens)
  24151. }
  24152. if m.addorganization_id != nil {
  24153. fields = append(fields, usagedetail.FieldOrganizationID)
  24154. }
  24155. return fields
  24156. }
  24157. // AddedField returns the numeric value that was incremented/decremented on a field
  24158. // with the given name. The second boolean return value indicates that this field
  24159. // was not set, or was not defined in the schema.
  24160. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  24161. switch name {
  24162. case usagedetail.FieldStatus:
  24163. return m.AddedStatus()
  24164. case usagedetail.FieldType:
  24165. return m.AddedType()
  24166. case usagedetail.FieldApp:
  24167. return m.AddedApp()
  24168. case usagedetail.FieldSessionID:
  24169. return m.AddedSessionID()
  24170. case usagedetail.FieldTotalTokens:
  24171. return m.AddedTotalTokens()
  24172. case usagedetail.FieldPromptTokens:
  24173. return m.AddedPromptTokens()
  24174. case usagedetail.FieldCompletionTokens:
  24175. return m.AddedCompletionTokens()
  24176. case usagedetail.FieldOrganizationID:
  24177. return m.AddedOrganizationID()
  24178. }
  24179. return nil, false
  24180. }
  24181. // AddField adds the value to the field with the given name. It returns an error if
  24182. // the field is not defined in the schema, or if the type mismatched the field
  24183. // type.
  24184. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  24185. switch name {
  24186. case usagedetail.FieldStatus:
  24187. v, ok := value.(int8)
  24188. if !ok {
  24189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24190. }
  24191. m.AddStatus(v)
  24192. return nil
  24193. case usagedetail.FieldType:
  24194. v, ok := value.(int)
  24195. if !ok {
  24196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24197. }
  24198. m.AddType(v)
  24199. return nil
  24200. case usagedetail.FieldApp:
  24201. v, ok := value.(int)
  24202. if !ok {
  24203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24204. }
  24205. m.AddApp(v)
  24206. return nil
  24207. case usagedetail.FieldSessionID:
  24208. v, ok := value.(int64)
  24209. if !ok {
  24210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24211. }
  24212. m.AddSessionID(v)
  24213. return nil
  24214. case usagedetail.FieldTotalTokens:
  24215. v, ok := value.(int64)
  24216. if !ok {
  24217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24218. }
  24219. m.AddTotalTokens(v)
  24220. return nil
  24221. case usagedetail.FieldPromptTokens:
  24222. v, ok := value.(int64)
  24223. if !ok {
  24224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24225. }
  24226. m.AddPromptTokens(v)
  24227. return nil
  24228. case usagedetail.FieldCompletionTokens:
  24229. v, ok := value.(int64)
  24230. if !ok {
  24231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24232. }
  24233. m.AddCompletionTokens(v)
  24234. return nil
  24235. case usagedetail.FieldOrganizationID:
  24236. v, ok := value.(int64)
  24237. if !ok {
  24238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24239. }
  24240. m.AddOrganizationID(v)
  24241. return nil
  24242. }
  24243. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  24244. }
  24245. // ClearedFields returns all nullable fields that were cleared during this
  24246. // mutation.
  24247. func (m *UsageDetailMutation) ClearedFields() []string {
  24248. var fields []string
  24249. if m.FieldCleared(usagedetail.FieldStatus) {
  24250. fields = append(fields, usagedetail.FieldStatus)
  24251. }
  24252. if m.FieldCleared(usagedetail.FieldType) {
  24253. fields = append(fields, usagedetail.FieldType)
  24254. }
  24255. if m.FieldCleared(usagedetail.FieldApp) {
  24256. fields = append(fields, usagedetail.FieldApp)
  24257. }
  24258. if m.FieldCleared(usagedetail.FieldSessionID) {
  24259. fields = append(fields, usagedetail.FieldSessionID)
  24260. }
  24261. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  24262. fields = append(fields, usagedetail.FieldTotalTokens)
  24263. }
  24264. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  24265. fields = append(fields, usagedetail.FieldPromptTokens)
  24266. }
  24267. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  24268. fields = append(fields, usagedetail.FieldCompletionTokens)
  24269. }
  24270. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  24271. fields = append(fields, usagedetail.FieldOrganizationID)
  24272. }
  24273. return fields
  24274. }
  24275. // FieldCleared returns a boolean indicating if a field with the given name was
  24276. // cleared in this mutation.
  24277. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  24278. _, ok := m.clearedFields[name]
  24279. return ok
  24280. }
  24281. // ClearField clears the value of the field with the given name. It returns an
  24282. // error if the field is not defined in the schema.
  24283. func (m *UsageDetailMutation) ClearField(name string) error {
  24284. switch name {
  24285. case usagedetail.FieldStatus:
  24286. m.ClearStatus()
  24287. return nil
  24288. case usagedetail.FieldType:
  24289. m.ClearType()
  24290. return nil
  24291. case usagedetail.FieldApp:
  24292. m.ClearApp()
  24293. return nil
  24294. case usagedetail.FieldSessionID:
  24295. m.ClearSessionID()
  24296. return nil
  24297. case usagedetail.FieldTotalTokens:
  24298. m.ClearTotalTokens()
  24299. return nil
  24300. case usagedetail.FieldPromptTokens:
  24301. m.ClearPromptTokens()
  24302. return nil
  24303. case usagedetail.FieldCompletionTokens:
  24304. m.ClearCompletionTokens()
  24305. return nil
  24306. case usagedetail.FieldOrganizationID:
  24307. m.ClearOrganizationID()
  24308. return nil
  24309. }
  24310. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  24311. }
  24312. // ResetField resets all changes in the mutation for the field with the given name.
  24313. // It returns an error if the field is not defined in the schema.
  24314. func (m *UsageDetailMutation) ResetField(name string) error {
  24315. switch name {
  24316. case usagedetail.FieldCreatedAt:
  24317. m.ResetCreatedAt()
  24318. return nil
  24319. case usagedetail.FieldUpdatedAt:
  24320. m.ResetUpdatedAt()
  24321. return nil
  24322. case usagedetail.FieldStatus:
  24323. m.ResetStatus()
  24324. return nil
  24325. case usagedetail.FieldType:
  24326. m.ResetType()
  24327. return nil
  24328. case usagedetail.FieldBotID:
  24329. m.ResetBotID()
  24330. return nil
  24331. case usagedetail.FieldReceiverID:
  24332. m.ResetReceiverID()
  24333. return nil
  24334. case usagedetail.FieldApp:
  24335. m.ResetApp()
  24336. return nil
  24337. case usagedetail.FieldSessionID:
  24338. m.ResetSessionID()
  24339. return nil
  24340. case usagedetail.FieldRequest:
  24341. m.ResetRequest()
  24342. return nil
  24343. case usagedetail.FieldResponse:
  24344. m.ResetResponse()
  24345. return nil
  24346. case usagedetail.FieldTotalTokens:
  24347. m.ResetTotalTokens()
  24348. return nil
  24349. case usagedetail.FieldPromptTokens:
  24350. m.ResetPromptTokens()
  24351. return nil
  24352. case usagedetail.FieldCompletionTokens:
  24353. m.ResetCompletionTokens()
  24354. return nil
  24355. case usagedetail.FieldOrganizationID:
  24356. m.ResetOrganizationID()
  24357. return nil
  24358. }
  24359. return fmt.Errorf("unknown UsageDetail field %s", name)
  24360. }
  24361. // AddedEdges returns all edge names that were set/added in this mutation.
  24362. func (m *UsageDetailMutation) AddedEdges() []string {
  24363. edges := make([]string, 0, 0)
  24364. return edges
  24365. }
  24366. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24367. // name in this mutation.
  24368. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  24369. return nil
  24370. }
  24371. // RemovedEdges returns all edge names that were removed in this mutation.
  24372. func (m *UsageDetailMutation) RemovedEdges() []string {
  24373. edges := make([]string, 0, 0)
  24374. return edges
  24375. }
  24376. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24377. // the given name in this mutation.
  24378. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  24379. return nil
  24380. }
  24381. // ClearedEdges returns all edge names that were cleared in this mutation.
  24382. func (m *UsageDetailMutation) ClearedEdges() []string {
  24383. edges := make([]string, 0, 0)
  24384. return edges
  24385. }
  24386. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24387. // was cleared in this mutation.
  24388. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  24389. return false
  24390. }
  24391. // ClearEdge clears the value of the edge with the given name. It returns an error
  24392. // if that edge is not defined in the schema.
  24393. func (m *UsageDetailMutation) ClearEdge(name string) error {
  24394. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  24395. }
  24396. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24397. // It returns an error if the edge is not defined in the schema.
  24398. func (m *UsageDetailMutation) ResetEdge(name string) error {
  24399. return fmt.Errorf("unknown UsageDetail edge %s", name)
  24400. }
  24401. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  24402. type UsageStatisticDayMutation struct {
  24403. config
  24404. op Op
  24405. typ string
  24406. id *uint64
  24407. created_at *time.Time
  24408. updated_at *time.Time
  24409. status *uint8
  24410. addstatus *int8
  24411. deleted_at *time.Time
  24412. addtime *uint64
  24413. addaddtime *int64
  24414. _type *int
  24415. add_type *int
  24416. bot_id *string
  24417. organization_id *uint64
  24418. addorganization_id *int64
  24419. ai_response *uint64
  24420. addai_response *int64
  24421. sop_run *uint64
  24422. addsop_run *int64
  24423. total_friend *uint64
  24424. addtotal_friend *int64
  24425. total_group *uint64
  24426. addtotal_group *int64
  24427. account_balance *uint64
  24428. addaccount_balance *int64
  24429. consume_token *uint64
  24430. addconsume_token *int64
  24431. active_user *uint64
  24432. addactive_user *int64
  24433. new_user *int64
  24434. addnew_user *int64
  24435. label_dist *[]custom_types.LabelDist
  24436. appendlabel_dist []custom_types.LabelDist
  24437. clearedFields map[string]struct{}
  24438. done bool
  24439. oldValue func(context.Context) (*UsageStatisticDay, error)
  24440. predicates []predicate.UsageStatisticDay
  24441. }
  24442. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  24443. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  24444. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  24445. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  24446. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  24447. m := &UsageStatisticDayMutation{
  24448. config: c,
  24449. op: op,
  24450. typ: TypeUsageStatisticDay,
  24451. clearedFields: make(map[string]struct{}),
  24452. }
  24453. for _, opt := range opts {
  24454. opt(m)
  24455. }
  24456. return m
  24457. }
  24458. // withUsageStatisticDayID sets the ID field of the mutation.
  24459. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  24460. return func(m *UsageStatisticDayMutation) {
  24461. var (
  24462. err error
  24463. once sync.Once
  24464. value *UsageStatisticDay
  24465. )
  24466. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  24467. once.Do(func() {
  24468. if m.done {
  24469. err = errors.New("querying old values post mutation is not allowed")
  24470. } else {
  24471. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  24472. }
  24473. })
  24474. return value, err
  24475. }
  24476. m.id = &id
  24477. }
  24478. }
  24479. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  24480. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  24481. return func(m *UsageStatisticDayMutation) {
  24482. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  24483. return node, nil
  24484. }
  24485. m.id = &node.ID
  24486. }
  24487. }
  24488. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24489. // executed in a transaction (ent.Tx), a transactional client is returned.
  24490. func (m UsageStatisticDayMutation) Client() *Client {
  24491. client := &Client{config: m.config}
  24492. client.init()
  24493. return client
  24494. }
  24495. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24496. // it returns an error otherwise.
  24497. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  24498. if _, ok := m.driver.(*txDriver); !ok {
  24499. return nil, errors.New("ent: mutation is not running in a transaction")
  24500. }
  24501. tx := &Tx{config: m.config}
  24502. tx.init()
  24503. return tx, nil
  24504. }
  24505. // SetID sets the value of the id field. Note that this
  24506. // operation is only accepted on creation of UsageStatisticDay entities.
  24507. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  24508. m.id = &id
  24509. }
  24510. // ID returns the ID value in the mutation. Note that the ID is only available
  24511. // if it was provided to the builder or after it was returned from the database.
  24512. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  24513. if m.id == nil {
  24514. return
  24515. }
  24516. return *m.id, true
  24517. }
  24518. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24519. // That means, if the mutation is applied within a transaction with an isolation level such
  24520. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24521. // or updated by the mutation.
  24522. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  24523. switch {
  24524. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24525. id, exists := m.ID()
  24526. if exists {
  24527. return []uint64{id}, nil
  24528. }
  24529. fallthrough
  24530. case m.op.Is(OpUpdate | OpDelete):
  24531. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  24532. default:
  24533. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24534. }
  24535. }
  24536. // SetCreatedAt sets the "created_at" field.
  24537. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  24538. m.created_at = &t
  24539. }
  24540. // CreatedAt returns the value of the "created_at" field in the mutation.
  24541. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  24542. v := m.created_at
  24543. if v == nil {
  24544. return
  24545. }
  24546. return *v, true
  24547. }
  24548. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  24549. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24551. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24552. if !m.op.Is(OpUpdateOne) {
  24553. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24554. }
  24555. if m.id == nil || m.oldValue == nil {
  24556. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24557. }
  24558. oldValue, err := m.oldValue(ctx)
  24559. if err != nil {
  24560. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24561. }
  24562. return oldValue.CreatedAt, nil
  24563. }
  24564. // ResetCreatedAt resets all changes to the "created_at" field.
  24565. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  24566. m.created_at = nil
  24567. }
  24568. // SetUpdatedAt sets the "updated_at" field.
  24569. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  24570. m.updated_at = &t
  24571. }
  24572. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24573. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  24574. v := m.updated_at
  24575. if v == nil {
  24576. return
  24577. }
  24578. return *v, true
  24579. }
  24580. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  24581. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24583. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24584. if !m.op.Is(OpUpdateOne) {
  24585. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24586. }
  24587. if m.id == nil || m.oldValue == nil {
  24588. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24589. }
  24590. oldValue, err := m.oldValue(ctx)
  24591. if err != nil {
  24592. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24593. }
  24594. return oldValue.UpdatedAt, nil
  24595. }
  24596. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24597. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  24598. m.updated_at = nil
  24599. }
  24600. // SetStatus sets the "status" field.
  24601. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  24602. m.status = &u
  24603. m.addstatus = nil
  24604. }
  24605. // Status returns the value of the "status" field in the mutation.
  24606. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  24607. v := m.status
  24608. if v == nil {
  24609. return
  24610. }
  24611. return *v, true
  24612. }
  24613. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  24614. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24616. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24617. if !m.op.Is(OpUpdateOne) {
  24618. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24619. }
  24620. if m.id == nil || m.oldValue == nil {
  24621. return v, errors.New("OldStatus requires an ID field in the mutation")
  24622. }
  24623. oldValue, err := m.oldValue(ctx)
  24624. if err != nil {
  24625. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24626. }
  24627. return oldValue.Status, nil
  24628. }
  24629. // AddStatus adds u to the "status" field.
  24630. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  24631. if m.addstatus != nil {
  24632. *m.addstatus += u
  24633. } else {
  24634. m.addstatus = &u
  24635. }
  24636. }
  24637. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24638. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  24639. v := m.addstatus
  24640. if v == nil {
  24641. return
  24642. }
  24643. return *v, true
  24644. }
  24645. // ClearStatus clears the value of the "status" field.
  24646. func (m *UsageStatisticDayMutation) ClearStatus() {
  24647. m.status = nil
  24648. m.addstatus = nil
  24649. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  24650. }
  24651. // StatusCleared returns if the "status" field was cleared in this mutation.
  24652. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  24653. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  24654. return ok
  24655. }
  24656. // ResetStatus resets all changes to the "status" field.
  24657. func (m *UsageStatisticDayMutation) ResetStatus() {
  24658. m.status = nil
  24659. m.addstatus = nil
  24660. delete(m.clearedFields, usagestatisticday.FieldStatus)
  24661. }
  24662. // SetDeletedAt sets the "deleted_at" field.
  24663. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  24664. m.deleted_at = &t
  24665. }
  24666. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24667. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  24668. v := m.deleted_at
  24669. if v == nil {
  24670. return
  24671. }
  24672. return *v, true
  24673. }
  24674. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  24675. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24677. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24678. if !m.op.Is(OpUpdateOne) {
  24679. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24680. }
  24681. if m.id == nil || m.oldValue == nil {
  24682. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24683. }
  24684. oldValue, err := m.oldValue(ctx)
  24685. if err != nil {
  24686. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24687. }
  24688. return oldValue.DeletedAt, nil
  24689. }
  24690. // ClearDeletedAt clears the value of the "deleted_at" field.
  24691. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  24692. m.deleted_at = nil
  24693. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  24694. }
  24695. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24696. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  24697. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  24698. return ok
  24699. }
  24700. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24701. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  24702. m.deleted_at = nil
  24703. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  24704. }
  24705. // SetAddtime sets the "addtime" field.
  24706. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  24707. m.addtime = &u
  24708. m.addaddtime = nil
  24709. }
  24710. // Addtime returns the value of the "addtime" field in the mutation.
  24711. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  24712. v := m.addtime
  24713. if v == nil {
  24714. return
  24715. }
  24716. return *v, true
  24717. }
  24718. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  24719. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24721. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  24722. if !m.op.Is(OpUpdateOne) {
  24723. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  24724. }
  24725. if m.id == nil || m.oldValue == nil {
  24726. return v, errors.New("OldAddtime requires an ID field in the mutation")
  24727. }
  24728. oldValue, err := m.oldValue(ctx)
  24729. if err != nil {
  24730. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  24731. }
  24732. return oldValue.Addtime, nil
  24733. }
  24734. // AddAddtime adds u to the "addtime" field.
  24735. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  24736. if m.addaddtime != nil {
  24737. *m.addaddtime += u
  24738. } else {
  24739. m.addaddtime = &u
  24740. }
  24741. }
  24742. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  24743. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  24744. v := m.addaddtime
  24745. if v == nil {
  24746. return
  24747. }
  24748. return *v, true
  24749. }
  24750. // ResetAddtime resets all changes to the "addtime" field.
  24751. func (m *UsageStatisticDayMutation) ResetAddtime() {
  24752. m.addtime = nil
  24753. m.addaddtime = nil
  24754. }
  24755. // SetType sets the "type" field.
  24756. func (m *UsageStatisticDayMutation) SetType(i int) {
  24757. m._type = &i
  24758. m.add_type = nil
  24759. }
  24760. // GetType returns the value of the "type" field in the mutation.
  24761. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  24762. v := m._type
  24763. if v == nil {
  24764. return
  24765. }
  24766. return *v, true
  24767. }
  24768. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  24769. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24771. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  24772. if !m.op.Is(OpUpdateOne) {
  24773. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24774. }
  24775. if m.id == nil || m.oldValue == nil {
  24776. return v, errors.New("OldType requires an ID field in the mutation")
  24777. }
  24778. oldValue, err := m.oldValue(ctx)
  24779. if err != nil {
  24780. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24781. }
  24782. return oldValue.Type, nil
  24783. }
  24784. // AddType adds i to the "type" field.
  24785. func (m *UsageStatisticDayMutation) AddType(i int) {
  24786. if m.add_type != nil {
  24787. *m.add_type += i
  24788. } else {
  24789. m.add_type = &i
  24790. }
  24791. }
  24792. // AddedType returns the value that was added to the "type" field in this mutation.
  24793. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  24794. v := m.add_type
  24795. if v == nil {
  24796. return
  24797. }
  24798. return *v, true
  24799. }
  24800. // ResetType resets all changes to the "type" field.
  24801. func (m *UsageStatisticDayMutation) ResetType() {
  24802. m._type = nil
  24803. m.add_type = nil
  24804. }
  24805. // SetBotID sets the "bot_id" field.
  24806. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  24807. m.bot_id = &s
  24808. }
  24809. // BotID returns the value of the "bot_id" field in the mutation.
  24810. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  24811. v := m.bot_id
  24812. if v == nil {
  24813. return
  24814. }
  24815. return *v, true
  24816. }
  24817. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  24818. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24820. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  24821. if !m.op.Is(OpUpdateOne) {
  24822. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  24823. }
  24824. if m.id == nil || m.oldValue == nil {
  24825. return v, errors.New("OldBotID requires an ID field in the mutation")
  24826. }
  24827. oldValue, err := m.oldValue(ctx)
  24828. if err != nil {
  24829. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  24830. }
  24831. return oldValue.BotID, nil
  24832. }
  24833. // ClearBotID clears the value of the "bot_id" field.
  24834. func (m *UsageStatisticDayMutation) ClearBotID() {
  24835. m.bot_id = nil
  24836. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  24837. }
  24838. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  24839. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  24840. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  24841. return ok
  24842. }
  24843. // ResetBotID resets all changes to the "bot_id" field.
  24844. func (m *UsageStatisticDayMutation) ResetBotID() {
  24845. m.bot_id = nil
  24846. delete(m.clearedFields, usagestatisticday.FieldBotID)
  24847. }
  24848. // SetOrganizationID sets the "organization_id" field.
  24849. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  24850. m.organization_id = &u
  24851. m.addorganization_id = nil
  24852. }
  24853. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24854. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  24855. v := m.organization_id
  24856. if v == nil {
  24857. return
  24858. }
  24859. return *v, true
  24860. }
  24861. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  24862. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24864. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24865. if !m.op.Is(OpUpdateOne) {
  24866. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24867. }
  24868. if m.id == nil || m.oldValue == nil {
  24869. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24870. }
  24871. oldValue, err := m.oldValue(ctx)
  24872. if err != nil {
  24873. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24874. }
  24875. return oldValue.OrganizationID, nil
  24876. }
  24877. // AddOrganizationID adds u to the "organization_id" field.
  24878. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  24879. if m.addorganization_id != nil {
  24880. *m.addorganization_id += u
  24881. } else {
  24882. m.addorganization_id = &u
  24883. }
  24884. }
  24885. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24886. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  24887. v := m.addorganization_id
  24888. if v == nil {
  24889. return
  24890. }
  24891. return *v, true
  24892. }
  24893. // ClearOrganizationID clears the value of the "organization_id" field.
  24894. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  24895. m.organization_id = nil
  24896. m.addorganization_id = nil
  24897. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  24898. }
  24899. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24900. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  24901. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  24902. return ok
  24903. }
  24904. // ResetOrganizationID resets all changes to the "organization_id" field.
  24905. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  24906. m.organization_id = nil
  24907. m.addorganization_id = nil
  24908. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  24909. }
  24910. // SetAiResponse sets the "ai_response" field.
  24911. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  24912. m.ai_response = &u
  24913. m.addai_response = nil
  24914. }
  24915. // AiResponse returns the value of the "ai_response" field in the mutation.
  24916. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  24917. v := m.ai_response
  24918. if v == nil {
  24919. return
  24920. }
  24921. return *v, true
  24922. }
  24923. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  24924. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24926. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  24927. if !m.op.Is(OpUpdateOne) {
  24928. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  24929. }
  24930. if m.id == nil || m.oldValue == nil {
  24931. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  24932. }
  24933. oldValue, err := m.oldValue(ctx)
  24934. if err != nil {
  24935. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  24936. }
  24937. return oldValue.AiResponse, nil
  24938. }
  24939. // AddAiResponse adds u to the "ai_response" field.
  24940. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  24941. if m.addai_response != nil {
  24942. *m.addai_response += u
  24943. } else {
  24944. m.addai_response = &u
  24945. }
  24946. }
  24947. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  24948. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  24949. v := m.addai_response
  24950. if v == nil {
  24951. return
  24952. }
  24953. return *v, true
  24954. }
  24955. // ResetAiResponse resets all changes to the "ai_response" field.
  24956. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  24957. m.ai_response = nil
  24958. m.addai_response = nil
  24959. }
  24960. // SetSopRun sets the "sop_run" field.
  24961. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  24962. m.sop_run = &u
  24963. m.addsop_run = nil
  24964. }
  24965. // SopRun returns the value of the "sop_run" field in the mutation.
  24966. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  24967. v := m.sop_run
  24968. if v == nil {
  24969. return
  24970. }
  24971. return *v, true
  24972. }
  24973. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  24974. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24976. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  24977. if !m.op.Is(OpUpdateOne) {
  24978. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  24979. }
  24980. if m.id == nil || m.oldValue == nil {
  24981. return v, errors.New("OldSopRun requires an ID field in the mutation")
  24982. }
  24983. oldValue, err := m.oldValue(ctx)
  24984. if err != nil {
  24985. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  24986. }
  24987. return oldValue.SopRun, nil
  24988. }
  24989. // AddSopRun adds u to the "sop_run" field.
  24990. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  24991. if m.addsop_run != nil {
  24992. *m.addsop_run += u
  24993. } else {
  24994. m.addsop_run = &u
  24995. }
  24996. }
  24997. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  24998. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  24999. v := m.addsop_run
  25000. if v == nil {
  25001. return
  25002. }
  25003. return *v, true
  25004. }
  25005. // ResetSopRun resets all changes to the "sop_run" field.
  25006. func (m *UsageStatisticDayMutation) ResetSopRun() {
  25007. m.sop_run = nil
  25008. m.addsop_run = nil
  25009. }
  25010. // SetTotalFriend sets the "total_friend" field.
  25011. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  25012. m.total_friend = &u
  25013. m.addtotal_friend = nil
  25014. }
  25015. // TotalFriend returns the value of the "total_friend" field in the mutation.
  25016. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  25017. v := m.total_friend
  25018. if v == nil {
  25019. return
  25020. }
  25021. return *v, true
  25022. }
  25023. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  25024. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25026. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  25027. if !m.op.Is(OpUpdateOne) {
  25028. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  25029. }
  25030. if m.id == nil || m.oldValue == nil {
  25031. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  25032. }
  25033. oldValue, err := m.oldValue(ctx)
  25034. if err != nil {
  25035. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  25036. }
  25037. return oldValue.TotalFriend, nil
  25038. }
  25039. // AddTotalFriend adds u to the "total_friend" field.
  25040. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  25041. if m.addtotal_friend != nil {
  25042. *m.addtotal_friend += u
  25043. } else {
  25044. m.addtotal_friend = &u
  25045. }
  25046. }
  25047. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  25048. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  25049. v := m.addtotal_friend
  25050. if v == nil {
  25051. return
  25052. }
  25053. return *v, true
  25054. }
  25055. // ResetTotalFriend resets all changes to the "total_friend" field.
  25056. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  25057. m.total_friend = nil
  25058. m.addtotal_friend = nil
  25059. }
  25060. // SetTotalGroup sets the "total_group" field.
  25061. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  25062. m.total_group = &u
  25063. m.addtotal_group = nil
  25064. }
  25065. // TotalGroup returns the value of the "total_group" field in the mutation.
  25066. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  25067. v := m.total_group
  25068. if v == nil {
  25069. return
  25070. }
  25071. return *v, true
  25072. }
  25073. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  25074. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25076. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  25077. if !m.op.Is(OpUpdateOne) {
  25078. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  25079. }
  25080. if m.id == nil || m.oldValue == nil {
  25081. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  25082. }
  25083. oldValue, err := m.oldValue(ctx)
  25084. if err != nil {
  25085. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  25086. }
  25087. return oldValue.TotalGroup, nil
  25088. }
  25089. // AddTotalGroup adds u to the "total_group" field.
  25090. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  25091. if m.addtotal_group != nil {
  25092. *m.addtotal_group += u
  25093. } else {
  25094. m.addtotal_group = &u
  25095. }
  25096. }
  25097. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  25098. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  25099. v := m.addtotal_group
  25100. if v == nil {
  25101. return
  25102. }
  25103. return *v, true
  25104. }
  25105. // ResetTotalGroup resets all changes to the "total_group" field.
  25106. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  25107. m.total_group = nil
  25108. m.addtotal_group = nil
  25109. }
  25110. // SetAccountBalance sets the "account_balance" field.
  25111. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  25112. m.account_balance = &u
  25113. m.addaccount_balance = nil
  25114. }
  25115. // AccountBalance returns the value of the "account_balance" field in the mutation.
  25116. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  25117. v := m.account_balance
  25118. if v == nil {
  25119. return
  25120. }
  25121. return *v, true
  25122. }
  25123. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  25124. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25126. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  25127. if !m.op.Is(OpUpdateOne) {
  25128. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  25129. }
  25130. if m.id == nil || m.oldValue == nil {
  25131. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  25132. }
  25133. oldValue, err := m.oldValue(ctx)
  25134. if err != nil {
  25135. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  25136. }
  25137. return oldValue.AccountBalance, nil
  25138. }
  25139. // AddAccountBalance adds u to the "account_balance" field.
  25140. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  25141. if m.addaccount_balance != nil {
  25142. *m.addaccount_balance += u
  25143. } else {
  25144. m.addaccount_balance = &u
  25145. }
  25146. }
  25147. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  25148. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  25149. v := m.addaccount_balance
  25150. if v == nil {
  25151. return
  25152. }
  25153. return *v, true
  25154. }
  25155. // ResetAccountBalance resets all changes to the "account_balance" field.
  25156. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  25157. m.account_balance = nil
  25158. m.addaccount_balance = nil
  25159. }
  25160. // SetConsumeToken sets the "consume_token" field.
  25161. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  25162. m.consume_token = &u
  25163. m.addconsume_token = nil
  25164. }
  25165. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  25166. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  25167. v := m.consume_token
  25168. if v == nil {
  25169. return
  25170. }
  25171. return *v, true
  25172. }
  25173. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  25174. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25176. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  25177. if !m.op.Is(OpUpdateOne) {
  25178. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  25179. }
  25180. if m.id == nil || m.oldValue == nil {
  25181. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  25182. }
  25183. oldValue, err := m.oldValue(ctx)
  25184. if err != nil {
  25185. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  25186. }
  25187. return oldValue.ConsumeToken, nil
  25188. }
  25189. // AddConsumeToken adds u to the "consume_token" field.
  25190. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  25191. if m.addconsume_token != nil {
  25192. *m.addconsume_token += u
  25193. } else {
  25194. m.addconsume_token = &u
  25195. }
  25196. }
  25197. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  25198. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  25199. v := m.addconsume_token
  25200. if v == nil {
  25201. return
  25202. }
  25203. return *v, true
  25204. }
  25205. // ResetConsumeToken resets all changes to the "consume_token" field.
  25206. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  25207. m.consume_token = nil
  25208. m.addconsume_token = nil
  25209. }
  25210. // SetActiveUser sets the "active_user" field.
  25211. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  25212. m.active_user = &u
  25213. m.addactive_user = nil
  25214. }
  25215. // ActiveUser returns the value of the "active_user" field in the mutation.
  25216. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  25217. v := m.active_user
  25218. if v == nil {
  25219. return
  25220. }
  25221. return *v, true
  25222. }
  25223. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  25224. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25226. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  25227. if !m.op.Is(OpUpdateOne) {
  25228. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  25229. }
  25230. if m.id == nil || m.oldValue == nil {
  25231. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  25232. }
  25233. oldValue, err := m.oldValue(ctx)
  25234. if err != nil {
  25235. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  25236. }
  25237. return oldValue.ActiveUser, nil
  25238. }
  25239. // AddActiveUser adds u to the "active_user" field.
  25240. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  25241. if m.addactive_user != nil {
  25242. *m.addactive_user += u
  25243. } else {
  25244. m.addactive_user = &u
  25245. }
  25246. }
  25247. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  25248. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  25249. v := m.addactive_user
  25250. if v == nil {
  25251. return
  25252. }
  25253. return *v, true
  25254. }
  25255. // ResetActiveUser resets all changes to the "active_user" field.
  25256. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  25257. m.active_user = nil
  25258. m.addactive_user = nil
  25259. }
  25260. // SetNewUser sets the "new_user" field.
  25261. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  25262. m.new_user = &i
  25263. m.addnew_user = nil
  25264. }
  25265. // NewUser returns the value of the "new_user" field in the mutation.
  25266. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  25267. v := m.new_user
  25268. if v == nil {
  25269. return
  25270. }
  25271. return *v, true
  25272. }
  25273. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  25274. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25276. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  25277. if !m.op.Is(OpUpdateOne) {
  25278. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  25279. }
  25280. if m.id == nil || m.oldValue == nil {
  25281. return v, errors.New("OldNewUser requires an ID field in the mutation")
  25282. }
  25283. oldValue, err := m.oldValue(ctx)
  25284. if err != nil {
  25285. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  25286. }
  25287. return oldValue.NewUser, nil
  25288. }
  25289. // AddNewUser adds i to the "new_user" field.
  25290. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  25291. if m.addnew_user != nil {
  25292. *m.addnew_user += i
  25293. } else {
  25294. m.addnew_user = &i
  25295. }
  25296. }
  25297. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  25298. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  25299. v := m.addnew_user
  25300. if v == nil {
  25301. return
  25302. }
  25303. return *v, true
  25304. }
  25305. // ResetNewUser resets all changes to the "new_user" field.
  25306. func (m *UsageStatisticDayMutation) ResetNewUser() {
  25307. m.new_user = nil
  25308. m.addnew_user = nil
  25309. }
  25310. // SetLabelDist sets the "label_dist" field.
  25311. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  25312. m.label_dist = &ctd
  25313. m.appendlabel_dist = nil
  25314. }
  25315. // LabelDist returns the value of the "label_dist" field in the mutation.
  25316. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  25317. v := m.label_dist
  25318. if v == nil {
  25319. return
  25320. }
  25321. return *v, true
  25322. }
  25323. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  25324. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25326. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  25327. if !m.op.Is(OpUpdateOne) {
  25328. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  25329. }
  25330. if m.id == nil || m.oldValue == nil {
  25331. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  25332. }
  25333. oldValue, err := m.oldValue(ctx)
  25334. if err != nil {
  25335. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  25336. }
  25337. return oldValue.LabelDist, nil
  25338. }
  25339. // AppendLabelDist adds ctd to the "label_dist" field.
  25340. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  25341. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  25342. }
  25343. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  25344. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  25345. if len(m.appendlabel_dist) == 0 {
  25346. return nil, false
  25347. }
  25348. return m.appendlabel_dist, true
  25349. }
  25350. // ResetLabelDist resets all changes to the "label_dist" field.
  25351. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  25352. m.label_dist = nil
  25353. m.appendlabel_dist = nil
  25354. }
  25355. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  25356. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  25357. m.predicates = append(m.predicates, ps...)
  25358. }
  25359. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  25360. // users can use type-assertion to append predicates that do not depend on any generated package.
  25361. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  25362. p := make([]predicate.UsageStatisticDay, len(ps))
  25363. for i := range ps {
  25364. p[i] = ps[i]
  25365. }
  25366. m.Where(p...)
  25367. }
  25368. // Op returns the operation name.
  25369. func (m *UsageStatisticDayMutation) Op() Op {
  25370. return m.op
  25371. }
  25372. // SetOp allows setting the mutation operation.
  25373. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  25374. m.op = op
  25375. }
  25376. // Type returns the node type of this mutation (UsageStatisticDay).
  25377. func (m *UsageStatisticDayMutation) Type() string {
  25378. return m.typ
  25379. }
  25380. // Fields returns all fields that were changed during this mutation. Note that in
  25381. // order to get all numeric fields that were incremented/decremented, call
  25382. // AddedFields().
  25383. func (m *UsageStatisticDayMutation) Fields() []string {
  25384. fields := make([]string, 0, 17)
  25385. if m.created_at != nil {
  25386. fields = append(fields, usagestatisticday.FieldCreatedAt)
  25387. }
  25388. if m.updated_at != nil {
  25389. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  25390. }
  25391. if m.status != nil {
  25392. fields = append(fields, usagestatisticday.FieldStatus)
  25393. }
  25394. if m.deleted_at != nil {
  25395. fields = append(fields, usagestatisticday.FieldDeletedAt)
  25396. }
  25397. if m.addtime != nil {
  25398. fields = append(fields, usagestatisticday.FieldAddtime)
  25399. }
  25400. if m._type != nil {
  25401. fields = append(fields, usagestatisticday.FieldType)
  25402. }
  25403. if m.bot_id != nil {
  25404. fields = append(fields, usagestatisticday.FieldBotID)
  25405. }
  25406. if m.organization_id != nil {
  25407. fields = append(fields, usagestatisticday.FieldOrganizationID)
  25408. }
  25409. if m.ai_response != nil {
  25410. fields = append(fields, usagestatisticday.FieldAiResponse)
  25411. }
  25412. if m.sop_run != nil {
  25413. fields = append(fields, usagestatisticday.FieldSopRun)
  25414. }
  25415. if m.total_friend != nil {
  25416. fields = append(fields, usagestatisticday.FieldTotalFriend)
  25417. }
  25418. if m.total_group != nil {
  25419. fields = append(fields, usagestatisticday.FieldTotalGroup)
  25420. }
  25421. if m.account_balance != nil {
  25422. fields = append(fields, usagestatisticday.FieldAccountBalance)
  25423. }
  25424. if m.consume_token != nil {
  25425. fields = append(fields, usagestatisticday.FieldConsumeToken)
  25426. }
  25427. if m.active_user != nil {
  25428. fields = append(fields, usagestatisticday.FieldActiveUser)
  25429. }
  25430. if m.new_user != nil {
  25431. fields = append(fields, usagestatisticday.FieldNewUser)
  25432. }
  25433. if m.label_dist != nil {
  25434. fields = append(fields, usagestatisticday.FieldLabelDist)
  25435. }
  25436. return fields
  25437. }
  25438. // Field returns the value of a field with the given name. The second boolean
  25439. // return value indicates that this field was not set, or was not defined in the
  25440. // schema.
  25441. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  25442. switch name {
  25443. case usagestatisticday.FieldCreatedAt:
  25444. return m.CreatedAt()
  25445. case usagestatisticday.FieldUpdatedAt:
  25446. return m.UpdatedAt()
  25447. case usagestatisticday.FieldStatus:
  25448. return m.Status()
  25449. case usagestatisticday.FieldDeletedAt:
  25450. return m.DeletedAt()
  25451. case usagestatisticday.FieldAddtime:
  25452. return m.Addtime()
  25453. case usagestatisticday.FieldType:
  25454. return m.GetType()
  25455. case usagestatisticday.FieldBotID:
  25456. return m.BotID()
  25457. case usagestatisticday.FieldOrganizationID:
  25458. return m.OrganizationID()
  25459. case usagestatisticday.FieldAiResponse:
  25460. return m.AiResponse()
  25461. case usagestatisticday.FieldSopRun:
  25462. return m.SopRun()
  25463. case usagestatisticday.FieldTotalFriend:
  25464. return m.TotalFriend()
  25465. case usagestatisticday.FieldTotalGroup:
  25466. return m.TotalGroup()
  25467. case usagestatisticday.FieldAccountBalance:
  25468. return m.AccountBalance()
  25469. case usagestatisticday.FieldConsumeToken:
  25470. return m.ConsumeToken()
  25471. case usagestatisticday.FieldActiveUser:
  25472. return m.ActiveUser()
  25473. case usagestatisticday.FieldNewUser:
  25474. return m.NewUser()
  25475. case usagestatisticday.FieldLabelDist:
  25476. return m.LabelDist()
  25477. }
  25478. return nil, false
  25479. }
  25480. // OldField returns the old value of the field from the database. An error is
  25481. // returned if the mutation operation is not UpdateOne, or the query to the
  25482. // database failed.
  25483. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25484. switch name {
  25485. case usagestatisticday.FieldCreatedAt:
  25486. return m.OldCreatedAt(ctx)
  25487. case usagestatisticday.FieldUpdatedAt:
  25488. return m.OldUpdatedAt(ctx)
  25489. case usagestatisticday.FieldStatus:
  25490. return m.OldStatus(ctx)
  25491. case usagestatisticday.FieldDeletedAt:
  25492. return m.OldDeletedAt(ctx)
  25493. case usagestatisticday.FieldAddtime:
  25494. return m.OldAddtime(ctx)
  25495. case usagestatisticday.FieldType:
  25496. return m.OldType(ctx)
  25497. case usagestatisticday.FieldBotID:
  25498. return m.OldBotID(ctx)
  25499. case usagestatisticday.FieldOrganizationID:
  25500. return m.OldOrganizationID(ctx)
  25501. case usagestatisticday.FieldAiResponse:
  25502. return m.OldAiResponse(ctx)
  25503. case usagestatisticday.FieldSopRun:
  25504. return m.OldSopRun(ctx)
  25505. case usagestatisticday.FieldTotalFriend:
  25506. return m.OldTotalFriend(ctx)
  25507. case usagestatisticday.FieldTotalGroup:
  25508. return m.OldTotalGroup(ctx)
  25509. case usagestatisticday.FieldAccountBalance:
  25510. return m.OldAccountBalance(ctx)
  25511. case usagestatisticday.FieldConsumeToken:
  25512. return m.OldConsumeToken(ctx)
  25513. case usagestatisticday.FieldActiveUser:
  25514. return m.OldActiveUser(ctx)
  25515. case usagestatisticday.FieldNewUser:
  25516. return m.OldNewUser(ctx)
  25517. case usagestatisticday.FieldLabelDist:
  25518. return m.OldLabelDist(ctx)
  25519. }
  25520. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  25521. }
  25522. // SetField sets the value of a field with the given name. It returns an error if
  25523. // the field is not defined in the schema, or if the type mismatched the field
  25524. // type.
  25525. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  25526. switch name {
  25527. case usagestatisticday.FieldCreatedAt:
  25528. v, ok := value.(time.Time)
  25529. if !ok {
  25530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25531. }
  25532. m.SetCreatedAt(v)
  25533. return nil
  25534. case usagestatisticday.FieldUpdatedAt:
  25535. v, ok := value.(time.Time)
  25536. if !ok {
  25537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25538. }
  25539. m.SetUpdatedAt(v)
  25540. return nil
  25541. case usagestatisticday.FieldStatus:
  25542. v, ok := value.(uint8)
  25543. if !ok {
  25544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25545. }
  25546. m.SetStatus(v)
  25547. return nil
  25548. case usagestatisticday.FieldDeletedAt:
  25549. v, ok := value.(time.Time)
  25550. if !ok {
  25551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25552. }
  25553. m.SetDeletedAt(v)
  25554. return nil
  25555. case usagestatisticday.FieldAddtime:
  25556. v, ok := value.(uint64)
  25557. if !ok {
  25558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25559. }
  25560. m.SetAddtime(v)
  25561. return nil
  25562. case usagestatisticday.FieldType:
  25563. v, ok := value.(int)
  25564. if !ok {
  25565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25566. }
  25567. m.SetType(v)
  25568. return nil
  25569. case usagestatisticday.FieldBotID:
  25570. v, ok := value.(string)
  25571. if !ok {
  25572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25573. }
  25574. m.SetBotID(v)
  25575. return nil
  25576. case usagestatisticday.FieldOrganizationID:
  25577. v, ok := value.(uint64)
  25578. if !ok {
  25579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25580. }
  25581. m.SetOrganizationID(v)
  25582. return nil
  25583. case usagestatisticday.FieldAiResponse:
  25584. v, ok := value.(uint64)
  25585. if !ok {
  25586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25587. }
  25588. m.SetAiResponse(v)
  25589. return nil
  25590. case usagestatisticday.FieldSopRun:
  25591. v, ok := value.(uint64)
  25592. if !ok {
  25593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25594. }
  25595. m.SetSopRun(v)
  25596. return nil
  25597. case usagestatisticday.FieldTotalFriend:
  25598. v, ok := value.(uint64)
  25599. if !ok {
  25600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25601. }
  25602. m.SetTotalFriend(v)
  25603. return nil
  25604. case usagestatisticday.FieldTotalGroup:
  25605. v, ok := value.(uint64)
  25606. if !ok {
  25607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25608. }
  25609. m.SetTotalGroup(v)
  25610. return nil
  25611. case usagestatisticday.FieldAccountBalance:
  25612. v, ok := value.(uint64)
  25613. if !ok {
  25614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25615. }
  25616. m.SetAccountBalance(v)
  25617. return nil
  25618. case usagestatisticday.FieldConsumeToken:
  25619. v, ok := value.(uint64)
  25620. if !ok {
  25621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25622. }
  25623. m.SetConsumeToken(v)
  25624. return nil
  25625. case usagestatisticday.FieldActiveUser:
  25626. v, ok := value.(uint64)
  25627. if !ok {
  25628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25629. }
  25630. m.SetActiveUser(v)
  25631. return nil
  25632. case usagestatisticday.FieldNewUser:
  25633. v, ok := value.(int64)
  25634. if !ok {
  25635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25636. }
  25637. m.SetNewUser(v)
  25638. return nil
  25639. case usagestatisticday.FieldLabelDist:
  25640. v, ok := value.([]custom_types.LabelDist)
  25641. if !ok {
  25642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25643. }
  25644. m.SetLabelDist(v)
  25645. return nil
  25646. }
  25647. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  25648. }
  25649. // AddedFields returns all numeric fields that were incremented/decremented during
  25650. // this mutation.
  25651. func (m *UsageStatisticDayMutation) AddedFields() []string {
  25652. var fields []string
  25653. if m.addstatus != nil {
  25654. fields = append(fields, usagestatisticday.FieldStatus)
  25655. }
  25656. if m.addaddtime != nil {
  25657. fields = append(fields, usagestatisticday.FieldAddtime)
  25658. }
  25659. if m.add_type != nil {
  25660. fields = append(fields, usagestatisticday.FieldType)
  25661. }
  25662. if m.addorganization_id != nil {
  25663. fields = append(fields, usagestatisticday.FieldOrganizationID)
  25664. }
  25665. if m.addai_response != nil {
  25666. fields = append(fields, usagestatisticday.FieldAiResponse)
  25667. }
  25668. if m.addsop_run != nil {
  25669. fields = append(fields, usagestatisticday.FieldSopRun)
  25670. }
  25671. if m.addtotal_friend != nil {
  25672. fields = append(fields, usagestatisticday.FieldTotalFriend)
  25673. }
  25674. if m.addtotal_group != nil {
  25675. fields = append(fields, usagestatisticday.FieldTotalGroup)
  25676. }
  25677. if m.addaccount_balance != nil {
  25678. fields = append(fields, usagestatisticday.FieldAccountBalance)
  25679. }
  25680. if m.addconsume_token != nil {
  25681. fields = append(fields, usagestatisticday.FieldConsumeToken)
  25682. }
  25683. if m.addactive_user != nil {
  25684. fields = append(fields, usagestatisticday.FieldActiveUser)
  25685. }
  25686. if m.addnew_user != nil {
  25687. fields = append(fields, usagestatisticday.FieldNewUser)
  25688. }
  25689. return fields
  25690. }
  25691. // AddedField returns the numeric value that was incremented/decremented on a field
  25692. // with the given name. The second boolean return value indicates that this field
  25693. // was not set, or was not defined in the schema.
  25694. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  25695. switch name {
  25696. case usagestatisticday.FieldStatus:
  25697. return m.AddedStatus()
  25698. case usagestatisticday.FieldAddtime:
  25699. return m.AddedAddtime()
  25700. case usagestatisticday.FieldType:
  25701. return m.AddedType()
  25702. case usagestatisticday.FieldOrganizationID:
  25703. return m.AddedOrganizationID()
  25704. case usagestatisticday.FieldAiResponse:
  25705. return m.AddedAiResponse()
  25706. case usagestatisticday.FieldSopRun:
  25707. return m.AddedSopRun()
  25708. case usagestatisticday.FieldTotalFriend:
  25709. return m.AddedTotalFriend()
  25710. case usagestatisticday.FieldTotalGroup:
  25711. return m.AddedTotalGroup()
  25712. case usagestatisticday.FieldAccountBalance:
  25713. return m.AddedAccountBalance()
  25714. case usagestatisticday.FieldConsumeToken:
  25715. return m.AddedConsumeToken()
  25716. case usagestatisticday.FieldActiveUser:
  25717. return m.AddedActiveUser()
  25718. case usagestatisticday.FieldNewUser:
  25719. return m.AddedNewUser()
  25720. }
  25721. return nil, false
  25722. }
  25723. // AddField adds the value to the field with the given name. It returns an error if
  25724. // the field is not defined in the schema, or if the type mismatched the field
  25725. // type.
  25726. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  25727. switch name {
  25728. case usagestatisticday.FieldStatus:
  25729. v, ok := value.(int8)
  25730. if !ok {
  25731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25732. }
  25733. m.AddStatus(v)
  25734. return nil
  25735. case usagestatisticday.FieldAddtime:
  25736. v, ok := value.(int64)
  25737. if !ok {
  25738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25739. }
  25740. m.AddAddtime(v)
  25741. return nil
  25742. case usagestatisticday.FieldType:
  25743. v, ok := value.(int)
  25744. if !ok {
  25745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25746. }
  25747. m.AddType(v)
  25748. return nil
  25749. case usagestatisticday.FieldOrganizationID:
  25750. v, ok := value.(int64)
  25751. if !ok {
  25752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25753. }
  25754. m.AddOrganizationID(v)
  25755. return nil
  25756. case usagestatisticday.FieldAiResponse:
  25757. v, ok := value.(int64)
  25758. if !ok {
  25759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25760. }
  25761. m.AddAiResponse(v)
  25762. return nil
  25763. case usagestatisticday.FieldSopRun:
  25764. v, ok := value.(int64)
  25765. if !ok {
  25766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25767. }
  25768. m.AddSopRun(v)
  25769. return nil
  25770. case usagestatisticday.FieldTotalFriend:
  25771. v, ok := value.(int64)
  25772. if !ok {
  25773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25774. }
  25775. m.AddTotalFriend(v)
  25776. return nil
  25777. case usagestatisticday.FieldTotalGroup:
  25778. v, ok := value.(int64)
  25779. if !ok {
  25780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25781. }
  25782. m.AddTotalGroup(v)
  25783. return nil
  25784. case usagestatisticday.FieldAccountBalance:
  25785. v, ok := value.(int64)
  25786. if !ok {
  25787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25788. }
  25789. m.AddAccountBalance(v)
  25790. return nil
  25791. case usagestatisticday.FieldConsumeToken:
  25792. v, ok := value.(int64)
  25793. if !ok {
  25794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25795. }
  25796. m.AddConsumeToken(v)
  25797. return nil
  25798. case usagestatisticday.FieldActiveUser:
  25799. v, ok := value.(int64)
  25800. if !ok {
  25801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25802. }
  25803. m.AddActiveUser(v)
  25804. return nil
  25805. case usagestatisticday.FieldNewUser:
  25806. v, ok := value.(int64)
  25807. if !ok {
  25808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25809. }
  25810. m.AddNewUser(v)
  25811. return nil
  25812. }
  25813. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  25814. }
  25815. // ClearedFields returns all nullable fields that were cleared during this
  25816. // mutation.
  25817. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  25818. var fields []string
  25819. if m.FieldCleared(usagestatisticday.FieldStatus) {
  25820. fields = append(fields, usagestatisticday.FieldStatus)
  25821. }
  25822. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  25823. fields = append(fields, usagestatisticday.FieldDeletedAt)
  25824. }
  25825. if m.FieldCleared(usagestatisticday.FieldBotID) {
  25826. fields = append(fields, usagestatisticday.FieldBotID)
  25827. }
  25828. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  25829. fields = append(fields, usagestatisticday.FieldOrganizationID)
  25830. }
  25831. return fields
  25832. }
  25833. // FieldCleared returns a boolean indicating if a field with the given name was
  25834. // cleared in this mutation.
  25835. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  25836. _, ok := m.clearedFields[name]
  25837. return ok
  25838. }
  25839. // ClearField clears the value of the field with the given name. It returns an
  25840. // error if the field is not defined in the schema.
  25841. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  25842. switch name {
  25843. case usagestatisticday.FieldStatus:
  25844. m.ClearStatus()
  25845. return nil
  25846. case usagestatisticday.FieldDeletedAt:
  25847. m.ClearDeletedAt()
  25848. return nil
  25849. case usagestatisticday.FieldBotID:
  25850. m.ClearBotID()
  25851. return nil
  25852. case usagestatisticday.FieldOrganizationID:
  25853. m.ClearOrganizationID()
  25854. return nil
  25855. }
  25856. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  25857. }
  25858. // ResetField resets all changes in the mutation for the field with the given name.
  25859. // It returns an error if the field is not defined in the schema.
  25860. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  25861. switch name {
  25862. case usagestatisticday.FieldCreatedAt:
  25863. m.ResetCreatedAt()
  25864. return nil
  25865. case usagestatisticday.FieldUpdatedAt:
  25866. m.ResetUpdatedAt()
  25867. return nil
  25868. case usagestatisticday.FieldStatus:
  25869. m.ResetStatus()
  25870. return nil
  25871. case usagestatisticday.FieldDeletedAt:
  25872. m.ResetDeletedAt()
  25873. return nil
  25874. case usagestatisticday.FieldAddtime:
  25875. m.ResetAddtime()
  25876. return nil
  25877. case usagestatisticday.FieldType:
  25878. m.ResetType()
  25879. return nil
  25880. case usagestatisticday.FieldBotID:
  25881. m.ResetBotID()
  25882. return nil
  25883. case usagestatisticday.FieldOrganizationID:
  25884. m.ResetOrganizationID()
  25885. return nil
  25886. case usagestatisticday.FieldAiResponse:
  25887. m.ResetAiResponse()
  25888. return nil
  25889. case usagestatisticday.FieldSopRun:
  25890. m.ResetSopRun()
  25891. return nil
  25892. case usagestatisticday.FieldTotalFriend:
  25893. m.ResetTotalFriend()
  25894. return nil
  25895. case usagestatisticday.FieldTotalGroup:
  25896. m.ResetTotalGroup()
  25897. return nil
  25898. case usagestatisticday.FieldAccountBalance:
  25899. m.ResetAccountBalance()
  25900. return nil
  25901. case usagestatisticday.FieldConsumeToken:
  25902. m.ResetConsumeToken()
  25903. return nil
  25904. case usagestatisticday.FieldActiveUser:
  25905. m.ResetActiveUser()
  25906. return nil
  25907. case usagestatisticday.FieldNewUser:
  25908. m.ResetNewUser()
  25909. return nil
  25910. case usagestatisticday.FieldLabelDist:
  25911. m.ResetLabelDist()
  25912. return nil
  25913. }
  25914. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  25915. }
  25916. // AddedEdges returns all edge names that were set/added in this mutation.
  25917. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  25918. edges := make([]string, 0, 0)
  25919. return edges
  25920. }
  25921. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25922. // name in this mutation.
  25923. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  25924. return nil
  25925. }
  25926. // RemovedEdges returns all edge names that were removed in this mutation.
  25927. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  25928. edges := make([]string, 0, 0)
  25929. return edges
  25930. }
  25931. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25932. // the given name in this mutation.
  25933. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  25934. return nil
  25935. }
  25936. // ClearedEdges returns all edge names that were cleared in this mutation.
  25937. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  25938. edges := make([]string, 0, 0)
  25939. return edges
  25940. }
  25941. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25942. // was cleared in this mutation.
  25943. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  25944. return false
  25945. }
  25946. // ClearEdge clears the value of the edge with the given name. It returns an error
  25947. // if that edge is not defined in the schema.
  25948. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  25949. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  25950. }
  25951. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25952. // It returns an error if the edge is not defined in the schema.
  25953. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  25954. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  25955. }
  25956. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  25957. type UsageStatisticHourMutation struct {
  25958. config
  25959. op Op
  25960. typ string
  25961. id *uint64
  25962. created_at *time.Time
  25963. updated_at *time.Time
  25964. status *uint8
  25965. addstatus *int8
  25966. deleted_at *time.Time
  25967. addtime *uint64
  25968. addaddtime *int64
  25969. _type *int
  25970. add_type *int
  25971. bot_id *string
  25972. organization_id *uint64
  25973. addorganization_id *int64
  25974. ai_response *uint64
  25975. addai_response *int64
  25976. sop_run *uint64
  25977. addsop_run *int64
  25978. total_friend *uint64
  25979. addtotal_friend *int64
  25980. total_group *uint64
  25981. addtotal_group *int64
  25982. account_balance *uint64
  25983. addaccount_balance *int64
  25984. consume_token *uint64
  25985. addconsume_token *int64
  25986. active_user *uint64
  25987. addactive_user *int64
  25988. new_user *int64
  25989. addnew_user *int64
  25990. label_dist *[]custom_types.LabelDist
  25991. appendlabel_dist []custom_types.LabelDist
  25992. clearedFields map[string]struct{}
  25993. done bool
  25994. oldValue func(context.Context) (*UsageStatisticHour, error)
  25995. predicates []predicate.UsageStatisticHour
  25996. }
  25997. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  25998. // usagestatistichourOption allows management of the mutation configuration using functional options.
  25999. type usagestatistichourOption func(*UsageStatisticHourMutation)
  26000. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  26001. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  26002. m := &UsageStatisticHourMutation{
  26003. config: c,
  26004. op: op,
  26005. typ: TypeUsageStatisticHour,
  26006. clearedFields: make(map[string]struct{}),
  26007. }
  26008. for _, opt := range opts {
  26009. opt(m)
  26010. }
  26011. return m
  26012. }
  26013. // withUsageStatisticHourID sets the ID field of the mutation.
  26014. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  26015. return func(m *UsageStatisticHourMutation) {
  26016. var (
  26017. err error
  26018. once sync.Once
  26019. value *UsageStatisticHour
  26020. )
  26021. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  26022. once.Do(func() {
  26023. if m.done {
  26024. err = errors.New("querying old values post mutation is not allowed")
  26025. } else {
  26026. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  26027. }
  26028. })
  26029. return value, err
  26030. }
  26031. m.id = &id
  26032. }
  26033. }
  26034. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  26035. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  26036. return func(m *UsageStatisticHourMutation) {
  26037. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  26038. return node, nil
  26039. }
  26040. m.id = &node.ID
  26041. }
  26042. }
  26043. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26044. // executed in a transaction (ent.Tx), a transactional client is returned.
  26045. func (m UsageStatisticHourMutation) Client() *Client {
  26046. client := &Client{config: m.config}
  26047. client.init()
  26048. return client
  26049. }
  26050. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26051. // it returns an error otherwise.
  26052. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  26053. if _, ok := m.driver.(*txDriver); !ok {
  26054. return nil, errors.New("ent: mutation is not running in a transaction")
  26055. }
  26056. tx := &Tx{config: m.config}
  26057. tx.init()
  26058. return tx, nil
  26059. }
  26060. // SetID sets the value of the id field. Note that this
  26061. // operation is only accepted on creation of UsageStatisticHour entities.
  26062. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  26063. m.id = &id
  26064. }
  26065. // ID returns the ID value in the mutation. Note that the ID is only available
  26066. // if it was provided to the builder or after it was returned from the database.
  26067. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  26068. if m.id == nil {
  26069. return
  26070. }
  26071. return *m.id, true
  26072. }
  26073. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26074. // That means, if the mutation is applied within a transaction with an isolation level such
  26075. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26076. // or updated by the mutation.
  26077. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  26078. switch {
  26079. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26080. id, exists := m.ID()
  26081. if exists {
  26082. return []uint64{id}, nil
  26083. }
  26084. fallthrough
  26085. case m.op.Is(OpUpdate | OpDelete):
  26086. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  26087. default:
  26088. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26089. }
  26090. }
  26091. // SetCreatedAt sets the "created_at" field.
  26092. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  26093. m.created_at = &t
  26094. }
  26095. // CreatedAt returns the value of the "created_at" field in the mutation.
  26096. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  26097. v := m.created_at
  26098. if v == nil {
  26099. return
  26100. }
  26101. return *v, true
  26102. }
  26103. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  26104. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26106. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26107. if !m.op.Is(OpUpdateOne) {
  26108. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26109. }
  26110. if m.id == nil || m.oldValue == nil {
  26111. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26112. }
  26113. oldValue, err := m.oldValue(ctx)
  26114. if err != nil {
  26115. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26116. }
  26117. return oldValue.CreatedAt, nil
  26118. }
  26119. // ResetCreatedAt resets all changes to the "created_at" field.
  26120. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  26121. m.created_at = nil
  26122. }
  26123. // SetUpdatedAt sets the "updated_at" field.
  26124. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  26125. m.updated_at = &t
  26126. }
  26127. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26128. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  26129. v := m.updated_at
  26130. if v == nil {
  26131. return
  26132. }
  26133. return *v, true
  26134. }
  26135. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  26136. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26138. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26139. if !m.op.Is(OpUpdateOne) {
  26140. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26141. }
  26142. if m.id == nil || m.oldValue == nil {
  26143. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26144. }
  26145. oldValue, err := m.oldValue(ctx)
  26146. if err != nil {
  26147. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26148. }
  26149. return oldValue.UpdatedAt, nil
  26150. }
  26151. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26152. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  26153. m.updated_at = nil
  26154. }
  26155. // SetStatus sets the "status" field.
  26156. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  26157. m.status = &u
  26158. m.addstatus = nil
  26159. }
  26160. // Status returns the value of the "status" field in the mutation.
  26161. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  26162. v := m.status
  26163. if v == nil {
  26164. return
  26165. }
  26166. return *v, true
  26167. }
  26168. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  26169. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26171. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26172. if !m.op.Is(OpUpdateOne) {
  26173. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26174. }
  26175. if m.id == nil || m.oldValue == nil {
  26176. return v, errors.New("OldStatus requires an ID field in the mutation")
  26177. }
  26178. oldValue, err := m.oldValue(ctx)
  26179. if err != nil {
  26180. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26181. }
  26182. return oldValue.Status, nil
  26183. }
  26184. // AddStatus adds u to the "status" field.
  26185. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  26186. if m.addstatus != nil {
  26187. *m.addstatus += u
  26188. } else {
  26189. m.addstatus = &u
  26190. }
  26191. }
  26192. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26193. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  26194. v := m.addstatus
  26195. if v == nil {
  26196. return
  26197. }
  26198. return *v, true
  26199. }
  26200. // ClearStatus clears the value of the "status" field.
  26201. func (m *UsageStatisticHourMutation) ClearStatus() {
  26202. m.status = nil
  26203. m.addstatus = nil
  26204. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  26205. }
  26206. // StatusCleared returns if the "status" field was cleared in this mutation.
  26207. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  26208. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  26209. return ok
  26210. }
  26211. // ResetStatus resets all changes to the "status" field.
  26212. func (m *UsageStatisticHourMutation) ResetStatus() {
  26213. m.status = nil
  26214. m.addstatus = nil
  26215. delete(m.clearedFields, usagestatistichour.FieldStatus)
  26216. }
  26217. // SetDeletedAt sets the "deleted_at" field.
  26218. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  26219. m.deleted_at = &t
  26220. }
  26221. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26222. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  26223. v := m.deleted_at
  26224. if v == nil {
  26225. return
  26226. }
  26227. return *v, true
  26228. }
  26229. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  26230. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26232. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26233. if !m.op.Is(OpUpdateOne) {
  26234. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26235. }
  26236. if m.id == nil || m.oldValue == nil {
  26237. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26238. }
  26239. oldValue, err := m.oldValue(ctx)
  26240. if err != nil {
  26241. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26242. }
  26243. return oldValue.DeletedAt, nil
  26244. }
  26245. // ClearDeletedAt clears the value of the "deleted_at" field.
  26246. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  26247. m.deleted_at = nil
  26248. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  26249. }
  26250. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26251. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  26252. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  26253. return ok
  26254. }
  26255. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26256. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  26257. m.deleted_at = nil
  26258. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  26259. }
  26260. // SetAddtime sets the "addtime" field.
  26261. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  26262. m.addtime = &u
  26263. m.addaddtime = nil
  26264. }
  26265. // Addtime returns the value of the "addtime" field in the mutation.
  26266. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  26267. v := m.addtime
  26268. if v == nil {
  26269. return
  26270. }
  26271. return *v, true
  26272. }
  26273. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  26274. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26276. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  26277. if !m.op.Is(OpUpdateOne) {
  26278. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  26279. }
  26280. if m.id == nil || m.oldValue == nil {
  26281. return v, errors.New("OldAddtime requires an ID field in the mutation")
  26282. }
  26283. oldValue, err := m.oldValue(ctx)
  26284. if err != nil {
  26285. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  26286. }
  26287. return oldValue.Addtime, nil
  26288. }
  26289. // AddAddtime adds u to the "addtime" field.
  26290. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  26291. if m.addaddtime != nil {
  26292. *m.addaddtime += u
  26293. } else {
  26294. m.addaddtime = &u
  26295. }
  26296. }
  26297. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  26298. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  26299. v := m.addaddtime
  26300. if v == nil {
  26301. return
  26302. }
  26303. return *v, true
  26304. }
  26305. // ResetAddtime resets all changes to the "addtime" field.
  26306. func (m *UsageStatisticHourMutation) ResetAddtime() {
  26307. m.addtime = nil
  26308. m.addaddtime = nil
  26309. }
  26310. // SetType sets the "type" field.
  26311. func (m *UsageStatisticHourMutation) SetType(i int) {
  26312. m._type = &i
  26313. m.add_type = nil
  26314. }
  26315. // GetType returns the value of the "type" field in the mutation.
  26316. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  26317. v := m._type
  26318. if v == nil {
  26319. return
  26320. }
  26321. return *v, true
  26322. }
  26323. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  26324. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26326. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  26327. if !m.op.Is(OpUpdateOne) {
  26328. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26329. }
  26330. if m.id == nil || m.oldValue == nil {
  26331. return v, errors.New("OldType requires an ID field in the mutation")
  26332. }
  26333. oldValue, err := m.oldValue(ctx)
  26334. if err != nil {
  26335. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26336. }
  26337. return oldValue.Type, nil
  26338. }
  26339. // AddType adds i to the "type" field.
  26340. func (m *UsageStatisticHourMutation) AddType(i int) {
  26341. if m.add_type != nil {
  26342. *m.add_type += i
  26343. } else {
  26344. m.add_type = &i
  26345. }
  26346. }
  26347. // AddedType returns the value that was added to the "type" field in this mutation.
  26348. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  26349. v := m.add_type
  26350. if v == nil {
  26351. return
  26352. }
  26353. return *v, true
  26354. }
  26355. // ResetType resets all changes to the "type" field.
  26356. func (m *UsageStatisticHourMutation) ResetType() {
  26357. m._type = nil
  26358. m.add_type = nil
  26359. }
  26360. // SetBotID sets the "bot_id" field.
  26361. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  26362. m.bot_id = &s
  26363. }
  26364. // BotID returns the value of the "bot_id" field in the mutation.
  26365. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  26366. v := m.bot_id
  26367. if v == nil {
  26368. return
  26369. }
  26370. return *v, true
  26371. }
  26372. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  26373. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26375. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  26376. if !m.op.Is(OpUpdateOne) {
  26377. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26378. }
  26379. if m.id == nil || m.oldValue == nil {
  26380. return v, errors.New("OldBotID requires an ID field in the mutation")
  26381. }
  26382. oldValue, err := m.oldValue(ctx)
  26383. if err != nil {
  26384. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  26385. }
  26386. return oldValue.BotID, nil
  26387. }
  26388. // ClearBotID clears the value of the "bot_id" field.
  26389. func (m *UsageStatisticHourMutation) ClearBotID() {
  26390. m.bot_id = nil
  26391. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  26392. }
  26393. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  26394. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  26395. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  26396. return ok
  26397. }
  26398. // ResetBotID resets all changes to the "bot_id" field.
  26399. func (m *UsageStatisticHourMutation) ResetBotID() {
  26400. m.bot_id = nil
  26401. delete(m.clearedFields, usagestatistichour.FieldBotID)
  26402. }
  26403. // SetOrganizationID sets the "organization_id" field.
  26404. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  26405. m.organization_id = &u
  26406. m.addorganization_id = nil
  26407. }
  26408. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26409. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  26410. v := m.organization_id
  26411. if v == nil {
  26412. return
  26413. }
  26414. return *v, true
  26415. }
  26416. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  26417. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26419. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26420. if !m.op.Is(OpUpdateOne) {
  26421. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26422. }
  26423. if m.id == nil || m.oldValue == nil {
  26424. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26425. }
  26426. oldValue, err := m.oldValue(ctx)
  26427. if err != nil {
  26428. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26429. }
  26430. return oldValue.OrganizationID, nil
  26431. }
  26432. // AddOrganizationID adds u to the "organization_id" field.
  26433. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  26434. if m.addorganization_id != nil {
  26435. *m.addorganization_id += u
  26436. } else {
  26437. m.addorganization_id = &u
  26438. }
  26439. }
  26440. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26441. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  26442. v := m.addorganization_id
  26443. if v == nil {
  26444. return
  26445. }
  26446. return *v, true
  26447. }
  26448. // ClearOrganizationID clears the value of the "organization_id" field.
  26449. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  26450. m.organization_id = nil
  26451. m.addorganization_id = nil
  26452. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  26453. }
  26454. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26455. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  26456. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  26457. return ok
  26458. }
  26459. // ResetOrganizationID resets all changes to the "organization_id" field.
  26460. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  26461. m.organization_id = nil
  26462. m.addorganization_id = nil
  26463. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  26464. }
  26465. // SetAiResponse sets the "ai_response" field.
  26466. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  26467. m.ai_response = &u
  26468. m.addai_response = nil
  26469. }
  26470. // AiResponse returns the value of the "ai_response" field in the mutation.
  26471. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  26472. v := m.ai_response
  26473. if v == nil {
  26474. return
  26475. }
  26476. return *v, true
  26477. }
  26478. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  26479. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26481. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  26482. if !m.op.Is(OpUpdateOne) {
  26483. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  26484. }
  26485. if m.id == nil || m.oldValue == nil {
  26486. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  26487. }
  26488. oldValue, err := m.oldValue(ctx)
  26489. if err != nil {
  26490. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  26491. }
  26492. return oldValue.AiResponse, nil
  26493. }
  26494. // AddAiResponse adds u to the "ai_response" field.
  26495. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  26496. if m.addai_response != nil {
  26497. *m.addai_response += u
  26498. } else {
  26499. m.addai_response = &u
  26500. }
  26501. }
  26502. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  26503. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  26504. v := m.addai_response
  26505. if v == nil {
  26506. return
  26507. }
  26508. return *v, true
  26509. }
  26510. // ResetAiResponse resets all changes to the "ai_response" field.
  26511. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  26512. m.ai_response = nil
  26513. m.addai_response = nil
  26514. }
  26515. // SetSopRun sets the "sop_run" field.
  26516. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  26517. m.sop_run = &u
  26518. m.addsop_run = nil
  26519. }
  26520. // SopRun returns the value of the "sop_run" field in the mutation.
  26521. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  26522. v := m.sop_run
  26523. if v == nil {
  26524. return
  26525. }
  26526. return *v, true
  26527. }
  26528. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  26529. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26531. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  26532. if !m.op.Is(OpUpdateOne) {
  26533. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  26534. }
  26535. if m.id == nil || m.oldValue == nil {
  26536. return v, errors.New("OldSopRun requires an ID field in the mutation")
  26537. }
  26538. oldValue, err := m.oldValue(ctx)
  26539. if err != nil {
  26540. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  26541. }
  26542. return oldValue.SopRun, nil
  26543. }
  26544. // AddSopRun adds u to the "sop_run" field.
  26545. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  26546. if m.addsop_run != nil {
  26547. *m.addsop_run += u
  26548. } else {
  26549. m.addsop_run = &u
  26550. }
  26551. }
  26552. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  26553. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  26554. v := m.addsop_run
  26555. if v == nil {
  26556. return
  26557. }
  26558. return *v, true
  26559. }
  26560. // ResetSopRun resets all changes to the "sop_run" field.
  26561. func (m *UsageStatisticHourMutation) ResetSopRun() {
  26562. m.sop_run = nil
  26563. m.addsop_run = nil
  26564. }
  26565. // SetTotalFriend sets the "total_friend" field.
  26566. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  26567. m.total_friend = &u
  26568. m.addtotal_friend = nil
  26569. }
  26570. // TotalFriend returns the value of the "total_friend" field in the mutation.
  26571. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  26572. v := m.total_friend
  26573. if v == nil {
  26574. return
  26575. }
  26576. return *v, true
  26577. }
  26578. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  26579. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26581. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  26582. if !m.op.Is(OpUpdateOne) {
  26583. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  26584. }
  26585. if m.id == nil || m.oldValue == nil {
  26586. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  26587. }
  26588. oldValue, err := m.oldValue(ctx)
  26589. if err != nil {
  26590. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  26591. }
  26592. return oldValue.TotalFriend, nil
  26593. }
  26594. // AddTotalFriend adds u to the "total_friend" field.
  26595. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  26596. if m.addtotal_friend != nil {
  26597. *m.addtotal_friend += u
  26598. } else {
  26599. m.addtotal_friend = &u
  26600. }
  26601. }
  26602. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  26603. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  26604. v := m.addtotal_friend
  26605. if v == nil {
  26606. return
  26607. }
  26608. return *v, true
  26609. }
  26610. // ResetTotalFriend resets all changes to the "total_friend" field.
  26611. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  26612. m.total_friend = nil
  26613. m.addtotal_friend = nil
  26614. }
  26615. // SetTotalGroup sets the "total_group" field.
  26616. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  26617. m.total_group = &u
  26618. m.addtotal_group = nil
  26619. }
  26620. // TotalGroup returns the value of the "total_group" field in the mutation.
  26621. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  26622. v := m.total_group
  26623. if v == nil {
  26624. return
  26625. }
  26626. return *v, true
  26627. }
  26628. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  26629. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26631. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  26632. if !m.op.Is(OpUpdateOne) {
  26633. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  26634. }
  26635. if m.id == nil || m.oldValue == nil {
  26636. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  26637. }
  26638. oldValue, err := m.oldValue(ctx)
  26639. if err != nil {
  26640. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  26641. }
  26642. return oldValue.TotalGroup, nil
  26643. }
  26644. // AddTotalGroup adds u to the "total_group" field.
  26645. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  26646. if m.addtotal_group != nil {
  26647. *m.addtotal_group += u
  26648. } else {
  26649. m.addtotal_group = &u
  26650. }
  26651. }
  26652. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  26653. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  26654. v := m.addtotal_group
  26655. if v == nil {
  26656. return
  26657. }
  26658. return *v, true
  26659. }
  26660. // ResetTotalGroup resets all changes to the "total_group" field.
  26661. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  26662. m.total_group = nil
  26663. m.addtotal_group = nil
  26664. }
  26665. // SetAccountBalance sets the "account_balance" field.
  26666. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  26667. m.account_balance = &u
  26668. m.addaccount_balance = nil
  26669. }
  26670. // AccountBalance returns the value of the "account_balance" field in the mutation.
  26671. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  26672. v := m.account_balance
  26673. if v == nil {
  26674. return
  26675. }
  26676. return *v, true
  26677. }
  26678. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  26679. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26681. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  26682. if !m.op.Is(OpUpdateOne) {
  26683. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  26684. }
  26685. if m.id == nil || m.oldValue == nil {
  26686. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  26687. }
  26688. oldValue, err := m.oldValue(ctx)
  26689. if err != nil {
  26690. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  26691. }
  26692. return oldValue.AccountBalance, nil
  26693. }
  26694. // AddAccountBalance adds u to the "account_balance" field.
  26695. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  26696. if m.addaccount_balance != nil {
  26697. *m.addaccount_balance += u
  26698. } else {
  26699. m.addaccount_balance = &u
  26700. }
  26701. }
  26702. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  26703. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  26704. v := m.addaccount_balance
  26705. if v == nil {
  26706. return
  26707. }
  26708. return *v, true
  26709. }
  26710. // ResetAccountBalance resets all changes to the "account_balance" field.
  26711. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  26712. m.account_balance = nil
  26713. m.addaccount_balance = nil
  26714. }
  26715. // SetConsumeToken sets the "consume_token" field.
  26716. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  26717. m.consume_token = &u
  26718. m.addconsume_token = nil
  26719. }
  26720. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  26721. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  26722. v := m.consume_token
  26723. if v == nil {
  26724. return
  26725. }
  26726. return *v, true
  26727. }
  26728. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  26729. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26731. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  26732. if !m.op.Is(OpUpdateOne) {
  26733. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  26734. }
  26735. if m.id == nil || m.oldValue == nil {
  26736. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  26737. }
  26738. oldValue, err := m.oldValue(ctx)
  26739. if err != nil {
  26740. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  26741. }
  26742. return oldValue.ConsumeToken, nil
  26743. }
  26744. // AddConsumeToken adds u to the "consume_token" field.
  26745. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  26746. if m.addconsume_token != nil {
  26747. *m.addconsume_token += u
  26748. } else {
  26749. m.addconsume_token = &u
  26750. }
  26751. }
  26752. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  26753. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  26754. v := m.addconsume_token
  26755. if v == nil {
  26756. return
  26757. }
  26758. return *v, true
  26759. }
  26760. // ResetConsumeToken resets all changes to the "consume_token" field.
  26761. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  26762. m.consume_token = nil
  26763. m.addconsume_token = nil
  26764. }
  26765. // SetActiveUser sets the "active_user" field.
  26766. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  26767. m.active_user = &u
  26768. m.addactive_user = nil
  26769. }
  26770. // ActiveUser returns the value of the "active_user" field in the mutation.
  26771. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  26772. v := m.active_user
  26773. if v == nil {
  26774. return
  26775. }
  26776. return *v, true
  26777. }
  26778. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  26779. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26781. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  26782. if !m.op.Is(OpUpdateOne) {
  26783. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  26784. }
  26785. if m.id == nil || m.oldValue == nil {
  26786. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  26787. }
  26788. oldValue, err := m.oldValue(ctx)
  26789. if err != nil {
  26790. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  26791. }
  26792. return oldValue.ActiveUser, nil
  26793. }
  26794. // AddActiveUser adds u to the "active_user" field.
  26795. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  26796. if m.addactive_user != nil {
  26797. *m.addactive_user += u
  26798. } else {
  26799. m.addactive_user = &u
  26800. }
  26801. }
  26802. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  26803. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  26804. v := m.addactive_user
  26805. if v == nil {
  26806. return
  26807. }
  26808. return *v, true
  26809. }
  26810. // ResetActiveUser resets all changes to the "active_user" field.
  26811. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  26812. m.active_user = nil
  26813. m.addactive_user = nil
  26814. }
  26815. // SetNewUser sets the "new_user" field.
  26816. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  26817. m.new_user = &i
  26818. m.addnew_user = nil
  26819. }
  26820. // NewUser returns the value of the "new_user" field in the mutation.
  26821. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  26822. v := m.new_user
  26823. if v == nil {
  26824. return
  26825. }
  26826. return *v, true
  26827. }
  26828. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  26829. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26831. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  26832. if !m.op.Is(OpUpdateOne) {
  26833. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  26834. }
  26835. if m.id == nil || m.oldValue == nil {
  26836. return v, errors.New("OldNewUser requires an ID field in the mutation")
  26837. }
  26838. oldValue, err := m.oldValue(ctx)
  26839. if err != nil {
  26840. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  26841. }
  26842. return oldValue.NewUser, nil
  26843. }
  26844. // AddNewUser adds i to the "new_user" field.
  26845. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  26846. if m.addnew_user != nil {
  26847. *m.addnew_user += i
  26848. } else {
  26849. m.addnew_user = &i
  26850. }
  26851. }
  26852. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  26853. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  26854. v := m.addnew_user
  26855. if v == nil {
  26856. return
  26857. }
  26858. return *v, true
  26859. }
  26860. // ResetNewUser resets all changes to the "new_user" field.
  26861. func (m *UsageStatisticHourMutation) ResetNewUser() {
  26862. m.new_user = nil
  26863. m.addnew_user = nil
  26864. }
  26865. // SetLabelDist sets the "label_dist" field.
  26866. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  26867. m.label_dist = &ctd
  26868. m.appendlabel_dist = nil
  26869. }
  26870. // LabelDist returns the value of the "label_dist" field in the mutation.
  26871. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  26872. v := m.label_dist
  26873. if v == nil {
  26874. return
  26875. }
  26876. return *v, true
  26877. }
  26878. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  26879. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26881. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  26882. if !m.op.Is(OpUpdateOne) {
  26883. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  26884. }
  26885. if m.id == nil || m.oldValue == nil {
  26886. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  26887. }
  26888. oldValue, err := m.oldValue(ctx)
  26889. if err != nil {
  26890. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  26891. }
  26892. return oldValue.LabelDist, nil
  26893. }
  26894. // AppendLabelDist adds ctd to the "label_dist" field.
  26895. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  26896. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  26897. }
  26898. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  26899. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  26900. if len(m.appendlabel_dist) == 0 {
  26901. return nil, false
  26902. }
  26903. return m.appendlabel_dist, true
  26904. }
  26905. // ResetLabelDist resets all changes to the "label_dist" field.
  26906. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  26907. m.label_dist = nil
  26908. m.appendlabel_dist = nil
  26909. }
  26910. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  26911. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  26912. m.predicates = append(m.predicates, ps...)
  26913. }
  26914. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  26915. // users can use type-assertion to append predicates that do not depend on any generated package.
  26916. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  26917. p := make([]predicate.UsageStatisticHour, len(ps))
  26918. for i := range ps {
  26919. p[i] = ps[i]
  26920. }
  26921. m.Where(p...)
  26922. }
  26923. // Op returns the operation name.
  26924. func (m *UsageStatisticHourMutation) Op() Op {
  26925. return m.op
  26926. }
  26927. // SetOp allows setting the mutation operation.
  26928. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  26929. m.op = op
  26930. }
  26931. // Type returns the node type of this mutation (UsageStatisticHour).
  26932. func (m *UsageStatisticHourMutation) Type() string {
  26933. return m.typ
  26934. }
  26935. // Fields returns all fields that were changed during this mutation. Note that in
  26936. // order to get all numeric fields that were incremented/decremented, call
  26937. // AddedFields().
  26938. func (m *UsageStatisticHourMutation) Fields() []string {
  26939. fields := make([]string, 0, 17)
  26940. if m.created_at != nil {
  26941. fields = append(fields, usagestatistichour.FieldCreatedAt)
  26942. }
  26943. if m.updated_at != nil {
  26944. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  26945. }
  26946. if m.status != nil {
  26947. fields = append(fields, usagestatistichour.FieldStatus)
  26948. }
  26949. if m.deleted_at != nil {
  26950. fields = append(fields, usagestatistichour.FieldDeletedAt)
  26951. }
  26952. if m.addtime != nil {
  26953. fields = append(fields, usagestatistichour.FieldAddtime)
  26954. }
  26955. if m._type != nil {
  26956. fields = append(fields, usagestatistichour.FieldType)
  26957. }
  26958. if m.bot_id != nil {
  26959. fields = append(fields, usagestatistichour.FieldBotID)
  26960. }
  26961. if m.organization_id != nil {
  26962. fields = append(fields, usagestatistichour.FieldOrganizationID)
  26963. }
  26964. if m.ai_response != nil {
  26965. fields = append(fields, usagestatistichour.FieldAiResponse)
  26966. }
  26967. if m.sop_run != nil {
  26968. fields = append(fields, usagestatistichour.FieldSopRun)
  26969. }
  26970. if m.total_friend != nil {
  26971. fields = append(fields, usagestatistichour.FieldTotalFriend)
  26972. }
  26973. if m.total_group != nil {
  26974. fields = append(fields, usagestatistichour.FieldTotalGroup)
  26975. }
  26976. if m.account_balance != nil {
  26977. fields = append(fields, usagestatistichour.FieldAccountBalance)
  26978. }
  26979. if m.consume_token != nil {
  26980. fields = append(fields, usagestatistichour.FieldConsumeToken)
  26981. }
  26982. if m.active_user != nil {
  26983. fields = append(fields, usagestatistichour.FieldActiveUser)
  26984. }
  26985. if m.new_user != nil {
  26986. fields = append(fields, usagestatistichour.FieldNewUser)
  26987. }
  26988. if m.label_dist != nil {
  26989. fields = append(fields, usagestatistichour.FieldLabelDist)
  26990. }
  26991. return fields
  26992. }
  26993. // Field returns the value of a field with the given name. The second boolean
  26994. // return value indicates that this field was not set, or was not defined in the
  26995. // schema.
  26996. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  26997. switch name {
  26998. case usagestatistichour.FieldCreatedAt:
  26999. return m.CreatedAt()
  27000. case usagestatistichour.FieldUpdatedAt:
  27001. return m.UpdatedAt()
  27002. case usagestatistichour.FieldStatus:
  27003. return m.Status()
  27004. case usagestatistichour.FieldDeletedAt:
  27005. return m.DeletedAt()
  27006. case usagestatistichour.FieldAddtime:
  27007. return m.Addtime()
  27008. case usagestatistichour.FieldType:
  27009. return m.GetType()
  27010. case usagestatistichour.FieldBotID:
  27011. return m.BotID()
  27012. case usagestatistichour.FieldOrganizationID:
  27013. return m.OrganizationID()
  27014. case usagestatistichour.FieldAiResponse:
  27015. return m.AiResponse()
  27016. case usagestatistichour.FieldSopRun:
  27017. return m.SopRun()
  27018. case usagestatistichour.FieldTotalFriend:
  27019. return m.TotalFriend()
  27020. case usagestatistichour.FieldTotalGroup:
  27021. return m.TotalGroup()
  27022. case usagestatistichour.FieldAccountBalance:
  27023. return m.AccountBalance()
  27024. case usagestatistichour.FieldConsumeToken:
  27025. return m.ConsumeToken()
  27026. case usagestatistichour.FieldActiveUser:
  27027. return m.ActiveUser()
  27028. case usagestatistichour.FieldNewUser:
  27029. return m.NewUser()
  27030. case usagestatistichour.FieldLabelDist:
  27031. return m.LabelDist()
  27032. }
  27033. return nil, false
  27034. }
  27035. // OldField returns the old value of the field from the database. An error is
  27036. // returned if the mutation operation is not UpdateOne, or the query to the
  27037. // database failed.
  27038. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27039. switch name {
  27040. case usagestatistichour.FieldCreatedAt:
  27041. return m.OldCreatedAt(ctx)
  27042. case usagestatistichour.FieldUpdatedAt:
  27043. return m.OldUpdatedAt(ctx)
  27044. case usagestatistichour.FieldStatus:
  27045. return m.OldStatus(ctx)
  27046. case usagestatistichour.FieldDeletedAt:
  27047. return m.OldDeletedAt(ctx)
  27048. case usagestatistichour.FieldAddtime:
  27049. return m.OldAddtime(ctx)
  27050. case usagestatistichour.FieldType:
  27051. return m.OldType(ctx)
  27052. case usagestatistichour.FieldBotID:
  27053. return m.OldBotID(ctx)
  27054. case usagestatistichour.FieldOrganizationID:
  27055. return m.OldOrganizationID(ctx)
  27056. case usagestatistichour.FieldAiResponse:
  27057. return m.OldAiResponse(ctx)
  27058. case usagestatistichour.FieldSopRun:
  27059. return m.OldSopRun(ctx)
  27060. case usagestatistichour.FieldTotalFriend:
  27061. return m.OldTotalFriend(ctx)
  27062. case usagestatistichour.FieldTotalGroup:
  27063. return m.OldTotalGroup(ctx)
  27064. case usagestatistichour.FieldAccountBalance:
  27065. return m.OldAccountBalance(ctx)
  27066. case usagestatistichour.FieldConsumeToken:
  27067. return m.OldConsumeToken(ctx)
  27068. case usagestatistichour.FieldActiveUser:
  27069. return m.OldActiveUser(ctx)
  27070. case usagestatistichour.FieldNewUser:
  27071. return m.OldNewUser(ctx)
  27072. case usagestatistichour.FieldLabelDist:
  27073. return m.OldLabelDist(ctx)
  27074. }
  27075. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  27076. }
  27077. // SetField sets the value of a field with the given name. It returns an error if
  27078. // the field is not defined in the schema, or if the type mismatched the field
  27079. // type.
  27080. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  27081. switch name {
  27082. case usagestatistichour.FieldCreatedAt:
  27083. v, ok := value.(time.Time)
  27084. if !ok {
  27085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27086. }
  27087. m.SetCreatedAt(v)
  27088. return nil
  27089. case usagestatistichour.FieldUpdatedAt:
  27090. v, ok := value.(time.Time)
  27091. if !ok {
  27092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27093. }
  27094. m.SetUpdatedAt(v)
  27095. return nil
  27096. case usagestatistichour.FieldStatus:
  27097. v, ok := value.(uint8)
  27098. if !ok {
  27099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27100. }
  27101. m.SetStatus(v)
  27102. return nil
  27103. case usagestatistichour.FieldDeletedAt:
  27104. v, ok := value.(time.Time)
  27105. if !ok {
  27106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27107. }
  27108. m.SetDeletedAt(v)
  27109. return nil
  27110. case usagestatistichour.FieldAddtime:
  27111. v, ok := value.(uint64)
  27112. if !ok {
  27113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27114. }
  27115. m.SetAddtime(v)
  27116. return nil
  27117. case usagestatistichour.FieldType:
  27118. v, ok := value.(int)
  27119. if !ok {
  27120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27121. }
  27122. m.SetType(v)
  27123. return nil
  27124. case usagestatistichour.FieldBotID:
  27125. v, ok := value.(string)
  27126. if !ok {
  27127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27128. }
  27129. m.SetBotID(v)
  27130. return nil
  27131. case usagestatistichour.FieldOrganizationID:
  27132. v, ok := value.(uint64)
  27133. if !ok {
  27134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27135. }
  27136. m.SetOrganizationID(v)
  27137. return nil
  27138. case usagestatistichour.FieldAiResponse:
  27139. v, ok := value.(uint64)
  27140. if !ok {
  27141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27142. }
  27143. m.SetAiResponse(v)
  27144. return nil
  27145. case usagestatistichour.FieldSopRun:
  27146. v, ok := value.(uint64)
  27147. if !ok {
  27148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27149. }
  27150. m.SetSopRun(v)
  27151. return nil
  27152. case usagestatistichour.FieldTotalFriend:
  27153. v, ok := value.(uint64)
  27154. if !ok {
  27155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27156. }
  27157. m.SetTotalFriend(v)
  27158. return nil
  27159. case usagestatistichour.FieldTotalGroup:
  27160. v, ok := value.(uint64)
  27161. if !ok {
  27162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27163. }
  27164. m.SetTotalGroup(v)
  27165. return nil
  27166. case usagestatistichour.FieldAccountBalance:
  27167. v, ok := value.(uint64)
  27168. if !ok {
  27169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27170. }
  27171. m.SetAccountBalance(v)
  27172. return nil
  27173. case usagestatistichour.FieldConsumeToken:
  27174. v, ok := value.(uint64)
  27175. if !ok {
  27176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27177. }
  27178. m.SetConsumeToken(v)
  27179. return nil
  27180. case usagestatistichour.FieldActiveUser:
  27181. v, ok := value.(uint64)
  27182. if !ok {
  27183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27184. }
  27185. m.SetActiveUser(v)
  27186. return nil
  27187. case usagestatistichour.FieldNewUser:
  27188. v, ok := value.(int64)
  27189. if !ok {
  27190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27191. }
  27192. m.SetNewUser(v)
  27193. return nil
  27194. case usagestatistichour.FieldLabelDist:
  27195. v, ok := value.([]custom_types.LabelDist)
  27196. if !ok {
  27197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27198. }
  27199. m.SetLabelDist(v)
  27200. return nil
  27201. }
  27202. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  27203. }
  27204. // AddedFields returns all numeric fields that were incremented/decremented during
  27205. // this mutation.
  27206. func (m *UsageStatisticHourMutation) AddedFields() []string {
  27207. var fields []string
  27208. if m.addstatus != nil {
  27209. fields = append(fields, usagestatistichour.FieldStatus)
  27210. }
  27211. if m.addaddtime != nil {
  27212. fields = append(fields, usagestatistichour.FieldAddtime)
  27213. }
  27214. if m.add_type != nil {
  27215. fields = append(fields, usagestatistichour.FieldType)
  27216. }
  27217. if m.addorganization_id != nil {
  27218. fields = append(fields, usagestatistichour.FieldOrganizationID)
  27219. }
  27220. if m.addai_response != nil {
  27221. fields = append(fields, usagestatistichour.FieldAiResponse)
  27222. }
  27223. if m.addsop_run != nil {
  27224. fields = append(fields, usagestatistichour.FieldSopRun)
  27225. }
  27226. if m.addtotal_friend != nil {
  27227. fields = append(fields, usagestatistichour.FieldTotalFriend)
  27228. }
  27229. if m.addtotal_group != nil {
  27230. fields = append(fields, usagestatistichour.FieldTotalGroup)
  27231. }
  27232. if m.addaccount_balance != nil {
  27233. fields = append(fields, usagestatistichour.FieldAccountBalance)
  27234. }
  27235. if m.addconsume_token != nil {
  27236. fields = append(fields, usagestatistichour.FieldConsumeToken)
  27237. }
  27238. if m.addactive_user != nil {
  27239. fields = append(fields, usagestatistichour.FieldActiveUser)
  27240. }
  27241. if m.addnew_user != nil {
  27242. fields = append(fields, usagestatistichour.FieldNewUser)
  27243. }
  27244. return fields
  27245. }
  27246. // AddedField returns the numeric value that was incremented/decremented on a field
  27247. // with the given name. The second boolean return value indicates that this field
  27248. // was not set, or was not defined in the schema.
  27249. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  27250. switch name {
  27251. case usagestatistichour.FieldStatus:
  27252. return m.AddedStatus()
  27253. case usagestatistichour.FieldAddtime:
  27254. return m.AddedAddtime()
  27255. case usagestatistichour.FieldType:
  27256. return m.AddedType()
  27257. case usagestatistichour.FieldOrganizationID:
  27258. return m.AddedOrganizationID()
  27259. case usagestatistichour.FieldAiResponse:
  27260. return m.AddedAiResponse()
  27261. case usagestatistichour.FieldSopRun:
  27262. return m.AddedSopRun()
  27263. case usagestatistichour.FieldTotalFriend:
  27264. return m.AddedTotalFriend()
  27265. case usagestatistichour.FieldTotalGroup:
  27266. return m.AddedTotalGroup()
  27267. case usagestatistichour.FieldAccountBalance:
  27268. return m.AddedAccountBalance()
  27269. case usagestatistichour.FieldConsumeToken:
  27270. return m.AddedConsumeToken()
  27271. case usagestatistichour.FieldActiveUser:
  27272. return m.AddedActiveUser()
  27273. case usagestatistichour.FieldNewUser:
  27274. return m.AddedNewUser()
  27275. }
  27276. return nil, false
  27277. }
  27278. // AddField adds the value to the field with the given name. It returns an error if
  27279. // the field is not defined in the schema, or if the type mismatched the field
  27280. // type.
  27281. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  27282. switch name {
  27283. case usagestatistichour.FieldStatus:
  27284. v, ok := value.(int8)
  27285. if !ok {
  27286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27287. }
  27288. m.AddStatus(v)
  27289. return nil
  27290. case usagestatistichour.FieldAddtime:
  27291. v, ok := value.(int64)
  27292. if !ok {
  27293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27294. }
  27295. m.AddAddtime(v)
  27296. return nil
  27297. case usagestatistichour.FieldType:
  27298. v, ok := value.(int)
  27299. if !ok {
  27300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27301. }
  27302. m.AddType(v)
  27303. return nil
  27304. case usagestatistichour.FieldOrganizationID:
  27305. v, ok := value.(int64)
  27306. if !ok {
  27307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27308. }
  27309. m.AddOrganizationID(v)
  27310. return nil
  27311. case usagestatistichour.FieldAiResponse:
  27312. v, ok := value.(int64)
  27313. if !ok {
  27314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27315. }
  27316. m.AddAiResponse(v)
  27317. return nil
  27318. case usagestatistichour.FieldSopRun:
  27319. v, ok := value.(int64)
  27320. if !ok {
  27321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27322. }
  27323. m.AddSopRun(v)
  27324. return nil
  27325. case usagestatistichour.FieldTotalFriend:
  27326. v, ok := value.(int64)
  27327. if !ok {
  27328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27329. }
  27330. m.AddTotalFriend(v)
  27331. return nil
  27332. case usagestatistichour.FieldTotalGroup:
  27333. v, ok := value.(int64)
  27334. if !ok {
  27335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27336. }
  27337. m.AddTotalGroup(v)
  27338. return nil
  27339. case usagestatistichour.FieldAccountBalance:
  27340. v, ok := value.(int64)
  27341. if !ok {
  27342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27343. }
  27344. m.AddAccountBalance(v)
  27345. return nil
  27346. case usagestatistichour.FieldConsumeToken:
  27347. v, ok := value.(int64)
  27348. if !ok {
  27349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27350. }
  27351. m.AddConsumeToken(v)
  27352. return nil
  27353. case usagestatistichour.FieldActiveUser:
  27354. v, ok := value.(int64)
  27355. if !ok {
  27356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27357. }
  27358. m.AddActiveUser(v)
  27359. return nil
  27360. case usagestatistichour.FieldNewUser:
  27361. v, ok := value.(int64)
  27362. if !ok {
  27363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27364. }
  27365. m.AddNewUser(v)
  27366. return nil
  27367. }
  27368. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  27369. }
  27370. // ClearedFields returns all nullable fields that were cleared during this
  27371. // mutation.
  27372. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  27373. var fields []string
  27374. if m.FieldCleared(usagestatistichour.FieldStatus) {
  27375. fields = append(fields, usagestatistichour.FieldStatus)
  27376. }
  27377. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  27378. fields = append(fields, usagestatistichour.FieldDeletedAt)
  27379. }
  27380. if m.FieldCleared(usagestatistichour.FieldBotID) {
  27381. fields = append(fields, usagestatistichour.FieldBotID)
  27382. }
  27383. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  27384. fields = append(fields, usagestatistichour.FieldOrganizationID)
  27385. }
  27386. return fields
  27387. }
  27388. // FieldCleared returns a boolean indicating if a field with the given name was
  27389. // cleared in this mutation.
  27390. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  27391. _, ok := m.clearedFields[name]
  27392. return ok
  27393. }
  27394. // ClearField clears the value of the field with the given name. It returns an
  27395. // error if the field is not defined in the schema.
  27396. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  27397. switch name {
  27398. case usagestatistichour.FieldStatus:
  27399. m.ClearStatus()
  27400. return nil
  27401. case usagestatistichour.FieldDeletedAt:
  27402. m.ClearDeletedAt()
  27403. return nil
  27404. case usagestatistichour.FieldBotID:
  27405. m.ClearBotID()
  27406. return nil
  27407. case usagestatistichour.FieldOrganizationID:
  27408. m.ClearOrganizationID()
  27409. return nil
  27410. }
  27411. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  27412. }
  27413. // ResetField resets all changes in the mutation for the field with the given name.
  27414. // It returns an error if the field is not defined in the schema.
  27415. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  27416. switch name {
  27417. case usagestatistichour.FieldCreatedAt:
  27418. m.ResetCreatedAt()
  27419. return nil
  27420. case usagestatistichour.FieldUpdatedAt:
  27421. m.ResetUpdatedAt()
  27422. return nil
  27423. case usagestatistichour.FieldStatus:
  27424. m.ResetStatus()
  27425. return nil
  27426. case usagestatistichour.FieldDeletedAt:
  27427. m.ResetDeletedAt()
  27428. return nil
  27429. case usagestatistichour.FieldAddtime:
  27430. m.ResetAddtime()
  27431. return nil
  27432. case usagestatistichour.FieldType:
  27433. m.ResetType()
  27434. return nil
  27435. case usagestatistichour.FieldBotID:
  27436. m.ResetBotID()
  27437. return nil
  27438. case usagestatistichour.FieldOrganizationID:
  27439. m.ResetOrganizationID()
  27440. return nil
  27441. case usagestatistichour.FieldAiResponse:
  27442. m.ResetAiResponse()
  27443. return nil
  27444. case usagestatistichour.FieldSopRun:
  27445. m.ResetSopRun()
  27446. return nil
  27447. case usagestatistichour.FieldTotalFriend:
  27448. m.ResetTotalFriend()
  27449. return nil
  27450. case usagestatistichour.FieldTotalGroup:
  27451. m.ResetTotalGroup()
  27452. return nil
  27453. case usagestatistichour.FieldAccountBalance:
  27454. m.ResetAccountBalance()
  27455. return nil
  27456. case usagestatistichour.FieldConsumeToken:
  27457. m.ResetConsumeToken()
  27458. return nil
  27459. case usagestatistichour.FieldActiveUser:
  27460. m.ResetActiveUser()
  27461. return nil
  27462. case usagestatistichour.FieldNewUser:
  27463. m.ResetNewUser()
  27464. return nil
  27465. case usagestatistichour.FieldLabelDist:
  27466. m.ResetLabelDist()
  27467. return nil
  27468. }
  27469. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  27470. }
  27471. // AddedEdges returns all edge names that were set/added in this mutation.
  27472. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  27473. edges := make([]string, 0, 0)
  27474. return edges
  27475. }
  27476. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27477. // name in this mutation.
  27478. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  27479. return nil
  27480. }
  27481. // RemovedEdges returns all edge names that were removed in this mutation.
  27482. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  27483. edges := make([]string, 0, 0)
  27484. return edges
  27485. }
  27486. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27487. // the given name in this mutation.
  27488. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  27489. return nil
  27490. }
  27491. // ClearedEdges returns all edge names that were cleared in this mutation.
  27492. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  27493. edges := make([]string, 0, 0)
  27494. return edges
  27495. }
  27496. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27497. // was cleared in this mutation.
  27498. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  27499. return false
  27500. }
  27501. // ClearEdge clears the value of the edge with the given name. It returns an error
  27502. // if that edge is not defined in the schema.
  27503. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  27504. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  27505. }
  27506. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27507. // It returns an error if the edge is not defined in the schema.
  27508. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  27509. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  27510. }
  27511. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  27512. type UsageStatisticMonthMutation struct {
  27513. config
  27514. op Op
  27515. typ string
  27516. id *uint64
  27517. created_at *time.Time
  27518. updated_at *time.Time
  27519. status *uint8
  27520. addstatus *int8
  27521. deleted_at *time.Time
  27522. addtime *uint64
  27523. addaddtime *int64
  27524. _type *int
  27525. add_type *int
  27526. bot_id *string
  27527. organization_id *uint64
  27528. addorganization_id *int64
  27529. ai_response *uint64
  27530. addai_response *int64
  27531. sop_run *uint64
  27532. addsop_run *int64
  27533. total_friend *uint64
  27534. addtotal_friend *int64
  27535. total_group *uint64
  27536. addtotal_group *int64
  27537. account_balance *uint64
  27538. addaccount_balance *int64
  27539. consume_token *uint64
  27540. addconsume_token *int64
  27541. active_user *uint64
  27542. addactive_user *int64
  27543. new_user *int64
  27544. addnew_user *int64
  27545. label_dist *[]custom_types.LabelDist
  27546. appendlabel_dist []custom_types.LabelDist
  27547. clearedFields map[string]struct{}
  27548. done bool
  27549. oldValue func(context.Context) (*UsageStatisticMonth, error)
  27550. predicates []predicate.UsageStatisticMonth
  27551. }
  27552. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  27553. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  27554. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  27555. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  27556. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  27557. m := &UsageStatisticMonthMutation{
  27558. config: c,
  27559. op: op,
  27560. typ: TypeUsageStatisticMonth,
  27561. clearedFields: make(map[string]struct{}),
  27562. }
  27563. for _, opt := range opts {
  27564. opt(m)
  27565. }
  27566. return m
  27567. }
  27568. // withUsageStatisticMonthID sets the ID field of the mutation.
  27569. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  27570. return func(m *UsageStatisticMonthMutation) {
  27571. var (
  27572. err error
  27573. once sync.Once
  27574. value *UsageStatisticMonth
  27575. )
  27576. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  27577. once.Do(func() {
  27578. if m.done {
  27579. err = errors.New("querying old values post mutation is not allowed")
  27580. } else {
  27581. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  27582. }
  27583. })
  27584. return value, err
  27585. }
  27586. m.id = &id
  27587. }
  27588. }
  27589. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  27590. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  27591. return func(m *UsageStatisticMonthMutation) {
  27592. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  27593. return node, nil
  27594. }
  27595. m.id = &node.ID
  27596. }
  27597. }
  27598. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27599. // executed in a transaction (ent.Tx), a transactional client is returned.
  27600. func (m UsageStatisticMonthMutation) Client() *Client {
  27601. client := &Client{config: m.config}
  27602. client.init()
  27603. return client
  27604. }
  27605. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27606. // it returns an error otherwise.
  27607. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  27608. if _, ok := m.driver.(*txDriver); !ok {
  27609. return nil, errors.New("ent: mutation is not running in a transaction")
  27610. }
  27611. tx := &Tx{config: m.config}
  27612. tx.init()
  27613. return tx, nil
  27614. }
  27615. // SetID sets the value of the id field. Note that this
  27616. // operation is only accepted on creation of UsageStatisticMonth entities.
  27617. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  27618. m.id = &id
  27619. }
  27620. // ID returns the ID value in the mutation. Note that the ID is only available
  27621. // if it was provided to the builder or after it was returned from the database.
  27622. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  27623. if m.id == nil {
  27624. return
  27625. }
  27626. return *m.id, true
  27627. }
  27628. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27629. // That means, if the mutation is applied within a transaction with an isolation level such
  27630. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27631. // or updated by the mutation.
  27632. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  27633. switch {
  27634. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27635. id, exists := m.ID()
  27636. if exists {
  27637. return []uint64{id}, nil
  27638. }
  27639. fallthrough
  27640. case m.op.Is(OpUpdate | OpDelete):
  27641. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  27642. default:
  27643. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27644. }
  27645. }
  27646. // SetCreatedAt sets the "created_at" field.
  27647. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  27648. m.created_at = &t
  27649. }
  27650. // CreatedAt returns the value of the "created_at" field in the mutation.
  27651. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  27652. v := m.created_at
  27653. if v == nil {
  27654. return
  27655. }
  27656. return *v, true
  27657. }
  27658. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  27659. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27661. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27662. if !m.op.Is(OpUpdateOne) {
  27663. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27664. }
  27665. if m.id == nil || m.oldValue == nil {
  27666. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27667. }
  27668. oldValue, err := m.oldValue(ctx)
  27669. if err != nil {
  27670. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27671. }
  27672. return oldValue.CreatedAt, nil
  27673. }
  27674. // ResetCreatedAt resets all changes to the "created_at" field.
  27675. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  27676. m.created_at = nil
  27677. }
  27678. // SetUpdatedAt sets the "updated_at" field.
  27679. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  27680. m.updated_at = &t
  27681. }
  27682. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27683. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  27684. v := m.updated_at
  27685. if v == nil {
  27686. return
  27687. }
  27688. return *v, true
  27689. }
  27690. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  27691. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27693. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27694. if !m.op.Is(OpUpdateOne) {
  27695. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27696. }
  27697. if m.id == nil || m.oldValue == nil {
  27698. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27699. }
  27700. oldValue, err := m.oldValue(ctx)
  27701. if err != nil {
  27702. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27703. }
  27704. return oldValue.UpdatedAt, nil
  27705. }
  27706. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27707. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  27708. m.updated_at = nil
  27709. }
  27710. // SetStatus sets the "status" field.
  27711. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  27712. m.status = &u
  27713. m.addstatus = nil
  27714. }
  27715. // Status returns the value of the "status" field in the mutation.
  27716. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  27717. v := m.status
  27718. if v == nil {
  27719. return
  27720. }
  27721. return *v, true
  27722. }
  27723. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  27724. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27726. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27727. if !m.op.Is(OpUpdateOne) {
  27728. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27729. }
  27730. if m.id == nil || m.oldValue == nil {
  27731. return v, errors.New("OldStatus requires an ID field in the mutation")
  27732. }
  27733. oldValue, err := m.oldValue(ctx)
  27734. if err != nil {
  27735. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27736. }
  27737. return oldValue.Status, nil
  27738. }
  27739. // AddStatus adds u to the "status" field.
  27740. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  27741. if m.addstatus != nil {
  27742. *m.addstatus += u
  27743. } else {
  27744. m.addstatus = &u
  27745. }
  27746. }
  27747. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27748. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  27749. v := m.addstatus
  27750. if v == nil {
  27751. return
  27752. }
  27753. return *v, true
  27754. }
  27755. // ClearStatus clears the value of the "status" field.
  27756. func (m *UsageStatisticMonthMutation) ClearStatus() {
  27757. m.status = nil
  27758. m.addstatus = nil
  27759. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  27760. }
  27761. // StatusCleared returns if the "status" field was cleared in this mutation.
  27762. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  27763. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  27764. return ok
  27765. }
  27766. // ResetStatus resets all changes to the "status" field.
  27767. func (m *UsageStatisticMonthMutation) ResetStatus() {
  27768. m.status = nil
  27769. m.addstatus = nil
  27770. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  27771. }
  27772. // SetDeletedAt sets the "deleted_at" field.
  27773. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  27774. m.deleted_at = &t
  27775. }
  27776. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27777. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  27778. v := m.deleted_at
  27779. if v == nil {
  27780. return
  27781. }
  27782. return *v, true
  27783. }
  27784. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  27785. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27787. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27788. if !m.op.Is(OpUpdateOne) {
  27789. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27790. }
  27791. if m.id == nil || m.oldValue == nil {
  27792. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27793. }
  27794. oldValue, err := m.oldValue(ctx)
  27795. if err != nil {
  27796. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27797. }
  27798. return oldValue.DeletedAt, nil
  27799. }
  27800. // ClearDeletedAt clears the value of the "deleted_at" field.
  27801. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  27802. m.deleted_at = nil
  27803. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  27804. }
  27805. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27806. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  27807. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  27808. return ok
  27809. }
  27810. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27811. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  27812. m.deleted_at = nil
  27813. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  27814. }
  27815. // SetAddtime sets the "addtime" field.
  27816. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  27817. m.addtime = &u
  27818. m.addaddtime = nil
  27819. }
  27820. // Addtime returns the value of the "addtime" field in the mutation.
  27821. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  27822. v := m.addtime
  27823. if v == nil {
  27824. return
  27825. }
  27826. return *v, true
  27827. }
  27828. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  27829. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27831. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  27832. if !m.op.Is(OpUpdateOne) {
  27833. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  27834. }
  27835. if m.id == nil || m.oldValue == nil {
  27836. return v, errors.New("OldAddtime requires an ID field in the mutation")
  27837. }
  27838. oldValue, err := m.oldValue(ctx)
  27839. if err != nil {
  27840. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  27841. }
  27842. return oldValue.Addtime, nil
  27843. }
  27844. // AddAddtime adds u to the "addtime" field.
  27845. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  27846. if m.addaddtime != nil {
  27847. *m.addaddtime += u
  27848. } else {
  27849. m.addaddtime = &u
  27850. }
  27851. }
  27852. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  27853. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  27854. v := m.addaddtime
  27855. if v == nil {
  27856. return
  27857. }
  27858. return *v, true
  27859. }
  27860. // ResetAddtime resets all changes to the "addtime" field.
  27861. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  27862. m.addtime = nil
  27863. m.addaddtime = nil
  27864. }
  27865. // SetType sets the "type" field.
  27866. func (m *UsageStatisticMonthMutation) SetType(i int) {
  27867. m._type = &i
  27868. m.add_type = nil
  27869. }
  27870. // GetType returns the value of the "type" field in the mutation.
  27871. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  27872. v := m._type
  27873. if v == nil {
  27874. return
  27875. }
  27876. return *v, true
  27877. }
  27878. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  27879. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27881. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  27882. if !m.op.Is(OpUpdateOne) {
  27883. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27884. }
  27885. if m.id == nil || m.oldValue == nil {
  27886. return v, errors.New("OldType requires an ID field in the mutation")
  27887. }
  27888. oldValue, err := m.oldValue(ctx)
  27889. if err != nil {
  27890. return v, fmt.Errorf("querying old value for OldType: %w", err)
  27891. }
  27892. return oldValue.Type, nil
  27893. }
  27894. // AddType adds i to the "type" field.
  27895. func (m *UsageStatisticMonthMutation) AddType(i int) {
  27896. if m.add_type != nil {
  27897. *m.add_type += i
  27898. } else {
  27899. m.add_type = &i
  27900. }
  27901. }
  27902. // AddedType returns the value that was added to the "type" field in this mutation.
  27903. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  27904. v := m.add_type
  27905. if v == nil {
  27906. return
  27907. }
  27908. return *v, true
  27909. }
  27910. // ResetType resets all changes to the "type" field.
  27911. func (m *UsageStatisticMonthMutation) ResetType() {
  27912. m._type = nil
  27913. m.add_type = nil
  27914. }
  27915. // SetBotID sets the "bot_id" field.
  27916. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  27917. m.bot_id = &s
  27918. }
  27919. // BotID returns the value of the "bot_id" field in the mutation.
  27920. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  27921. v := m.bot_id
  27922. if v == nil {
  27923. return
  27924. }
  27925. return *v, true
  27926. }
  27927. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  27928. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27930. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  27931. if !m.op.Is(OpUpdateOne) {
  27932. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27933. }
  27934. if m.id == nil || m.oldValue == nil {
  27935. return v, errors.New("OldBotID requires an ID field in the mutation")
  27936. }
  27937. oldValue, err := m.oldValue(ctx)
  27938. if err != nil {
  27939. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27940. }
  27941. return oldValue.BotID, nil
  27942. }
  27943. // ClearBotID clears the value of the "bot_id" field.
  27944. func (m *UsageStatisticMonthMutation) ClearBotID() {
  27945. m.bot_id = nil
  27946. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  27947. }
  27948. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  27949. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  27950. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  27951. return ok
  27952. }
  27953. // ResetBotID resets all changes to the "bot_id" field.
  27954. func (m *UsageStatisticMonthMutation) ResetBotID() {
  27955. m.bot_id = nil
  27956. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  27957. }
  27958. // SetOrganizationID sets the "organization_id" field.
  27959. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  27960. m.organization_id = &u
  27961. m.addorganization_id = nil
  27962. }
  27963. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27964. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  27965. v := m.organization_id
  27966. if v == nil {
  27967. return
  27968. }
  27969. return *v, true
  27970. }
  27971. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  27972. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27974. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27975. if !m.op.Is(OpUpdateOne) {
  27976. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27977. }
  27978. if m.id == nil || m.oldValue == nil {
  27979. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27980. }
  27981. oldValue, err := m.oldValue(ctx)
  27982. if err != nil {
  27983. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27984. }
  27985. return oldValue.OrganizationID, nil
  27986. }
  27987. // AddOrganizationID adds u to the "organization_id" field.
  27988. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  27989. if m.addorganization_id != nil {
  27990. *m.addorganization_id += u
  27991. } else {
  27992. m.addorganization_id = &u
  27993. }
  27994. }
  27995. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27996. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  27997. v := m.addorganization_id
  27998. if v == nil {
  27999. return
  28000. }
  28001. return *v, true
  28002. }
  28003. // ClearOrganizationID clears the value of the "organization_id" field.
  28004. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  28005. m.organization_id = nil
  28006. m.addorganization_id = nil
  28007. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  28008. }
  28009. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28010. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  28011. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  28012. return ok
  28013. }
  28014. // ResetOrganizationID resets all changes to the "organization_id" field.
  28015. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  28016. m.organization_id = nil
  28017. m.addorganization_id = nil
  28018. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  28019. }
  28020. // SetAiResponse sets the "ai_response" field.
  28021. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  28022. m.ai_response = &u
  28023. m.addai_response = nil
  28024. }
  28025. // AiResponse returns the value of the "ai_response" field in the mutation.
  28026. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  28027. v := m.ai_response
  28028. if v == nil {
  28029. return
  28030. }
  28031. return *v, true
  28032. }
  28033. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  28034. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28036. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28037. if !m.op.Is(OpUpdateOne) {
  28038. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28039. }
  28040. if m.id == nil || m.oldValue == nil {
  28041. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28042. }
  28043. oldValue, err := m.oldValue(ctx)
  28044. if err != nil {
  28045. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28046. }
  28047. return oldValue.AiResponse, nil
  28048. }
  28049. // AddAiResponse adds u to the "ai_response" field.
  28050. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  28051. if m.addai_response != nil {
  28052. *m.addai_response += u
  28053. } else {
  28054. m.addai_response = &u
  28055. }
  28056. }
  28057. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28058. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  28059. v := m.addai_response
  28060. if v == nil {
  28061. return
  28062. }
  28063. return *v, true
  28064. }
  28065. // ResetAiResponse resets all changes to the "ai_response" field.
  28066. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  28067. m.ai_response = nil
  28068. m.addai_response = nil
  28069. }
  28070. // SetSopRun sets the "sop_run" field.
  28071. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  28072. m.sop_run = &u
  28073. m.addsop_run = nil
  28074. }
  28075. // SopRun returns the value of the "sop_run" field in the mutation.
  28076. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  28077. v := m.sop_run
  28078. if v == nil {
  28079. return
  28080. }
  28081. return *v, true
  28082. }
  28083. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  28084. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28086. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28087. if !m.op.Is(OpUpdateOne) {
  28088. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28089. }
  28090. if m.id == nil || m.oldValue == nil {
  28091. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28092. }
  28093. oldValue, err := m.oldValue(ctx)
  28094. if err != nil {
  28095. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28096. }
  28097. return oldValue.SopRun, nil
  28098. }
  28099. // AddSopRun adds u to the "sop_run" field.
  28100. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  28101. if m.addsop_run != nil {
  28102. *m.addsop_run += u
  28103. } else {
  28104. m.addsop_run = &u
  28105. }
  28106. }
  28107. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28108. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  28109. v := m.addsop_run
  28110. if v == nil {
  28111. return
  28112. }
  28113. return *v, true
  28114. }
  28115. // ResetSopRun resets all changes to the "sop_run" field.
  28116. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  28117. m.sop_run = nil
  28118. m.addsop_run = nil
  28119. }
  28120. // SetTotalFriend sets the "total_friend" field.
  28121. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  28122. m.total_friend = &u
  28123. m.addtotal_friend = nil
  28124. }
  28125. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28126. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  28127. v := m.total_friend
  28128. if v == nil {
  28129. return
  28130. }
  28131. return *v, true
  28132. }
  28133. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  28134. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28136. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28137. if !m.op.Is(OpUpdateOne) {
  28138. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28139. }
  28140. if m.id == nil || m.oldValue == nil {
  28141. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28142. }
  28143. oldValue, err := m.oldValue(ctx)
  28144. if err != nil {
  28145. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28146. }
  28147. return oldValue.TotalFriend, nil
  28148. }
  28149. // AddTotalFriend adds u to the "total_friend" field.
  28150. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  28151. if m.addtotal_friend != nil {
  28152. *m.addtotal_friend += u
  28153. } else {
  28154. m.addtotal_friend = &u
  28155. }
  28156. }
  28157. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28158. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  28159. v := m.addtotal_friend
  28160. if v == nil {
  28161. return
  28162. }
  28163. return *v, true
  28164. }
  28165. // ResetTotalFriend resets all changes to the "total_friend" field.
  28166. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  28167. m.total_friend = nil
  28168. m.addtotal_friend = nil
  28169. }
  28170. // SetTotalGroup sets the "total_group" field.
  28171. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  28172. m.total_group = &u
  28173. m.addtotal_group = nil
  28174. }
  28175. // TotalGroup returns the value of the "total_group" field in the mutation.
  28176. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  28177. v := m.total_group
  28178. if v == nil {
  28179. return
  28180. }
  28181. return *v, true
  28182. }
  28183. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  28184. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28186. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28187. if !m.op.Is(OpUpdateOne) {
  28188. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28189. }
  28190. if m.id == nil || m.oldValue == nil {
  28191. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28192. }
  28193. oldValue, err := m.oldValue(ctx)
  28194. if err != nil {
  28195. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28196. }
  28197. return oldValue.TotalGroup, nil
  28198. }
  28199. // AddTotalGroup adds u to the "total_group" field.
  28200. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  28201. if m.addtotal_group != nil {
  28202. *m.addtotal_group += u
  28203. } else {
  28204. m.addtotal_group = &u
  28205. }
  28206. }
  28207. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28208. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  28209. v := m.addtotal_group
  28210. if v == nil {
  28211. return
  28212. }
  28213. return *v, true
  28214. }
  28215. // ResetTotalGroup resets all changes to the "total_group" field.
  28216. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  28217. m.total_group = nil
  28218. m.addtotal_group = nil
  28219. }
  28220. // SetAccountBalance sets the "account_balance" field.
  28221. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  28222. m.account_balance = &u
  28223. m.addaccount_balance = nil
  28224. }
  28225. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28226. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  28227. v := m.account_balance
  28228. if v == nil {
  28229. return
  28230. }
  28231. return *v, true
  28232. }
  28233. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  28234. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28236. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28237. if !m.op.Is(OpUpdateOne) {
  28238. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28239. }
  28240. if m.id == nil || m.oldValue == nil {
  28241. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28242. }
  28243. oldValue, err := m.oldValue(ctx)
  28244. if err != nil {
  28245. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28246. }
  28247. return oldValue.AccountBalance, nil
  28248. }
  28249. // AddAccountBalance adds u to the "account_balance" field.
  28250. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  28251. if m.addaccount_balance != nil {
  28252. *m.addaccount_balance += u
  28253. } else {
  28254. m.addaccount_balance = &u
  28255. }
  28256. }
  28257. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28258. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  28259. v := m.addaccount_balance
  28260. if v == nil {
  28261. return
  28262. }
  28263. return *v, true
  28264. }
  28265. // ResetAccountBalance resets all changes to the "account_balance" field.
  28266. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  28267. m.account_balance = nil
  28268. m.addaccount_balance = nil
  28269. }
  28270. // SetConsumeToken sets the "consume_token" field.
  28271. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  28272. m.consume_token = &u
  28273. m.addconsume_token = nil
  28274. }
  28275. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28276. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  28277. v := m.consume_token
  28278. if v == nil {
  28279. return
  28280. }
  28281. return *v, true
  28282. }
  28283. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  28284. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28286. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28287. if !m.op.Is(OpUpdateOne) {
  28288. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28289. }
  28290. if m.id == nil || m.oldValue == nil {
  28291. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28292. }
  28293. oldValue, err := m.oldValue(ctx)
  28294. if err != nil {
  28295. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28296. }
  28297. return oldValue.ConsumeToken, nil
  28298. }
  28299. // AddConsumeToken adds u to the "consume_token" field.
  28300. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  28301. if m.addconsume_token != nil {
  28302. *m.addconsume_token += u
  28303. } else {
  28304. m.addconsume_token = &u
  28305. }
  28306. }
  28307. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28308. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  28309. v := m.addconsume_token
  28310. if v == nil {
  28311. return
  28312. }
  28313. return *v, true
  28314. }
  28315. // ResetConsumeToken resets all changes to the "consume_token" field.
  28316. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  28317. m.consume_token = nil
  28318. m.addconsume_token = nil
  28319. }
  28320. // SetActiveUser sets the "active_user" field.
  28321. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  28322. m.active_user = &u
  28323. m.addactive_user = nil
  28324. }
  28325. // ActiveUser returns the value of the "active_user" field in the mutation.
  28326. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  28327. v := m.active_user
  28328. if v == nil {
  28329. return
  28330. }
  28331. return *v, true
  28332. }
  28333. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  28334. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28336. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28337. if !m.op.Is(OpUpdateOne) {
  28338. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28339. }
  28340. if m.id == nil || m.oldValue == nil {
  28341. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28342. }
  28343. oldValue, err := m.oldValue(ctx)
  28344. if err != nil {
  28345. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28346. }
  28347. return oldValue.ActiveUser, nil
  28348. }
  28349. // AddActiveUser adds u to the "active_user" field.
  28350. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  28351. if m.addactive_user != nil {
  28352. *m.addactive_user += u
  28353. } else {
  28354. m.addactive_user = &u
  28355. }
  28356. }
  28357. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28358. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  28359. v := m.addactive_user
  28360. if v == nil {
  28361. return
  28362. }
  28363. return *v, true
  28364. }
  28365. // ResetActiveUser resets all changes to the "active_user" field.
  28366. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  28367. m.active_user = nil
  28368. m.addactive_user = nil
  28369. }
  28370. // SetNewUser sets the "new_user" field.
  28371. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  28372. m.new_user = &i
  28373. m.addnew_user = nil
  28374. }
  28375. // NewUser returns the value of the "new_user" field in the mutation.
  28376. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  28377. v := m.new_user
  28378. if v == nil {
  28379. return
  28380. }
  28381. return *v, true
  28382. }
  28383. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  28384. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28386. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28387. if !m.op.Is(OpUpdateOne) {
  28388. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28389. }
  28390. if m.id == nil || m.oldValue == nil {
  28391. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28392. }
  28393. oldValue, err := m.oldValue(ctx)
  28394. if err != nil {
  28395. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28396. }
  28397. return oldValue.NewUser, nil
  28398. }
  28399. // AddNewUser adds i to the "new_user" field.
  28400. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  28401. if m.addnew_user != nil {
  28402. *m.addnew_user += i
  28403. } else {
  28404. m.addnew_user = &i
  28405. }
  28406. }
  28407. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28408. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  28409. v := m.addnew_user
  28410. if v == nil {
  28411. return
  28412. }
  28413. return *v, true
  28414. }
  28415. // ResetNewUser resets all changes to the "new_user" field.
  28416. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  28417. m.new_user = nil
  28418. m.addnew_user = nil
  28419. }
  28420. // SetLabelDist sets the "label_dist" field.
  28421. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28422. m.label_dist = &ctd
  28423. m.appendlabel_dist = nil
  28424. }
  28425. // LabelDist returns the value of the "label_dist" field in the mutation.
  28426. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28427. v := m.label_dist
  28428. if v == nil {
  28429. return
  28430. }
  28431. return *v, true
  28432. }
  28433. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  28434. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28436. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28437. if !m.op.Is(OpUpdateOne) {
  28438. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  28439. }
  28440. if m.id == nil || m.oldValue == nil {
  28441. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  28442. }
  28443. oldValue, err := m.oldValue(ctx)
  28444. if err != nil {
  28445. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  28446. }
  28447. return oldValue.LabelDist, nil
  28448. }
  28449. // AppendLabelDist adds ctd to the "label_dist" field.
  28450. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  28451. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  28452. }
  28453. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  28454. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  28455. if len(m.appendlabel_dist) == 0 {
  28456. return nil, false
  28457. }
  28458. return m.appendlabel_dist, true
  28459. }
  28460. // ResetLabelDist resets all changes to the "label_dist" field.
  28461. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  28462. m.label_dist = nil
  28463. m.appendlabel_dist = nil
  28464. }
  28465. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  28466. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  28467. m.predicates = append(m.predicates, ps...)
  28468. }
  28469. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  28470. // users can use type-assertion to append predicates that do not depend on any generated package.
  28471. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  28472. p := make([]predicate.UsageStatisticMonth, len(ps))
  28473. for i := range ps {
  28474. p[i] = ps[i]
  28475. }
  28476. m.Where(p...)
  28477. }
  28478. // Op returns the operation name.
  28479. func (m *UsageStatisticMonthMutation) Op() Op {
  28480. return m.op
  28481. }
  28482. // SetOp allows setting the mutation operation.
  28483. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  28484. m.op = op
  28485. }
  28486. // Type returns the node type of this mutation (UsageStatisticMonth).
  28487. func (m *UsageStatisticMonthMutation) Type() string {
  28488. return m.typ
  28489. }
  28490. // Fields returns all fields that were changed during this mutation. Note that in
  28491. // order to get all numeric fields that were incremented/decremented, call
  28492. // AddedFields().
  28493. func (m *UsageStatisticMonthMutation) Fields() []string {
  28494. fields := make([]string, 0, 17)
  28495. if m.created_at != nil {
  28496. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  28497. }
  28498. if m.updated_at != nil {
  28499. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  28500. }
  28501. if m.status != nil {
  28502. fields = append(fields, usagestatisticmonth.FieldStatus)
  28503. }
  28504. if m.deleted_at != nil {
  28505. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  28506. }
  28507. if m.addtime != nil {
  28508. fields = append(fields, usagestatisticmonth.FieldAddtime)
  28509. }
  28510. if m._type != nil {
  28511. fields = append(fields, usagestatisticmonth.FieldType)
  28512. }
  28513. if m.bot_id != nil {
  28514. fields = append(fields, usagestatisticmonth.FieldBotID)
  28515. }
  28516. if m.organization_id != nil {
  28517. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  28518. }
  28519. if m.ai_response != nil {
  28520. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  28521. }
  28522. if m.sop_run != nil {
  28523. fields = append(fields, usagestatisticmonth.FieldSopRun)
  28524. }
  28525. if m.total_friend != nil {
  28526. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  28527. }
  28528. if m.total_group != nil {
  28529. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  28530. }
  28531. if m.account_balance != nil {
  28532. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  28533. }
  28534. if m.consume_token != nil {
  28535. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  28536. }
  28537. if m.active_user != nil {
  28538. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  28539. }
  28540. if m.new_user != nil {
  28541. fields = append(fields, usagestatisticmonth.FieldNewUser)
  28542. }
  28543. if m.label_dist != nil {
  28544. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  28545. }
  28546. return fields
  28547. }
  28548. // Field returns the value of a field with the given name. The second boolean
  28549. // return value indicates that this field was not set, or was not defined in the
  28550. // schema.
  28551. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  28552. switch name {
  28553. case usagestatisticmonth.FieldCreatedAt:
  28554. return m.CreatedAt()
  28555. case usagestatisticmonth.FieldUpdatedAt:
  28556. return m.UpdatedAt()
  28557. case usagestatisticmonth.FieldStatus:
  28558. return m.Status()
  28559. case usagestatisticmonth.FieldDeletedAt:
  28560. return m.DeletedAt()
  28561. case usagestatisticmonth.FieldAddtime:
  28562. return m.Addtime()
  28563. case usagestatisticmonth.FieldType:
  28564. return m.GetType()
  28565. case usagestatisticmonth.FieldBotID:
  28566. return m.BotID()
  28567. case usagestatisticmonth.FieldOrganizationID:
  28568. return m.OrganizationID()
  28569. case usagestatisticmonth.FieldAiResponse:
  28570. return m.AiResponse()
  28571. case usagestatisticmonth.FieldSopRun:
  28572. return m.SopRun()
  28573. case usagestatisticmonth.FieldTotalFriend:
  28574. return m.TotalFriend()
  28575. case usagestatisticmonth.FieldTotalGroup:
  28576. return m.TotalGroup()
  28577. case usagestatisticmonth.FieldAccountBalance:
  28578. return m.AccountBalance()
  28579. case usagestatisticmonth.FieldConsumeToken:
  28580. return m.ConsumeToken()
  28581. case usagestatisticmonth.FieldActiveUser:
  28582. return m.ActiveUser()
  28583. case usagestatisticmonth.FieldNewUser:
  28584. return m.NewUser()
  28585. case usagestatisticmonth.FieldLabelDist:
  28586. return m.LabelDist()
  28587. }
  28588. return nil, false
  28589. }
  28590. // OldField returns the old value of the field from the database. An error is
  28591. // returned if the mutation operation is not UpdateOne, or the query to the
  28592. // database failed.
  28593. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28594. switch name {
  28595. case usagestatisticmonth.FieldCreatedAt:
  28596. return m.OldCreatedAt(ctx)
  28597. case usagestatisticmonth.FieldUpdatedAt:
  28598. return m.OldUpdatedAt(ctx)
  28599. case usagestatisticmonth.FieldStatus:
  28600. return m.OldStatus(ctx)
  28601. case usagestatisticmonth.FieldDeletedAt:
  28602. return m.OldDeletedAt(ctx)
  28603. case usagestatisticmonth.FieldAddtime:
  28604. return m.OldAddtime(ctx)
  28605. case usagestatisticmonth.FieldType:
  28606. return m.OldType(ctx)
  28607. case usagestatisticmonth.FieldBotID:
  28608. return m.OldBotID(ctx)
  28609. case usagestatisticmonth.FieldOrganizationID:
  28610. return m.OldOrganizationID(ctx)
  28611. case usagestatisticmonth.FieldAiResponse:
  28612. return m.OldAiResponse(ctx)
  28613. case usagestatisticmonth.FieldSopRun:
  28614. return m.OldSopRun(ctx)
  28615. case usagestatisticmonth.FieldTotalFriend:
  28616. return m.OldTotalFriend(ctx)
  28617. case usagestatisticmonth.FieldTotalGroup:
  28618. return m.OldTotalGroup(ctx)
  28619. case usagestatisticmonth.FieldAccountBalance:
  28620. return m.OldAccountBalance(ctx)
  28621. case usagestatisticmonth.FieldConsumeToken:
  28622. return m.OldConsumeToken(ctx)
  28623. case usagestatisticmonth.FieldActiveUser:
  28624. return m.OldActiveUser(ctx)
  28625. case usagestatisticmonth.FieldNewUser:
  28626. return m.OldNewUser(ctx)
  28627. case usagestatisticmonth.FieldLabelDist:
  28628. return m.OldLabelDist(ctx)
  28629. }
  28630. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  28631. }
  28632. // SetField sets the value of a field with the given name. It returns an error if
  28633. // the field is not defined in the schema, or if the type mismatched the field
  28634. // type.
  28635. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  28636. switch name {
  28637. case usagestatisticmonth.FieldCreatedAt:
  28638. v, ok := value.(time.Time)
  28639. if !ok {
  28640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28641. }
  28642. m.SetCreatedAt(v)
  28643. return nil
  28644. case usagestatisticmonth.FieldUpdatedAt:
  28645. v, ok := value.(time.Time)
  28646. if !ok {
  28647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28648. }
  28649. m.SetUpdatedAt(v)
  28650. return nil
  28651. case usagestatisticmonth.FieldStatus:
  28652. v, ok := value.(uint8)
  28653. if !ok {
  28654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28655. }
  28656. m.SetStatus(v)
  28657. return nil
  28658. case usagestatisticmonth.FieldDeletedAt:
  28659. v, ok := value.(time.Time)
  28660. if !ok {
  28661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28662. }
  28663. m.SetDeletedAt(v)
  28664. return nil
  28665. case usagestatisticmonth.FieldAddtime:
  28666. v, ok := value.(uint64)
  28667. if !ok {
  28668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28669. }
  28670. m.SetAddtime(v)
  28671. return nil
  28672. case usagestatisticmonth.FieldType:
  28673. v, ok := value.(int)
  28674. if !ok {
  28675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28676. }
  28677. m.SetType(v)
  28678. return nil
  28679. case usagestatisticmonth.FieldBotID:
  28680. v, ok := value.(string)
  28681. if !ok {
  28682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28683. }
  28684. m.SetBotID(v)
  28685. return nil
  28686. case usagestatisticmonth.FieldOrganizationID:
  28687. v, ok := value.(uint64)
  28688. if !ok {
  28689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28690. }
  28691. m.SetOrganizationID(v)
  28692. return nil
  28693. case usagestatisticmonth.FieldAiResponse:
  28694. v, ok := value.(uint64)
  28695. if !ok {
  28696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28697. }
  28698. m.SetAiResponse(v)
  28699. return nil
  28700. case usagestatisticmonth.FieldSopRun:
  28701. v, ok := value.(uint64)
  28702. if !ok {
  28703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28704. }
  28705. m.SetSopRun(v)
  28706. return nil
  28707. case usagestatisticmonth.FieldTotalFriend:
  28708. v, ok := value.(uint64)
  28709. if !ok {
  28710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28711. }
  28712. m.SetTotalFriend(v)
  28713. return nil
  28714. case usagestatisticmonth.FieldTotalGroup:
  28715. v, ok := value.(uint64)
  28716. if !ok {
  28717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28718. }
  28719. m.SetTotalGroup(v)
  28720. return nil
  28721. case usagestatisticmonth.FieldAccountBalance:
  28722. v, ok := value.(uint64)
  28723. if !ok {
  28724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28725. }
  28726. m.SetAccountBalance(v)
  28727. return nil
  28728. case usagestatisticmonth.FieldConsumeToken:
  28729. v, ok := value.(uint64)
  28730. if !ok {
  28731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28732. }
  28733. m.SetConsumeToken(v)
  28734. return nil
  28735. case usagestatisticmonth.FieldActiveUser:
  28736. v, ok := value.(uint64)
  28737. if !ok {
  28738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28739. }
  28740. m.SetActiveUser(v)
  28741. return nil
  28742. case usagestatisticmonth.FieldNewUser:
  28743. v, ok := value.(int64)
  28744. if !ok {
  28745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28746. }
  28747. m.SetNewUser(v)
  28748. return nil
  28749. case usagestatisticmonth.FieldLabelDist:
  28750. v, ok := value.([]custom_types.LabelDist)
  28751. if !ok {
  28752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28753. }
  28754. m.SetLabelDist(v)
  28755. return nil
  28756. }
  28757. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  28758. }
  28759. // AddedFields returns all numeric fields that were incremented/decremented during
  28760. // this mutation.
  28761. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  28762. var fields []string
  28763. if m.addstatus != nil {
  28764. fields = append(fields, usagestatisticmonth.FieldStatus)
  28765. }
  28766. if m.addaddtime != nil {
  28767. fields = append(fields, usagestatisticmonth.FieldAddtime)
  28768. }
  28769. if m.add_type != nil {
  28770. fields = append(fields, usagestatisticmonth.FieldType)
  28771. }
  28772. if m.addorganization_id != nil {
  28773. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  28774. }
  28775. if m.addai_response != nil {
  28776. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  28777. }
  28778. if m.addsop_run != nil {
  28779. fields = append(fields, usagestatisticmonth.FieldSopRun)
  28780. }
  28781. if m.addtotal_friend != nil {
  28782. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  28783. }
  28784. if m.addtotal_group != nil {
  28785. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  28786. }
  28787. if m.addaccount_balance != nil {
  28788. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  28789. }
  28790. if m.addconsume_token != nil {
  28791. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  28792. }
  28793. if m.addactive_user != nil {
  28794. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  28795. }
  28796. if m.addnew_user != nil {
  28797. fields = append(fields, usagestatisticmonth.FieldNewUser)
  28798. }
  28799. return fields
  28800. }
  28801. // AddedField returns the numeric value that was incremented/decremented on a field
  28802. // with the given name. The second boolean return value indicates that this field
  28803. // was not set, or was not defined in the schema.
  28804. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  28805. switch name {
  28806. case usagestatisticmonth.FieldStatus:
  28807. return m.AddedStatus()
  28808. case usagestatisticmonth.FieldAddtime:
  28809. return m.AddedAddtime()
  28810. case usagestatisticmonth.FieldType:
  28811. return m.AddedType()
  28812. case usagestatisticmonth.FieldOrganizationID:
  28813. return m.AddedOrganizationID()
  28814. case usagestatisticmonth.FieldAiResponse:
  28815. return m.AddedAiResponse()
  28816. case usagestatisticmonth.FieldSopRun:
  28817. return m.AddedSopRun()
  28818. case usagestatisticmonth.FieldTotalFriend:
  28819. return m.AddedTotalFriend()
  28820. case usagestatisticmonth.FieldTotalGroup:
  28821. return m.AddedTotalGroup()
  28822. case usagestatisticmonth.FieldAccountBalance:
  28823. return m.AddedAccountBalance()
  28824. case usagestatisticmonth.FieldConsumeToken:
  28825. return m.AddedConsumeToken()
  28826. case usagestatisticmonth.FieldActiveUser:
  28827. return m.AddedActiveUser()
  28828. case usagestatisticmonth.FieldNewUser:
  28829. return m.AddedNewUser()
  28830. }
  28831. return nil, false
  28832. }
  28833. // AddField adds the value to the field with the given name. It returns an error if
  28834. // the field is not defined in the schema, or if the type mismatched the field
  28835. // type.
  28836. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  28837. switch name {
  28838. case usagestatisticmonth.FieldStatus:
  28839. v, ok := value.(int8)
  28840. if !ok {
  28841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28842. }
  28843. m.AddStatus(v)
  28844. return nil
  28845. case usagestatisticmonth.FieldAddtime:
  28846. v, ok := value.(int64)
  28847. if !ok {
  28848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28849. }
  28850. m.AddAddtime(v)
  28851. return nil
  28852. case usagestatisticmonth.FieldType:
  28853. v, ok := value.(int)
  28854. if !ok {
  28855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28856. }
  28857. m.AddType(v)
  28858. return nil
  28859. case usagestatisticmonth.FieldOrganizationID:
  28860. v, ok := value.(int64)
  28861. if !ok {
  28862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28863. }
  28864. m.AddOrganizationID(v)
  28865. return nil
  28866. case usagestatisticmonth.FieldAiResponse:
  28867. v, ok := value.(int64)
  28868. if !ok {
  28869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28870. }
  28871. m.AddAiResponse(v)
  28872. return nil
  28873. case usagestatisticmonth.FieldSopRun:
  28874. v, ok := value.(int64)
  28875. if !ok {
  28876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28877. }
  28878. m.AddSopRun(v)
  28879. return nil
  28880. case usagestatisticmonth.FieldTotalFriend:
  28881. v, ok := value.(int64)
  28882. if !ok {
  28883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28884. }
  28885. m.AddTotalFriend(v)
  28886. return nil
  28887. case usagestatisticmonth.FieldTotalGroup:
  28888. v, ok := value.(int64)
  28889. if !ok {
  28890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28891. }
  28892. m.AddTotalGroup(v)
  28893. return nil
  28894. case usagestatisticmonth.FieldAccountBalance:
  28895. v, ok := value.(int64)
  28896. if !ok {
  28897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28898. }
  28899. m.AddAccountBalance(v)
  28900. return nil
  28901. case usagestatisticmonth.FieldConsumeToken:
  28902. v, ok := value.(int64)
  28903. if !ok {
  28904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28905. }
  28906. m.AddConsumeToken(v)
  28907. return nil
  28908. case usagestatisticmonth.FieldActiveUser:
  28909. v, ok := value.(int64)
  28910. if !ok {
  28911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28912. }
  28913. m.AddActiveUser(v)
  28914. return nil
  28915. case usagestatisticmonth.FieldNewUser:
  28916. v, ok := value.(int64)
  28917. if !ok {
  28918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28919. }
  28920. m.AddNewUser(v)
  28921. return nil
  28922. }
  28923. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  28924. }
  28925. // ClearedFields returns all nullable fields that were cleared during this
  28926. // mutation.
  28927. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  28928. var fields []string
  28929. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  28930. fields = append(fields, usagestatisticmonth.FieldStatus)
  28931. }
  28932. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  28933. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  28934. }
  28935. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  28936. fields = append(fields, usagestatisticmonth.FieldBotID)
  28937. }
  28938. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  28939. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  28940. }
  28941. return fields
  28942. }
  28943. // FieldCleared returns a boolean indicating if a field with the given name was
  28944. // cleared in this mutation.
  28945. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  28946. _, ok := m.clearedFields[name]
  28947. return ok
  28948. }
  28949. // ClearField clears the value of the field with the given name. It returns an
  28950. // error if the field is not defined in the schema.
  28951. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  28952. switch name {
  28953. case usagestatisticmonth.FieldStatus:
  28954. m.ClearStatus()
  28955. return nil
  28956. case usagestatisticmonth.FieldDeletedAt:
  28957. m.ClearDeletedAt()
  28958. return nil
  28959. case usagestatisticmonth.FieldBotID:
  28960. m.ClearBotID()
  28961. return nil
  28962. case usagestatisticmonth.FieldOrganizationID:
  28963. m.ClearOrganizationID()
  28964. return nil
  28965. }
  28966. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  28967. }
  28968. // ResetField resets all changes in the mutation for the field with the given name.
  28969. // It returns an error if the field is not defined in the schema.
  28970. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  28971. switch name {
  28972. case usagestatisticmonth.FieldCreatedAt:
  28973. m.ResetCreatedAt()
  28974. return nil
  28975. case usagestatisticmonth.FieldUpdatedAt:
  28976. m.ResetUpdatedAt()
  28977. return nil
  28978. case usagestatisticmonth.FieldStatus:
  28979. m.ResetStatus()
  28980. return nil
  28981. case usagestatisticmonth.FieldDeletedAt:
  28982. m.ResetDeletedAt()
  28983. return nil
  28984. case usagestatisticmonth.FieldAddtime:
  28985. m.ResetAddtime()
  28986. return nil
  28987. case usagestatisticmonth.FieldType:
  28988. m.ResetType()
  28989. return nil
  28990. case usagestatisticmonth.FieldBotID:
  28991. m.ResetBotID()
  28992. return nil
  28993. case usagestatisticmonth.FieldOrganizationID:
  28994. m.ResetOrganizationID()
  28995. return nil
  28996. case usagestatisticmonth.FieldAiResponse:
  28997. m.ResetAiResponse()
  28998. return nil
  28999. case usagestatisticmonth.FieldSopRun:
  29000. m.ResetSopRun()
  29001. return nil
  29002. case usagestatisticmonth.FieldTotalFriend:
  29003. m.ResetTotalFriend()
  29004. return nil
  29005. case usagestatisticmonth.FieldTotalGroup:
  29006. m.ResetTotalGroup()
  29007. return nil
  29008. case usagestatisticmonth.FieldAccountBalance:
  29009. m.ResetAccountBalance()
  29010. return nil
  29011. case usagestatisticmonth.FieldConsumeToken:
  29012. m.ResetConsumeToken()
  29013. return nil
  29014. case usagestatisticmonth.FieldActiveUser:
  29015. m.ResetActiveUser()
  29016. return nil
  29017. case usagestatisticmonth.FieldNewUser:
  29018. m.ResetNewUser()
  29019. return nil
  29020. case usagestatisticmonth.FieldLabelDist:
  29021. m.ResetLabelDist()
  29022. return nil
  29023. }
  29024. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  29025. }
  29026. // AddedEdges returns all edge names that were set/added in this mutation.
  29027. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  29028. edges := make([]string, 0, 0)
  29029. return edges
  29030. }
  29031. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29032. // name in this mutation.
  29033. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  29034. return nil
  29035. }
  29036. // RemovedEdges returns all edge names that were removed in this mutation.
  29037. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  29038. edges := make([]string, 0, 0)
  29039. return edges
  29040. }
  29041. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29042. // the given name in this mutation.
  29043. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  29044. return nil
  29045. }
  29046. // ClearedEdges returns all edge names that were cleared in this mutation.
  29047. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  29048. edges := make([]string, 0, 0)
  29049. return edges
  29050. }
  29051. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29052. // was cleared in this mutation.
  29053. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  29054. return false
  29055. }
  29056. // ClearEdge clears the value of the edge with the given name. It returns an error
  29057. // if that edge is not defined in the schema.
  29058. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  29059. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  29060. }
  29061. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29062. // It returns an error if the edge is not defined in the schema.
  29063. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  29064. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  29065. }
  29066. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  29067. type UsageTotalMutation struct {
  29068. config
  29069. op Op
  29070. typ string
  29071. id *uint64
  29072. created_at *time.Time
  29073. updated_at *time.Time
  29074. status *uint8
  29075. addstatus *int8
  29076. _type *int
  29077. add_type *int
  29078. bot_id *string
  29079. total_tokens *uint64
  29080. addtotal_tokens *int64
  29081. start_index *uint64
  29082. addstart_index *int64
  29083. end_index *uint64
  29084. addend_index *int64
  29085. organization_id *uint64
  29086. addorganization_id *int64
  29087. clearedFields map[string]struct{}
  29088. done bool
  29089. oldValue func(context.Context) (*UsageTotal, error)
  29090. predicates []predicate.UsageTotal
  29091. }
  29092. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  29093. // usagetotalOption allows management of the mutation configuration using functional options.
  29094. type usagetotalOption func(*UsageTotalMutation)
  29095. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  29096. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  29097. m := &UsageTotalMutation{
  29098. config: c,
  29099. op: op,
  29100. typ: TypeUsageTotal,
  29101. clearedFields: make(map[string]struct{}),
  29102. }
  29103. for _, opt := range opts {
  29104. opt(m)
  29105. }
  29106. return m
  29107. }
  29108. // withUsageTotalID sets the ID field of the mutation.
  29109. func withUsageTotalID(id uint64) usagetotalOption {
  29110. return func(m *UsageTotalMutation) {
  29111. var (
  29112. err error
  29113. once sync.Once
  29114. value *UsageTotal
  29115. )
  29116. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  29117. once.Do(func() {
  29118. if m.done {
  29119. err = errors.New("querying old values post mutation is not allowed")
  29120. } else {
  29121. value, err = m.Client().UsageTotal.Get(ctx, id)
  29122. }
  29123. })
  29124. return value, err
  29125. }
  29126. m.id = &id
  29127. }
  29128. }
  29129. // withUsageTotal sets the old UsageTotal of the mutation.
  29130. func withUsageTotal(node *UsageTotal) usagetotalOption {
  29131. return func(m *UsageTotalMutation) {
  29132. m.oldValue = func(context.Context) (*UsageTotal, error) {
  29133. return node, nil
  29134. }
  29135. m.id = &node.ID
  29136. }
  29137. }
  29138. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29139. // executed in a transaction (ent.Tx), a transactional client is returned.
  29140. func (m UsageTotalMutation) Client() *Client {
  29141. client := &Client{config: m.config}
  29142. client.init()
  29143. return client
  29144. }
  29145. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29146. // it returns an error otherwise.
  29147. func (m UsageTotalMutation) Tx() (*Tx, error) {
  29148. if _, ok := m.driver.(*txDriver); !ok {
  29149. return nil, errors.New("ent: mutation is not running in a transaction")
  29150. }
  29151. tx := &Tx{config: m.config}
  29152. tx.init()
  29153. return tx, nil
  29154. }
  29155. // SetID sets the value of the id field. Note that this
  29156. // operation is only accepted on creation of UsageTotal entities.
  29157. func (m *UsageTotalMutation) SetID(id uint64) {
  29158. m.id = &id
  29159. }
  29160. // ID returns the ID value in the mutation. Note that the ID is only available
  29161. // if it was provided to the builder or after it was returned from the database.
  29162. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  29163. if m.id == nil {
  29164. return
  29165. }
  29166. return *m.id, true
  29167. }
  29168. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29169. // That means, if the mutation is applied within a transaction with an isolation level such
  29170. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29171. // or updated by the mutation.
  29172. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  29173. switch {
  29174. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29175. id, exists := m.ID()
  29176. if exists {
  29177. return []uint64{id}, nil
  29178. }
  29179. fallthrough
  29180. case m.op.Is(OpUpdate | OpDelete):
  29181. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  29182. default:
  29183. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29184. }
  29185. }
  29186. // SetCreatedAt sets the "created_at" field.
  29187. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  29188. m.created_at = &t
  29189. }
  29190. // CreatedAt returns the value of the "created_at" field in the mutation.
  29191. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  29192. v := m.created_at
  29193. if v == nil {
  29194. return
  29195. }
  29196. return *v, true
  29197. }
  29198. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  29199. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29201. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29202. if !m.op.Is(OpUpdateOne) {
  29203. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29204. }
  29205. if m.id == nil || m.oldValue == nil {
  29206. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29207. }
  29208. oldValue, err := m.oldValue(ctx)
  29209. if err != nil {
  29210. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29211. }
  29212. return oldValue.CreatedAt, nil
  29213. }
  29214. // ResetCreatedAt resets all changes to the "created_at" field.
  29215. func (m *UsageTotalMutation) ResetCreatedAt() {
  29216. m.created_at = nil
  29217. }
  29218. // SetUpdatedAt sets the "updated_at" field.
  29219. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  29220. m.updated_at = &t
  29221. }
  29222. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29223. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  29224. v := m.updated_at
  29225. if v == nil {
  29226. return
  29227. }
  29228. return *v, true
  29229. }
  29230. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  29231. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29233. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29234. if !m.op.Is(OpUpdateOne) {
  29235. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29236. }
  29237. if m.id == nil || m.oldValue == nil {
  29238. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29239. }
  29240. oldValue, err := m.oldValue(ctx)
  29241. if err != nil {
  29242. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29243. }
  29244. return oldValue.UpdatedAt, nil
  29245. }
  29246. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29247. func (m *UsageTotalMutation) ResetUpdatedAt() {
  29248. m.updated_at = nil
  29249. }
  29250. // SetStatus sets the "status" field.
  29251. func (m *UsageTotalMutation) SetStatus(u uint8) {
  29252. m.status = &u
  29253. m.addstatus = nil
  29254. }
  29255. // Status returns the value of the "status" field in the mutation.
  29256. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  29257. v := m.status
  29258. if v == nil {
  29259. return
  29260. }
  29261. return *v, true
  29262. }
  29263. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  29264. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29266. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29267. if !m.op.Is(OpUpdateOne) {
  29268. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29269. }
  29270. if m.id == nil || m.oldValue == nil {
  29271. return v, errors.New("OldStatus requires an ID field in the mutation")
  29272. }
  29273. oldValue, err := m.oldValue(ctx)
  29274. if err != nil {
  29275. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29276. }
  29277. return oldValue.Status, nil
  29278. }
  29279. // AddStatus adds u to the "status" field.
  29280. func (m *UsageTotalMutation) AddStatus(u int8) {
  29281. if m.addstatus != nil {
  29282. *m.addstatus += u
  29283. } else {
  29284. m.addstatus = &u
  29285. }
  29286. }
  29287. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29288. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  29289. v := m.addstatus
  29290. if v == nil {
  29291. return
  29292. }
  29293. return *v, true
  29294. }
  29295. // ClearStatus clears the value of the "status" field.
  29296. func (m *UsageTotalMutation) ClearStatus() {
  29297. m.status = nil
  29298. m.addstatus = nil
  29299. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  29300. }
  29301. // StatusCleared returns if the "status" field was cleared in this mutation.
  29302. func (m *UsageTotalMutation) StatusCleared() bool {
  29303. _, ok := m.clearedFields[usagetotal.FieldStatus]
  29304. return ok
  29305. }
  29306. // ResetStatus resets all changes to the "status" field.
  29307. func (m *UsageTotalMutation) ResetStatus() {
  29308. m.status = nil
  29309. m.addstatus = nil
  29310. delete(m.clearedFields, usagetotal.FieldStatus)
  29311. }
  29312. // SetType sets the "type" field.
  29313. func (m *UsageTotalMutation) SetType(i int) {
  29314. m._type = &i
  29315. m.add_type = nil
  29316. }
  29317. // GetType returns the value of the "type" field in the mutation.
  29318. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  29319. v := m._type
  29320. if v == nil {
  29321. return
  29322. }
  29323. return *v, true
  29324. }
  29325. // OldType returns the old "type" field's value of the UsageTotal entity.
  29326. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29328. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  29329. if !m.op.Is(OpUpdateOne) {
  29330. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29331. }
  29332. if m.id == nil || m.oldValue == nil {
  29333. return v, errors.New("OldType requires an ID field in the mutation")
  29334. }
  29335. oldValue, err := m.oldValue(ctx)
  29336. if err != nil {
  29337. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29338. }
  29339. return oldValue.Type, nil
  29340. }
  29341. // AddType adds i to the "type" field.
  29342. func (m *UsageTotalMutation) AddType(i int) {
  29343. if m.add_type != nil {
  29344. *m.add_type += i
  29345. } else {
  29346. m.add_type = &i
  29347. }
  29348. }
  29349. // AddedType returns the value that was added to the "type" field in this mutation.
  29350. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  29351. v := m.add_type
  29352. if v == nil {
  29353. return
  29354. }
  29355. return *v, true
  29356. }
  29357. // ClearType clears the value of the "type" field.
  29358. func (m *UsageTotalMutation) ClearType() {
  29359. m._type = nil
  29360. m.add_type = nil
  29361. m.clearedFields[usagetotal.FieldType] = struct{}{}
  29362. }
  29363. // TypeCleared returns if the "type" field was cleared in this mutation.
  29364. func (m *UsageTotalMutation) TypeCleared() bool {
  29365. _, ok := m.clearedFields[usagetotal.FieldType]
  29366. return ok
  29367. }
  29368. // ResetType resets all changes to the "type" field.
  29369. func (m *UsageTotalMutation) ResetType() {
  29370. m._type = nil
  29371. m.add_type = nil
  29372. delete(m.clearedFields, usagetotal.FieldType)
  29373. }
  29374. // SetBotID sets the "bot_id" field.
  29375. func (m *UsageTotalMutation) SetBotID(s string) {
  29376. m.bot_id = &s
  29377. }
  29378. // BotID returns the value of the "bot_id" field in the mutation.
  29379. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  29380. v := m.bot_id
  29381. if v == nil {
  29382. return
  29383. }
  29384. return *v, true
  29385. }
  29386. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  29387. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29389. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  29390. if !m.op.Is(OpUpdateOne) {
  29391. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29392. }
  29393. if m.id == nil || m.oldValue == nil {
  29394. return v, errors.New("OldBotID requires an ID field in the mutation")
  29395. }
  29396. oldValue, err := m.oldValue(ctx)
  29397. if err != nil {
  29398. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29399. }
  29400. return oldValue.BotID, nil
  29401. }
  29402. // ResetBotID resets all changes to the "bot_id" field.
  29403. func (m *UsageTotalMutation) ResetBotID() {
  29404. m.bot_id = nil
  29405. }
  29406. // SetTotalTokens sets the "total_tokens" field.
  29407. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  29408. m.total_tokens = &u
  29409. m.addtotal_tokens = nil
  29410. }
  29411. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29412. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  29413. v := m.total_tokens
  29414. if v == nil {
  29415. return
  29416. }
  29417. return *v, true
  29418. }
  29419. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  29420. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29422. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29423. if !m.op.Is(OpUpdateOne) {
  29424. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29425. }
  29426. if m.id == nil || m.oldValue == nil {
  29427. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29428. }
  29429. oldValue, err := m.oldValue(ctx)
  29430. if err != nil {
  29431. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29432. }
  29433. return oldValue.TotalTokens, nil
  29434. }
  29435. // AddTotalTokens adds u to the "total_tokens" field.
  29436. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  29437. if m.addtotal_tokens != nil {
  29438. *m.addtotal_tokens += u
  29439. } else {
  29440. m.addtotal_tokens = &u
  29441. }
  29442. }
  29443. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29444. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  29445. v := m.addtotal_tokens
  29446. if v == nil {
  29447. return
  29448. }
  29449. return *v, true
  29450. }
  29451. // ClearTotalTokens clears the value of the "total_tokens" field.
  29452. func (m *UsageTotalMutation) ClearTotalTokens() {
  29453. m.total_tokens = nil
  29454. m.addtotal_tokens = nil
  29455. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  29456. }
  29457. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29458. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  29459. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  29460. return ok
  29461. }
  29462. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29463. func (m *UsageTotalMutation) ResetTotalTokens() {
  29464. m.total_tokens = nil
  29465. m.addtotal_tokens = nil
  29466. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  29467. }
  29468. // SetStartIndex sets the "start_index" field.
  29469. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  29470. m.start_index = &u
  29471. m.addstart_index = nil
  29472. }
  29473. // StartIndex returns the value of the "start_index" field in the mutation.
  29474. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  29475. v := m.start_index
  29476. if v == nil {
  29477. return
  29478. }
  29479. return *v, true
  29480. }
  29481. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  29482. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29484. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  29485. if !m.op.Is(OpUpdateOne) {
  29486. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  29487. }
  29488. if m.id == nil || m.oldValue == nil {
  29489. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  29490. }
  29491. oldValue, err := m.oldValue(ctx)
  29492. if err != nil {
  29493. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  29494. }
  29495. return oldValue.StartIndex, nil
  29496. }
  29497. // AddStartIndex adds u to the "start_index" field.
  29498. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  29499. if m.addstart_index != nil {
  29500. *m.addstart_index += u
  29501. } else {
  29502. m.addstart_index = &u
  29503. }
  29504. }
  29505. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  29506. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  29507. v := m.addstart_index
  29508. if v == nil {
  29509. return
  29510. }
  29511. return *v, true
  29512. }
  29513. // ClearStartIndex clears the value of the "start_index" field.
  29514. func (m *UsageTotalMutation) ClearStartIndex() {
  29515. m.start_index = nil
  29516. m.addstart_index = nil
  29517. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  29518. }
  29519. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  29520. func (m *UsageTotalMutation) StartIndexCleared() bool {
  29521. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  29522. return ok
  29523. }
  29524. // ResetStartIndex resets all changes to the "start_index" field.
  29525. func (m *UsageTotalMutation) ResetStartIndex() {
  29526. m.start_index = nil
  29527. m.addstart_index = nil
  29528. delete(m.clearedFields, usagetotal.FieldStartIndex)
  29529. }
  29530. // SetEndIndex sets the "end_index" field.
  29531. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  29532. m.end_index = &u
  29533. m.addend_index = nil
  29534. }
  29535. // EndIndex returns the value of the "end_index" field in the mutation.
  29536. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  29537. v := m.end_index
  29538. if v == nil {
  29539. return
  29540. }
  29541. return *v, true
  29542. }
  29543. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  29544. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29546. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  29547. if !m.op.Is(OpUpdateOne) {
  29548. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  29549. }
  29550. if m.id == nil || m.oldValue == nil {
  29551. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  29552. }
  29553. oldValue, err := m.oldValue(ctx)
  29554. if err != nil {
  29555. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  29556. }
  29557. return oldValue.EndIndex, nil
  29558. }
  29559. // AddEndIndex adds u to the "end_index" field.
  29560. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  29561. if m.addend_index != nil {
  29562. *m.addend_index += u
  29563. } else {
  29564. m.addend_index = &u
  29565. }
  29566. }
  29567. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  29568. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  29569. v := m.addend_index
  29570. if v == nil {
  29571. return
  29572. }
  29573. return *v, true
  29574. }
  29575. // ClearEndIndex clears the value of the "end_index" field.
  29576. func (m *UsageTotalMutation) ClearEndIndex() {
  29577. m.end_index = nil
  29578. m.addend_index = nil
  29579. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  29580. }
  29581. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  29582. func (m *UsageTotalMutation) EndIndexCleared() bool {
  29583. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  29584. return ok
  29585. }
  29586. // ResetEndIndex resets all changes to the "end_index" field.
  29587. func (m *UsageTotalMutation) ResetEndIndex() {
  29588. m.end_index = nil
  29589. m.addend_index = nil
  29590. delete(m.clearedFields, usagetotal.FieldEndIndex)
  29591. }
  29592. // SetOrganizationID sets the "organization_id" field.
  29593. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  29594. m.organization_id = &u
  29595. m.addorganization_id = nil
  29596. }
  29597. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29598. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  29599. v := m.organization_id
  29600. if v == nil {
  29601. return
  29602. }
  29603. return *v, true
  29604. }
  29605. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  29606. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29608. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29609. if !m.op.Is(OpUpdateOne) {
  29610. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29611. }
  29612. if m.id == nil || m.oldValue == nil {
  29613. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29614. }
  29615. oldValue, err := m.oldValue(ctx)
  29616. if err != nil {
  29617. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29618. }
  29619. return oldValue.OrganizationID, nil
  29620. }
  29621. // AddOrganizationID adds u to the "organization_id" field.
  29622. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  29623. if m.addorganization_id != nil {
  29624. *m.addorganization_id += u
  29625. } else {
  29626. m.addorganization_id = &u
  29627. }
  29628. }
  29629. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29630. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  29631. v := m.addorganization_id
  29632. if v == nil {
  29633. return
  29634. }
  29635. return *v, true
  29636. }
  29637. // ClearOrganizationID clears the value of the "organization_id" field.
  29638. func (m *UsageTotalMutation) ClearOrganizationID() {
  29639. m.organization_id = nil
  29640. m.addorganization_id = nil
  29641. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  29642. }
  29643. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29644. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  29645. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  29646. return ok
  29647. }
  29648. // ResetOrganizationID resets all changes to the "organization_id" field.
  29649. func (m *UsageTotalMutation) ResetOrganizationID() {
  29650. m.organization_id = nil
  29651. m.addorganization_id = nil
  29652. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  29653. }
  29654. // Where appends a list predicates to the UsageTotalMutation builder.
  29655. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  29656. m.predicates = append(m.predicates, ps...)
  29657. }
  29658. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  29659. // users can use type-assertion to append predicates that do not depend on any generated package.
  29660. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  29661. p := make([]predicate.UsageTotal, len(ps))
  29662. for i := range ps {
  29663. p[i] = ps[i]
  29664. }
  29665. m.Where(p...)
  29666. }
  29667. // Op returns the operation name.
  29668. func (m *UsageTotalMutation) Op() Op {
  29669. return m.op
  29670. }
  29671. // SetOp allows setting the mutation operation.
  29672. func (m *UsageTotalMutation) SetOp(op Op) {
  29673. m.op = op
  29674. }
  29675. // Type returns the node type of this mutation (UsageTotal).
  29676. func (m *UsageTotalMutation) Type() string {
  29677. return m.typ
  29678. }
  29679. // Fields returns all fields that were changed during this mutation. Note that in
  29680. // order to get all numeric fields that were incremented/decremented, call
  29681. // AddedFields().
  29682. func (m *UsageTotalMutation) Fields() []string {
  29683. fields := make([]string, 0, 9)
  29684. if m.created_at != nil {
  29685. fields = append(fields, usagetotal.FieldCreatedAt)
  29686. }
  29687. if m.updated_at != nil {
  29688. fields = append(fields, usagetotal.FieldUpdatedAt)
  29689. }
  29690. if m.status != nil {
  29691. fields = append(fields, usagetotal.FieldStatus)
  29692. }
  29693. if m._type != nil {
  29694. fields = append(fields, usagetotal.FieldType)
  29695. }
  29696. if m.bot_id != nil {
  29697. fields = append(fields, usagetotal.FieldBotID)
  29698. }
  29699. if m.total_tokens != nil {
  29700. fields = append(fields, usagetotal.FieldTotalTokens)
  29701. }
  29702. if m.start_index != nil {
  29703. fields = append(fields, usagetotal.FieldStartIndex)
  29704. }
  29705. if m.end_index != nil {
  29706. fields = append(fields, usagetotal.FieldEndIndex)
  29707. }
  29708. if m.organization_id != nil {
  29709. fields = append(fields, usagetotal.FieldOrganizationID)
  29710. }
  29711. return fields
  29712. }
  29713. // Field returns the value of a field with the given name. The second boolean
  29714. // return value indicates that this field was not set, or was not defined in the
  29715. // schema.
  29716. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  29717. switch name {
  29718. case usagetotal.FieldCreatedAt:
  29719. return m.CreatedAt()
  29720. case usagetotal.FieldUpdatedAt:
  29721. return m.UpdatedAt()
  29722. case usagetotal.FieldStatus:
  29723. return m.Status()
  29724. case usagetotal.FieldType:
  29725. return m.GetType()
  29726. case usagetotal.FieldBotID:
  29727. return m.BotID()
  29728. case usagetotal.FieldTotalTokens:
  29729. return m.TotalTokens()
  29730. case usagetotal.FieldStartIndex:
  29731. return m.StartIndex()
  29732. case usagetotal.FieldEndIndex:
  29733. return m.EndIndex()
  29734. case usagetotal.FieldOrganizationID:
  29735. return m.OrganizationID()
  29736. }
  29737. return nil, false
  29738. }
  29739. // OldField returns the old value of the field from the database. An error is
  29740. // returned if the mutation operation is not UpdateOne, or the query to the
  29741. // database failed.
  29742. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29743. switch name {
  29744. case usagetotal.FieldCreatedAt:
  29745. return m.OldCreatedAt(ctx)
  29746. case usagetotal.FieldUpdatedAt:
  29747. return m.OldUpdatedAt(ctx)
  29748. case usagetotal.FieldStatus:
  29749. return m.OldStatus(ctx)
  29750. case usagetotal.FieldType:
  29751. return m.OldType(ctx)
  29752. case usagetotal.FieldBotID:
  29753. return m.OldBotID(ctx)
  29754. case usagetotal.FieldTotalTokens:
  29755. return m.OldTotalTokens(ctx)
  29756. case usagetotal.FieldStartIndex:
  29757. return m.OldStartIndex(ctx)
  29758. case usagetotal.FieldEndIndex:
  29759. return m.OldEndIndex(ctx)
  29760. case usagetotal.FieldOrganizationID:
  29761. return m.OldOrganizationID(ctx)
  29762. }
  29763. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  29764. }
  29765. // SetField sets the value of a field with the given name. It returns an error if
  29766. // the field is not defined in the schema, or if the type mismatched the field
  29767. // type.
  29768. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  29769. switch name {
  29770. case usagetotal.FieldCreatedAt:
  29771. v, ok := value.(time.Time)
  29772. if !ok {
  29773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29774. }
  29775. m.SetCreatedAt(v)
  29776. return nil
  29777. case usagetotal.FieldUpdatedAt:
  29778. v, ok := value.(time.Time)
  29779. if !ok {
  29780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29781. }
  29782. m.SetUpdatedAt(v)
  29783. return nil
  29784. case usagetotal.FieldStatus:
  29785. v, ok := value.(uint8)
  29786. if !ok {
  29787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29788. }
  29789. m.SetStatus(v)
  29790. return nil
  29791. case usagetotal.FieldType:
  29792. v, ok := value.(int)
  29793. if !ok {
  29794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29795. }
  29796. m.SetType(v)
  29797. return nil
  29798. case usagetotal.FieldBotID:
  29799. v, ok := value.(string)
  29800. if !ok {
  29801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29802. }
  29803. m.SetBotID(v)
  29804. return nil
  29805. case usagetotal.FieldTotalTokens:
  29806. v, ok := value.(uint64)
  29807. if !ok {
  29808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29809. }
  29810. m.SetTotalTokens(v)
  29811. return nil
  29812. case usagetotal.FieldStartIndex:
  29813. v, ok := value.(uint64)
  29814. if !ok {
  29815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29816. }
  29817. m.SetStartIndex(v)
  29818. return nil
  29819. case usagetotal.FieldEndIndex:
  29820. v, ok := value.(uint64)
  29821. if !ok {
  29822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29823. }
  29824. m.SetEndIndex(v)
  29825. return nil
  29826. case usagetotal.FieldOrganizationID:
  29827. v, ok := value.(uint64)
  29828. if !ok {
  29829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29830. }
  29831. m.SetOrganizationID(v)
  29832. return nil
  29833. }
  29834. return fmt.Errorf("unknown UsageTotal field %s", name)
  29835. }
  29836. // AddedFields returns all numeric fields that were incremented/decremented during
  29837. // this mutation.
  29838. func (m *UsageTotalMutation) AddedFields() []string {
  29839. var fields []string
  29840. if m.addstatus != nil {
  29841. fields = append(fields, usagetotal.FieldStatus)
  29842. }
  29843. if m.add_type != nil {
  29844. fields = append(fields, usagetotal.FieldType)
  29845. }
  29846. if m.addtotal_tokens != nil {
  29847. fields = append(fields, usagetotal.FieldTotalTokens)
  29848. }
  29849. if m.addstart_index != nil {
  29850. fields = append(fields, usagetotal.FieldStartIndex)
  29851. }
  29852. if m.addend_index != nil {
  29853. fields = append(fields, usagetotal.FieldEndIndex)
  29854. }
  29855. if m.addorganization_id != nil {
  29856. fields = append(fields, usagetotal.FieldOrganizationID)
  29857. }
  29858. return fields
  29859. }
  29860. // AddedField returns the numeric value that was incremented/decremented on a field
  29861. // with the given name. The second boolean return value indicates that this field
  29862. // was not set, or was not defined in the schema.
  29863. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  29864. switch name {
  29865. case usagetotal.FieldStatus:
  29866. return m.AddedStatus()
  29867. case usagetotal.FieldType:
  29868. return m.AddedType()
  29869. case usagetotal.FieldTotalTokens:
  29870. return m.AddedTotalTokens()
  29871. case usagetotal.FieldStartIndex:
  29872. return m.AddedStartIndex()
  29873. case usagetotal.FieldEndIndex:
  29874. return m.AddedEndIndex()
  29875. case usagetotal.FieldOrganizationID:
  29876. return m.AddedOrganizationID()
  29877. }
  29878. return nil, false
  29879. }
  29880. // AddField adds the value to the field with the given name. It returns an error if
  29881. // the field is not defined in the schema, or if the type mismatched the field
  29882. // type.
  29883. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  29884. switch name {
  29885. case usagetotal.FieldStatus:
  29886. v, ok := value.(int8)
  29887. if !ok {
  29888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29889. }
  29890. m.AddStatus(v)
  29891. return nil
  29892. case usagetotal.FieldType:
  29893. v, ok := value.(int)
  29894. if !ok {
  29895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29896. }
  29897. m.AddType(v)
  29898. return nil
  29899. case usagetotal.FieldTotalTokens:
  29900. v, ok := value.(int64)
  29901. if !ok {
  29902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29903. }
  29904. m.AddTotalTokens(v)
  29905. return nil
  29906. case usagetotal.FieldStartIndex:
  29907. v, ok := value.(int64)
  29908. if !ok {
  29909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29910. }
  29911. m.AddStartIndex(v)
  29912. return nil
  29913. case usagetotal.FieldEndIndex:
  29914. v, ok := value.(int64)
  29915. if !ok {
  29916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29917. }
  29918. m.AddEndIndex(v)
  29919. return nil
  29920. case usagetotal.FieldOrganizationID:
  29921. v, ok := value.(int64)
  29922. if !ok {
  29923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29924. }
  29925. m.AddOrganizationID(v)
  29926. return nil
  29927. }
  29928. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  29929. }
  29930. // ClearedFields returns all nullable fields that were cleared during this
  29931. // mutation.
  29932. func (m *UsageTotalMutation) ClearedFields() []string {
  29933. var fields []string
  29934. if m.FieldCleared(usagetotal.FieldStatus) {
  29935. fields = append(fields, usagetotal.FieldStatus)
  29936. }
  29937. if m.FieldCleared(usagetotal.FieldType) {
  29938. fields = append(fields, usagetotal.FieldType)
  29939. }
  29940. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  29941. fields = append(fields, usagetotal.FieldTotalTokens)
  29942. }
  29943. if m.FieldCleared(usagetotal.FieldStartIndex) {
  29944. fields = append(fields, usagetotal.FieldStartIndex)
  29945. }
  29946. if m.FieldCleared(usagetotal.FieldEndIndex) {
  29947. fields = append(fields, usagetotal.FieldEndIndex)
  29948. }
  29949. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  29950. fields = append(fields, usagetotal.FieldOrganizationID)
  29951. }
  29952. return fields
  29953. }
  29954. // FieldCleared returns a boolean indicating if a field with the given name was
  29955. // cleared in this mutation.
  29956. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  29957. _, ok := m.clearedFields[name]
  29958. return ok
  29959. }
  29960. // ClearField clears the value of the field with the given name. It returns an
  29961. // error if the field is not defined in the schema.
  29962. func (m *UsageTotalMutation) ClearField(name string) error {
  29963. switch name {
  29964. case usagetotal.FieldStatus:
  29965. m.ClearStatus()
  29966. return nil
  29967. case usagetotal.FieldType:
  29968. m.ClearType()
  29969. return nil
  29970. case usagetotal.FieldTotalTokens:
  29971. m.ClearTotalTokens()
  29972. return nil
  29973. case usagetotal.FieldStartIndex:
  29974. m.ClearStartIndex()
  29975. return nil
  29976. case usagetotal.FieldEndIndex:
  29977. m.ClearEndIndex()
  29978. return nil
  29979. case usagetotal.FieldOrganizationID:
  29980. m.ClearOrganizationID()
  29981. return nil
  29982. }
  29983. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  29984. }
  29985. // ResetField resets all changes in the mutation for the field with the given name.
  29986. // It returns an error if the field is not defined in the schema.
  29987. func (m *UsageTotalMutation) ResetField(name string) error {
  29988. switch name {
  29989. case usagetotal.FieldCreatedAt:
  29990. m.ResetCreatedAt()
  29991. return nil
  29992. case usagetotal.FieldUpdatedAt:
  29993. m.ResetUpdatedAt()
  29994. return nil
  29995. case usagetotal.FieldStatus:
  29996. m.ResetStatus()
  29997. return nil
  29998. case usagetotal.FieldType:
  29999. m.ResetType()
  30000. return nil
  30001. case usagetotal.FieldBotID:
  30002. m.ResetBotID()
  30003. return nil
  30004. case usagetotal.FieldTotalTokens:
  30005. m.ResetTotalTokens()
  30006. return nil
  30007. case usagetotal.FieldStartIndex:
  30008. m.ResetStartIndex()
  30009. return nil
  30010. case usagetotal.FieldEndIndex:
  30011. m.ResetEndIndex()
  30012. return nil
  30013. case usagetotal.FieldOrganizationID:
  30014. m.ResetOrganizationID()
  30015. return nil
  30016. }
  30017. return fmt.Errorf("unknown UsageTotal field %s", name)
  30018. }
  30019. // AddedEdges returns all edge names that were set/added in this mutation.
  30020. func (m *UsageTotalMutation) AddedEdges() []string {
  30021. edges := make([]string, 0, 0)
  30022. return edges
  30023. }
  30024. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30025. // name in this mutation.
  30026. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  30027. return nil
  30028. }
  30029. // RemovedEdges returns all edge names that were removed in this mutation.
  30030. func (m *UsageTotalMutation) RemovedEdges() []string {
  30031. edges := make([]string, 0, 0)
  30032. return edges
  30033. }
  30034. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30035. // the given name in this mutation.
  30036. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  30037. return nil
  30038. }
  30039. // ClearedEdges returns all edge names that were cleared in this mutation.
  30040. func (m *UsageTotalMutation) ClearedEdges() []string {
  30041. edges := make([]string, 0, 0)
  30042. return edges
  30043. }
  30044. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30045. // was cleared in this mutation.
  30046. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  30047. return false
  30048. }
  30049. // ClearEdge clears the value of the edge with the given name. It returns an error
  30050. // if that edge is not defined in the schema.
  30051. func (m *UsageTotalMutation) ClearEdge(name string) error {
  30052. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  30053. }
  30054. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30055. // It returns an error if the edge is not defined in the schema.
  30056. func (m *UsageTotalMutation) ResetEdge(name string) error {
  30057. return fmt.Errorf("unknown UsageTotal edge %s", name)
  30058. }
  30059. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  30060. type WorkExperienceMutation struct {
  30061. config
  30062. op Op
  30063. typ string
  30064. id *uint64
  30065. created_at *time.Time
  30066. updated_at *time.Time
  30067. deleted_at *time.Time
  30068. start_date *time.Time
  30069. end_date *time.Time
  30070. company *string
  30071. experience *string
  30072. organization_id *uint64
  30073. addorganization_id *int64
  30074. clearedFields map[string]struct{}
  30075. employee *uint64
  30076. clearedemployee bool
  30077. done bool
  30078. oldValue func(context.Context) (*WorkExperience, error)
  30079. predicates []predicate.WorkExperience
  30080. }
  30081. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  30082. // workexperienceOption allows management of the mutation configuration using functional options.
  30083. type workexperienceOption func(*WorkExperienceMutation)
  30084. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  30085. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  30086. m := &WorkExperienceMutation{
  30087. config: c,
  30088. op: op,
  30089. typ: TypeWorkExperience,
  30090. clearedFields: make(map[string]struct{}),
  30091. }
  30092. for _, opt := range opts {
  30093. opt(m)
  30094. }
  30095. return m
  30096. }
  30097. // withWorkExperienceID sets the ID field of the mutation.
  30098. func withWorkExperienceID(id uint64) workexperienceOption {
  30099. return func(m *WorkExperienceMutation) {
  30100. var (
  30101. err error
  30102. once sync.Once
  30103. value *WorkExperience
  30104. )
  30105. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  30106. once.Do(func() {
  30107. if m.done {
  30108. err = errors.New("querying old values post mutation is not allowed")
  30109. } else {
  30110. value, err = m.Client().WorkExperience.Get(ctx, id)
  30111. }
  30112. })
  30113. return value, err
  30114. }
  30115. m.id = &id
  30116. }
  30117. }
  30118. // withWorkExperience sets the old WorkExperience of the mutation.
  30119. func withWorkExperience(node *WorkExperience) workexperienceOption {
  30120. return func(m *WorkExperienceMutation) {
  30121. m.oldValue = func(context.Context) (*WorkExperience, error) {
  30122. return node, nil
  30123. }
  30124. m.id = &node.ID
  30125. }
  30126. }
  30127. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30128. // executed in a transaction (ent.Tx), a transactional client is returned.
  30129. func (m WorkExperienceMutation) Client() *Client {
  30130. client := &Client{config: m.config}
  30131. client.init()
  30132. return client
  30133. }
  30134. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30135. // it returns an error otherwise.
  30136. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  30137. if _, ok := m.driver.(*txDriver); !ok {
  30138. return nil, errors.New("ent: mutation is not running in a transaction")
  30139. }
  30140. tx := &Tx{config: m.config}
  30141. tx.init()
  30142. return tx, nil
  30143. }
  30144. // SetID sets the value of the id field. Note that this
  30145. // operation is only accepted on creation of WorkExperience entities.
  30146. func (m *WorkExperienceMutation) SetID(id uint64) {
  30147. m.id = &id
  30148. }
  30149. // ID returns the ID value in the mutation. Note that the ID is only available
  30150. // if it was provided to the builder or after it was returned from the database.
  30151. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  30152. if m.id == nil {
  30153. return
  30154. }
  30155. return *m.id, true
  30156. }
  30157. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30158. // That means, if the mutation is applied within a transaction with an isolation level such
  30159. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30160. // or updated by the mutation.
  30161. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  30162. switch {
  30163. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30164. id, exists := m.ID()
  30165. if exists {
  30166. return []uint64{id}, nil
  30167. }
  30168. fallthrough
  30169. case m.op.Is(OpUpdate | OpDelete):
  30170. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  30171. default:
  30172. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30173. }
  30174. }
  30175. // SetCreatedAt sets the "created_at" field.
  30176. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  30177. m.created_at = &t
  30178. }
  30179. // CreatedAt returns the value of the "created_at" field in the mutation.
  30180. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  30181. v := m.created_at
  30182. if v == nil {
  30183. return
  30184. }
  30185. return *v, true
  30186. }
  30187. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  30188. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30190. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30191. if !m.op.Is(OpUpdateOne) {
  30192. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30193. }
  30194. if m.id == nil || m.oldValue == nil {
  30195. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30196. }
  30197. oldValue, err := m.oldValue(ctx)
  30198. if err != nil {
  30199. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30200. }
  30201. return oldValue.CreatedAt, nil
  30202. }
  30203. // ResetCreatedAt resets all changes to the "created_at" field.
  30204. func (m *WorkExperienceMutation) ResetCreatedAt() {
  30205. m.created_at = nil
  30206. }
  30207. // SetUpdatedAt sets the "updated_at" field.
  30208. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  30209. m.updated_at = &t
  30210. }
  30211. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30212. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  30213. v := m.updated_at
  30214. if v == nil {
  30215. return
  30216. }
  30217. return *v, true
  30218. }
  30219. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  30220. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30222. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30223. if !m.op.Is(OpUpdateOne) {
  30224. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30225. }
  30226. if m.id == nil || m.oldValue == nil {
  30227. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30228. }
  30229. oldValue, err := m.oldValue(ctx)
  30230. if err != nil {
  30231. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30232. }
  30233. return oldValue.UpdatedAt, nil
  30234. }
  30235. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30236. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  30237. m.updated_at = nil
  30238. }
  30239. // SetDeletedAt sets the "deleted_at" field.
  30240. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  30241. m.deleted_at = &t
  30242. }
  30243. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30244. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  30245. v := m.deleted_at
  30246. if v == nil {
  30247. return
  30248. }
  30249. return *v, true
  30250. }
  30251. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  30252. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30254. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30255. if !m.op.Is(OpUpdateOne) {
  30256. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30257. }
  30258. if m.id == nil || m.oldValue == nil {
  30259. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30260. }
  30261. oldValue, err := m.oldValue(ctx)
  30262. if err != nil {
  30263. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30264. }
  30265. return oldValue.DeletedAt, nil
  30266. }
  30267. // ClearDeletedAt clears the value of the "deleted_at" field.
  30268. func (m *WorkExperienceMutation) ClearDeletedAt() {
  30269. m.deleted_at = nil
  30270. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  30271. }
  30272. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30273. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  30274. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  30275. return ok
  30276. }
  30277. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30278. func (m *WorkExperienceMutation) ResetDeletedAt() {
  30279. m.deleted_at = nil
  30280. delete(m.clearedFields, workexperience.FieldDeletedAt)
  30281. }
  30282. // SetEmployeeID sets the "employee_id" field.
  30283. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  30284. m.employee = &u
  30285. }
  30286. // EmployeeID returns the value of the "employee_id" field in the mutation.
  30287. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  30288. v := m.employee
  30289. if v == nil {
  30290. return
  30291. }
  30292. return *v, true
  30293. }
  30294. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  30295. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30297. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  30298. if !m.op.Is(OpUpdateOne) {
  30299. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  30300. }
  30301. if m.id == nil || m.oldValue == nil {
  30302. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  30303. }
  30304. oldValue, err := m.oldValue(ctx)
  30305. if err != nil {
  30306. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  30307. }
  30308. return oldValue.EmployeeID, nil
  30309. }
  30310. // ResetEmployeeID resets all changes to the "employee_id" field.
  30311. func (m *WorkExperienceMutation) ResetEmployeeID() {
  30312. m.employee = nil
  30313. }
  30314. // SetStartDate sets the "start_date" field.
  30315. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  30316. m.start_date = &t
  30317. }
  30318. // StartDate returns the value of the "start_date" field in the mutation.
  30319. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  30320. v := m.start_date
  30321. if v == nil {
  30322. return
  30323. }
  30324. return *v, true
  30325. }
  30326. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  30327. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30329. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  30330. if !m.op.Is(OpUpdateOne) {
  30331. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  30332. }
  30333. if m.id == nil || m.oldValue == nil {
  30334. return v, errors.New("OldStartDate requires an ID field in the mutation")
  30335. }
  30336. oldValue, err := m.oldValue(ctx)
  30337. if err != nil {
  30338. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  30339. }
  30340. return oldValue.StartDate, nil
  30341. }
  30342. // ResetStartDate resets all changes to the "start_date" field.
  30343. func (m *WorkExperienceMutation) ResetStartDate() {
  30344. m.start_date = nil
  30345. }
  30346. // SetEndDate sets the "end_date" field.
  30347. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  30348. m.end_date = &t
  30349. }
  30350. // EndDate returns the value of the "end_date" field in the mutation.
  30351. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  30352. v := m.end_date
  30353. if v == nil {
  30354. return
  30355. }
  30356. return *v, true
  30357. }
  30358. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  30359. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30361. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  30362. if !m.op.Is(OpUpdateOne) {
  30363. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  30364. }
  30365. if m.id == nil || m.oldValue == nil {
  30366. return v, errors.New("OldEndDate requires an ID field in the mutation")
  30367. }
  30368. oldValue, err := m.oldValue(ctx)
  30369. if err != nil {
  30370. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  30371. }
  30372. return oldValue.EndDate, nil
  30373. }
  30374. // ResetEndDate resets all changes to the "end_date" field.
  30375. func (m *WorkExperienceMutation) ResetEndDate() {
  30376. m.end_date = nil
  30377. }
  30378. // SetCompany sets the "company" field.
  30379. func (m *WorkExperienceMutation) SetCompany(s string) {
  30380. m.company = &s
  30381. }
  30382. // Company returns the value of the "company" field in the mutation.
  30383. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  30384. v := m.company
  30385. if v == nil {
  30386. return
  30387. }
  30388. return *v, true
  30389. }
  30390. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  30391. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30393. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  30394. if !m.op.Is(OpUpdateOne) {
  30395. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  30396. }
  30397. if m.id == nil || m.oldValue == nil {
  30398. return v, errors.New("OldCompany requires an ID field in the mutation")
  30399. }
  30400. oldValue, err := m.oldValue(ctx)
  30401. if err != nil {
  30402. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  30403. }
  30404. return oldValue.Company, nil
  30405. }
  30406. // ResetCompany resets all changes to the "company" field.
  30407. func (m *WorkExperienceMutation) ResetCompany() {
  30408. m.company = nil
  30409. }
  30410. // SetExperience sets the "experience" field.
  30411. func (m *WorkExperienceMutation) SetExperience(s string) {
  30412. m.experience = &s
  30413. }
  30414. // Experience returns the value of the "experience" field in the mutation.
  30415. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  30416. v := m.experience
  30417. if v == nil {
  30418. return
  30419. }
  30420. return *v, true
  30421. }
  30422. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  30423. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30425. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  30426. if !m.op.Is(OpUpdateOne) {
  30427. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  30428. }
  30429. if m.id == nil || m.oldValue == nil {
  30430. return v, errors.New("OldExperience requires an ID field in the mutation")
  30431. }
  30432. oldValue, err := m.oldValue(ctx)
  30433. if err != nil {
  30434. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  30435. }
  30436. return oldValue.Experience, nil
  30437. }
  30438. // ResetExperience resets all changes to the "experience" field.
  30439. func (m *WorkExperienceMutation) ResetExperience() {
  30440. m.experience = nil
  30441. }
  30442. // SetOrganizationID sets the "organization_id" field.
  30443. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  30444. m.organization_id = &u
  30445. m.addorganization_id = nil
  30446. }
  30447. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30448. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  30449. v := m.organization_id
  30450. if v == nil {
  30451. return
  30452. }
  30453. return *v, true
  30454. }
  30455. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  30456. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30458. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30459. if !m.op.Is(OpUpdateOne) {
  30460. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30461. }
  30462. if m.id == nil || m.oldValue == nil {
  30463. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30464. }
  30465. oldValue, err := m.oldValue(ctx)
  30466. if err != nil {
  30467. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30468. }
  30469. return oldValue.OrganizationID, nil
  30470. }
  30471. // AddOrganizationID adds u to the "organization_id" field.
  30472. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  30473. if m.addorganization_id != nil {
  30474. *m.addorganization_id += u
  30475. } else {
  30476. m.addorganization_id = &u
  30477. }
  30478. }
  30479. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30480. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  30481. v := m.addorganization_id
  30482. if v == nil {
  30483. return
  30484. }
  30485. return *v, true
  30486. }
  30487. // ResetOrganizationID resets all changes to the "organization_id" field.
  30488. func (m *WorkExperienceMutation) ResetOrganizationID() {
  30489. m.organization_id = nil
  30490. m.addorganization_id = nil
  30491. }
  30492. // ClearEmployee clears the "employee" edge to the Employee entity.
  30493. func (m *WorkExperienceMutation) ClearEmployee() {
  30494. m.clearedemployee = true
  30495. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  30496. }
  30497. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  30498. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  30499. return m.clearedemployee
  30500. }
  30501. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  30502. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30503. // EmployeeID instead. It exists only for internal usage by the builders.
  30504. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  30505. if id := m.employee; id != nil {
  30506. ids = append(ids, *id)
  30507. }
  30508. return
  30509. }
  30510. // ResetEmployee resets all changes to the "employee" edge.
  30511. func (m *WorkExperienceMutation) ResetEmployee() {
  30512. m.employee = nil
  30513. m.clearedemployee = false
  30514. }
  30515. // Where appends a list predicates to the WorkExperienceMutation builder.
  30516. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  30517. m.predicates = append(m.predicates, ps...)
  30518. }
  30519. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  30520. // users can use type-assertion to append predicates that do not depend on any generated package.
  30521. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  30522. p := make([]predicate.WorkExperience, len(ps))
  30523. for i := range ps {
  30524. p[i] = ps[i]
  30525. }
  30526. m.Where(p...)
  30527. }
  30528. // Op returns the operation name.
  30529. func (m *WorkExperienceMutation) Op() Op {
  30530. return m.op
  30531. }
  30532. // SetOp allows setting the mutation operation.
  30533. func (m *WorkExperienceMutation) SetOp(op Op) {
  30534. m.op = op
  30535. }
  30536. // Type returns the node type of this mutation (WorkExperience).
  30537. func (m *WorkExperienceMutation) Type() string {
  30538. return m.typ
  30539. }
  30540. // Fields returns all fields that were changed during this mutation. Note that in
  30541. // order to get all numeric fields that were incremented/decremented, call
  30542. // AddedFields().
  30543. func (m *WorkExperienceMutation) Fields() []string {
  30544. fields := make([]string, 0, 9)
  30545. if m.created_at != nil {
  30546. fields = append(fields, workexperience.FieldCreatedAt)
  30547. }
  30548. if m.updated_at != nil {
  30549. fields = append(fields, workexperience.FieldUpdatedAt)
  30550. }
  30551. if m.deleted_at != nil {
  30552. fields = append(fields, workexperience.FieldDeletedAt)
  30553. }
  30554. if m.employee != nil {
  30555. fields = append(fields, workexperience.FieldEmployeeID)
  30556. }
  30557. if m.start_date != nil {
  30558. fields = append(fields, workexperience.FieldStartDate)
  30559. }
  30560. if m.end_date != nil {
  30561. fields = append(fields, workexperience.FieldEndDate)
  30562. }
  30563. if m.company != nil {
  30564. fields = append(fields, workexperience.FieldCompany)
  30565. }
  30566. if m.experience != nil {
  30567. fields = append(fields, workexperience.FieldExperience)
  30568. }
  30569. if m.organization_id != nil {
  30570. fields = append(fields, workexperience.FieldOrganizationID)
  30571. }
  30572. return fields
  30573. }
  30574. // Field returns the value of a field with the given name. The second boolean
  30575. // return value indicates that this field was not set, or was not defined in the
  30576. // schema.
  30577. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  30578. switch name {
  30579. case workexperience.FieldCreatedAt:
  30580. return m.CreatedAt()
  30581. case workexperience.FieldUpdatedAt:
  30582. return m.UpdatedAt()
  30583. case workexperience.FieldDeletedAt:
  30584. return m.DeletedAt()
  30585. case workexperience.FieldEmployeeID:
  30586. return m.EmployeeID()
  30587. case workexperience.FieldStartDate:
  30588. return m.StartDate()
  30589. case workexperience.FieldEndDate:
  30590. return m.EndDate()
  30591. case workexperience.FieldCompany:
  30592. return m.Company()
  30593. case workexperience.FieldExperience:
  30594. return m.Experience()
  30595. case workexperience.FieldOrganizationID:
  30596. return m.OrganizationID()
  30597. }
  30598. return nil, false
  30599. }
  30600. // OldField returns the old value of the field from the database. An error is
  30601. // returned if the mutation operation is not UpdateOne, or the query to the
  30602. // database failed.
  30603. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30604. switch name {
  30605. case workexperience.FieldCreatedAt:
  30606. return m.OldCreatedAt(ctx)
  30607. case workexperience.FieldUpdatedAt:
  30608. return m.OldUpdatedAt(ctx)
  30609. case workexperience.FieldDeletedAt:
  30610. return m.OldDeletedAt(ctx)
  30611. case workexperience.FieldEmployeeID:
  30612. return m.OldEmployeeID(ctx)
  30613. case workexperience.FieldStartDate:
  30614. return m.OldStartDate(ctx)
  30615. case workexperience.FieldEndDate:
  30616. return m.OldEndDate(ctx)
  30617. case workexperience.FieldCompany:
  30618. return m.OldCompany(ctx)
  30619. case workexperience.FieldExperience:
  30620. return m.OldExperience(ctx)
  30621. case workexperience.FieldOrganizationID:
  30622. return m.OldOrganizationID(ctx)
  30623. }
  30624. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  30625. }
  30626. // SetField sets the value of a field with the given name. It returns an error if
  30627. // the field is not defined in the schema, or if the type mismatched the field
  30628. // type.
  30629. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  30630. switch name {
  30631. case workexperience.FieldCreatedAt:
  30632. v, ok := value.(time.Time)
  30633. if !ok {
  30634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30635. }
  30636. m.SetCreatedAt(v)
  30637. return nil
  30638. case workexperience.FieldUpdatedAt:
  30639. v, ok := value.(time.Time)
  30640. if !ok {
  30641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30642. }
  30643. m.SetUpdatedAt(v)
  30644. return nil
  30645. case workexperience.FieldDeletedAt:
  30646. v, ok := value.(time.Time)
  30647. if !ok {
  30648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30649. }
  30650. m.SetDeletedAt(v)
  30651. return nil
  30652. case workexperience.FieldEmployeeID:
  30653. v, ok := value.(uint64)
  30654. if !ok {
  30655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30656. }
  30657. m.SetEmployeeID(v)
  30658. return nil
  30659. case workexperience.FieldStartDate:
  30660. v, ok := value.(time.Time)
  30661. if !ok {
  30662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30663. }
  30664. m.SetStartDate(v)
  30665. return nil
  30666. case workexperience.FieldEndDate:
  30667. v, ok := value.(time.Time)
  30668. if !ok {
  30669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30670. }
  30671. m.SetEndDate(v)
  30672. return nil
  30673. case workexperience.FieldCompany:
  30674. v, ok := value.(string)
  30675. if !ok {
  30676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30677. }
  30678. m.SetCompany(v)
  30679. return nil
  30680. case workexperience.FieldExperience:
  30681. v, ok := value.(string)
  30682. if !ok {
  30683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30684. }
  30685. m.SetExperience(v)
  30686. return nil
  30687. case workexperience.FieldOrganizationID:
  30688. v, ok := value.(uint64)
  30689. if !ok {
  30690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30691. }
  30692. m.SetOrganizationID(v)
  30693. return nil
  30694. }
  30695. return fmt.Errorf("unknown WorkExperience field %s", name)
  30696. }
  30697. // AddedFields returns all numeric fields that were incremented/decremented during
  30698. // this mutation.
  30699. func (m *WorkExperienceMutation) AddedFields() []string {
  30700. var fields []string
  30701. if m.addorganization_id != nil {
  30702. fields = append(fields, workexperience.FieldOrganizationID)
  30703. }
  30704. return fields
  30705. }
  30706. // AddedField returns the numeric value that was incremented/decremented on a field
  30707. // with the given name. The second boolean return value indicates that this field
  30708. // was not set, or was not defined in the schema.
  30709. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  30710. switch name {
  30711. case workexperience.FieldOrganizationID:
  30712. return m.AddedOrganizationID()
  30713. }
  30714. return nil, false
  30715. }
  30716. // AddField adds the value to the field with the given name. It returns an error if
  30717. // the field is not defined in the schema, or if the type mismatched the field
  30718. // type.
  30719. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  30720. switch name {
  30721. case workexperience.FieldOrganizationID:
  30722. v, ok := value.(int64)
  30723. if !ok {
  30724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30725. }
  30726. m.AddOrganizationID(v)
  30727. return nil
  30728. }
  30729. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  30730. }
  30731. // ClearedFields returns all nullable fields that were cleared during this
  30732. // mutation.
  30733. func (m *WorkExperienceMutation) ClearedFields() []string {
  30734. var fields []string
  30735. if m.FieldCleared(workexperience.FieldDeletedAt) {
  30736. fields = append(fields, workexperience.FieldDeletedAt)
  30737. }
  30738. return fields
  30739. }
  30740. // FieldCleared returns a boolean indicating if a field with the given name was
  30741. // cleared in this mutation.
  30742. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  30743. _, ok := m.clearedFields[name]
  30744. return ok
  30745. }
  30746. // ClearField clears the value of the field with the given name. It returns an
  30747. // error if the field is not defined in the schema.
  30748. func (m *WorkExperienceMutation) ClearField(name string) error {
  30749. switch name {
  30750. case workexperience.FieldDeletedAt:
  30751. m.ClearDeletedAt()
  30752. return nil
  30753. }
  30754. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  30755. }
  30756. // ResetField resets all changes in the mutation for the field with the given name.
  30757. // It returns an error if the field is not defined in the schema.
  30758. func (m *WorkExperienceMutation) ResetField(name string) error {
  30759. switch name {
  30760. case workexperience.FieldCreatedAt:
  30761. m.ResetCreatedAt()
  30762. return nil
  30763. case workexperience.FieldUpdatedAt:
  30764. m.ResetUpdatedAt()
  30765. return nil
  30766. case workexperience.FieldDeletedAt:
  30767. m.ResetDeletedAt()
  30768. return nil
  30769. case workexperience.FieldEmployeeID:
  30770. m.ResetEmployeeID()
  30771. return nil
  30772. case workexperience.FieldStartDate:
  30773. m.ResetStartDate()
  30774. return nil
  30775. case workexperience.FieldEndDate:
  30776. m.ResetEndDate()
  30777. return nil
  30778. case workexperience.FieldCompany:
  30779. m.ResetCompany()
  30780. return nil
  30781. case workexperience.FieldExperience:
  30782. m.ResetExperience()
  30783. return nil
  30784. case workexperience.FieldOrganizationID:
  30785. m.ResetOrganizationID()
  30786. return nil
  30787. }
  30788. return fmt.Errorf("unknown WorkExperience field %s", name)
  30789. }
  30790. // AddedEdges returns all edge names that were set/added in this mutation.
  30791. func (m *WorkExperienceMutation) AddedEdges() []string {
  30792. edges := make([]string, 0, 1)
  30793. if m.employee != nil {
  30794. edges = append(edges, workexperience.EdgeEmployee)
  30795. }
  30796. return edges
  30797. }
  30798. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30799. // name in this mutation.
  30800. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  30801. switch name {
  30802. case workexperience.EdgeEmployee:
  30803. if id := m.employee; id != nil {
  30804. return []ent.Value{*id}
  30805. }
  30806. }
  30807. return nil
  30808. }
  30809. // RemovedEdges returns all edge names that were removed in this mutation.
  30810. func (m *WorkExperienceMutation) RemovedEdges() []string {
  30811. edges := make([]string, 0, 1)
  30812. return edges
  30813. }
  30814. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30815. // the given name in this mutation.
  30816. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  30817. return nil
  30818. }
  30819. // ClearedEdges returns all edge names that were cleared in this mutation.
  30820. func (m *WorkExperienceMutation) ClearedEdges() []string {
  30821. edges := make([]string, 0, 1)
  30822. if m.clearedemployee {
  30823. edges = append(edges, workexperience.EdgeEmployee)
  30824. }
  30825. return edges
  30826. }
  30827. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30828. // was cleared in this mutation.
  30829. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  30830. switch name {
  30831. case workexperience.EdgeEmployee:
  30832. return m.clearedemployee
  30833. }
  30834. return false
  30835. }
  30836. // ClearEdge clears the value of the edge with the given name. It returns an error
  30837. // if that edge is not defined in the schema.
  30838. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  30839. switch name {
  30840. case workexperience.EdgeEmployee:
  30841. m.ClearEmployee()
  30842. return nil
  30843. }
  30844. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  30845. }
  30846. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30847. // It returns an error if the edge is not defined in the schema.
  30848. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  30849. switch name {
  30850. case workexperience.EdgeEmployee:
  30851. m.ResetEmployee()
  30852. return nil
  30853. }
  30854. return fmt.Errorf("unknown WorkExperience edge %s", name)
  30855. }
  30856. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  30857. type WpChatroomMutation struct {
  30858. config
  30859. op Op
  30860. typ string
  30861. id *uint64
  30862. created_at *time.Time
  30863. updated_at *time.Time
  30864. status *uint8
  30865. addstatus *int8
  30866. wx_wxid *string
  30867. chatroom_id *string
  30868. nickname *string
  30869. owner *string
  30870. avatar *string
  30871. member_list *[]string
  30872. appendmember_list []string
  30873. clearedFields map[string]struct{}
  30874. done bool
  30875. oldValue func(context.Context) (*WpChatroom, error)
  30876. predicates []predicate.WpChatroom
  30877. }
  30878. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  30879. // wpchatroomOption allows management of the mutation configuration using functional options.
  30880. type wpchatroomOption func(*WpChatroomMutation)
  30881. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  30882. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  30883. m := &WpChatroomMutation{
  30884. config: c,
  30885. op: op,
  30886. typ: TypeWpChatroom,
  30887. clearedFields: make(map[string]struct{}),
  30888. }
  30889. for _, opt := range opts {
  30890. opt(m)
  30891. }
  30892. return m
  30893. }
  30894. // withWpChatroomID sets the ID field of the mutation.
  30895. func withWpChatroomID(id uint64) wpchatroomOption {
  30896. return func(m *WpChatroomMutation) {
  30897. var (
  30898. err error
  30899. once sync.Once
  30900. value *WpChatroom
  30901. )
  30902. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  30903. once.Do(func() {
  30904. if m.done {
  30905. err = errors.New("querying old values post mutation is not allowed")
  30906. } else {
  30907. value, err = m.Client().WpChatroom.Get(ctx, id)
  30908. }
  30909. })
  30910. return value, err
  30911. }
  30912. m.id = &id
  30913. }
  30914. }
  30915. // withWpChatroom sets the old WpChatroom of the mutation.
  30916. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  30917. return func(m *WpChatroomMutation) {
  30918. m.oldValue = func(context.Context) (*WpChatroom, error) {
  30919. return node, nil
  30920. }
  30921. m.id = &node.ID
  30922. }
  30923. }
  30924. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30925. // executed in a transaction (ent.Tx), a transactional client is returned.
  30926. func (m WpChatroomMutation) Client() *Client {
  30927. client := &Client{config: m.config}
  30928. client.init()
  30929. return client
  30930. }
  30931. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30932. // it returns an error otherwise.
  30933. func (m WpChatroomMutation) Tx() (*Tx, error) {
  30934. if _, ok := m.driver.(*txDriver); !ok {
  30935. return nil, errors.New("ent: mutation is not running in a transaction")
  30936. }
  30937. tx := &Tx{config: m.config}
  30938. tx.init()
  30939. return tx, nil
  30940. }
  30941. // SetID sets the value of the id field. Note that this
  30942. // operation is only accepted on creation of WpChatroom entities.
  30943. func (m *WpChatroomMutation) SetID(id uint64) {
  30944. m.id = &id
  30945. }
  30946. // ID returns the ID value in the mutation. Note that the ID is only available
  30947. // if it was provided to the builder or after it was returned from the database.
  30948. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  30949. if m.id == nil {
  30950. return
  30951. }
  30952. return *m.id, true
  30953. }
  30954. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30955. // That means, if the mutation is applied within a transaction with an isolation level such
  30956. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30957. // or updated by the mutation.
  30958. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  30959. switch {
  30960. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30961. id, exists := m.ID()
  30962. if exists {
  30963. return []uint64{id}, nil
  30964. }
  30965. fallthrough
  30966. case m.op.Is(OpUpdate | OpDelete):
  30967. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  30968. default:
  30969. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30970. }
  30971. }
  30972. // SetCreatedAt sets the "created_at" field.
  30973. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  30974. m.created_at = &t
  30975. }
  30976. // CreatedAt returns the value of the "created_at" field in the mutation.
  30977. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  30978. v := m.created_at
  30979. if v == nil {
  30980. return
  30981. }
  30982. return *v, true
  30983. }
  30984. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  30985. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  30986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30987. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30988. if !m.op.Is(OpUpdateOne) {
  30989. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30990. }
  30991. if m.id == nil || m.oldValue == nil {
  30992. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30993. }
  30994. oldValue, err := m.oldValue(ctx)
  30995. if err != nil {
  30996. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30997. }
  30998. return oldValue.CreatedAt, nil
  30999. }
  31000. // ResetCreatedAt resets all changes to the "created_at" field.
  31001. func (m *WpChatroomMutation) ResetCreatedAt() {
  31002. m.created_at = nil
  31003. }
  31004. // SetUpdatedAt sets the "updated_at" field.
  31005. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  31006. m.updated_at = &t
  31007. }
  31008. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31009. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  31010. v := m.updated_at
  31011. if v == nil {
  31012. return
  31013. }
  31014. return *v, true
  31015. }
  31016. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  31017. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31019. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31020. if !m.op.Is(OpUpdateOne) {
  31021. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31022. }
  31023. if m.id == nil || m.oldValue == nil {
  31024. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31025. }
  31026. oldValue, err := m.oldValue(ctx)
  31027. if err != nil {
  31028. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31029. }
  31030. return oldValue.UpdatedAt, nil
  31031. }
  31032. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31033. func (m *WpChatroomMutation) ResetUpdatedAt() {
  31034. m.updated_at = nil
  31035. }
  31036. // SetStatus sets the "status" field.
  31037. func (m *WpChatroomMutation) SetStatus(u uint8) {
  31038. m.status = &u
  31039. m.addstatus = nil
  31040. }
  31041. // Status returns the value of the "status" field in the mutation.
  31042. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  31043. v := m.status
  31044. if v == nil {
  31045. return
  31046. }
  31047. return *v, true
  31048. }
  31049. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  31050. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31052. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31053. if !m.op.Is(OpUpdateOne) {
  31054. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31055. }
  31056. if m.id == nil || m.oldValue == nil {
  31057. return v, errors.New("OldStatus requires an ID field in the mutation")
  31058. }
  31059. oldValue, err := m.oldValue(ctx)
  31060. if err != nil {
  31061. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31062. }
  31063. return oldValue.Status, nil
  31064. }
  31065. // AddStatus adds u to the "status" field.
  31066. func (m *WpChatroomMutation) AddStatus(u int8) {
  31067. if m.addstatus != nil {
  31068. *m.addstatus += u
  31069. } else {
  31070. m.addstatus = &u
  31071. }
  31072. }
  31073. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31074. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  31075. v := m.addstatus
  31076. if v == nil {
  31077. return
  31078. }
  31079. return *v, true
  31080. }
  31081. // ClearStatus clears the value of the "status" field.
  31082. func (m *WpChatroomMutation) ClearStatus() {
  31083. m.status = nil
  31084. m.addstatus = nil
  31085. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  31086. }
  31087. // StatusCleared returns if the "status" field was cleared in this mutation.
  31088. func (m *WpChatroomMutation) StatusCleared() bool {
  31089. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  31090. return ok
  31091. }
  31092. // ResetStatus resets all changes to the "status" field.
  31093. func (m *WpChatroomMutation) ResetStatus() {
  31094. m.status = nil
  31095. m.addstatus = nil
  31096. delete(m.clearedFields, wpchatroom.FieldStatus)
  31097. }
  31098. // SetWxWxid sets the "wx_wxid" field.
  31099. func (m *WpChatroomMutation) SetWxWxid(s string) {
  31100. m.wx_wxid = &s
  31101. }
  31102. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  31103. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  31104. v := m.wx_wxid
  31105. if v == nil {
  31106. return
  31107. }
  31108. return *v, true
  31109. }
  31110. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  31111. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31113. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  31114. if !m.op.Is(OpUpdateOne) {
  31115. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  31116. }
  31117. if m.id == nil || m.oldValue == nil {
  31118. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  31119. }
  31120. oldValue, err := m.oldValue(ctx)
  31121. if err != nil {
  31122. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  31123. }
  31124. return oldValue.WxWxid, nil
  31125. }
  31126. // ResetWxWxid resets all changes to the "wx_wxid" field.
  31127. func (m *WpChatroomMutation) ResetWxWxid() {
  31128. m.wx_wxid = nil
  31129. }
  31130. // SetChatroomID sets the "chatroom_id" field.
  31131. func (m *WpChatroomMutation) SetChatroomID(s string) {
  31132. m.chatroom_id = &s
  31133. }
  31134. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  31135. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  31136. v := m.chatroom_id
  31137. if v == nil {
  31138. return
  31139. }
  31140. return *v, true
  31141. }
  31142. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  31143. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31145. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  31146. if !m.op.Is(OpUpdateOne) {
  31147. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  31148. }
  31149. if m.id == nil || m.oldValue == nil {
  31150. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  31151. }
  31152. oldValue, err := m.oldValue(ctx)
  31153. if err != nil {
  31154. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  31155. }
  31156. return oldValue.ChatroomID, nil
  31157. }
  31158. // ResetChatroomID resets all changes to the "chatroom_id" field.
  31159. func (m *WpChatroomMutation) ResetChatroomID() {
  31160. m.chatroom_id = nil
  31161. }
  31162. // SetNickname sets the "nickname" field.
  31163. func (m *WpChatroomMutation) SetNickname(s string) {
  31164. m.nickname = &s
  31165. }
  31166. // Nickname returns the value of the "nickname" field in the mutation.
  31167. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  31168. v := m.nickname
  31169. if v == nil {
  31170. return
  31171. }
  31172. return *v, true
  31173. }
  31174. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  31175. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31177. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  31178. if !m.op.Is(OpUpdateOne) {
  31179. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  31180. }
  31181. if m.id == nil || m.oldValue == nil {
  31182. return v, errors.New("OldNickname requires an ID field in the mutation")
  31183. }
  31184. oldValue, err := m.oldValue(ctx)
  31185. if err != nil {
  31186. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  31187. }
  31188. return oldValue.Nickname, nil
  31189. }
  31190. // ResetNickname resets all changes to the "nickname" field.
  31191. func (m *WpChatroomMutation) ResetNickname() {
  31192. m.nickname = nil
  31193. }
  31194. // SetOwner sets the "owner" field.
  31195. func (m *WpChatroomMutation) SetOwner(s string) {
  31196. m.owner = &s
  31197. }
  31198. // Owner returns the value of the "owner" field in the mutation.
  31199. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  31200. v := m.owner
  31201. if v == nil {
  31202. return
  31203. }
  31204. return *v, true
  31205. }
  31206. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  31207. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31209. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  31210. if !m.op.Is(OpUpdateOne) {
  31211. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  31212. }
  31213. if m.id == nil || m.oldValue == nil {
  31214. return v, errors.New("OldOwner requires an ID field in the mutation")
  31215. }
  31216. oldValue, err := m.oldValue(ctx)
  31217. if err != nil {
  31218. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  31219. }
  31220. return oldValue.Owner, nil
  31221. }
  31222. // ResetOwner resets all changes to the "owner" field.
  31223. func (m *WpChatroomMutation) ResetOwner() {
  31224. m.owner = nil
  31225. }
  31226. // SetAvatar sets the "avatar" field.
  31227. func (m *WpChatroomMutation) SetAvatar(s string) {
  31228. m.avatar = &s
  31229. }
  31230. // Avatar returns the value of the "avatar" field in the mutation.
  31231. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  31232. v := m.avatar
  31233. if v == nil {
  31234. return
  31235. }
  31236. return *v, true
  31237. }
  31238. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  31239. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31241. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  31242. if !m.op.Is(OpUpdateOne) {
  31243. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  31244. }
  31245. if m.id == nil || m.oldValue == nil {
  31246. return v, errors.New("OldAvatar requires an ID field in the mutation")
  31247. }
  31248. oldValue, err := m.oldValue(ctx)
  31249. if err != nil {
  31250. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  31251. }
  31252. return oldValue.Avatar, nil
  31253. }
  31254. // ResetAvatar resets all changes to the "avatar" field.
  31255. func (m *WpChatroomMutation) ResetAvatar() {
  31256. m.avatar = nil
  31257. }
  31258. // SetMemberList sets the "member_list" field.
  31259. func (m *WpChatroomMutation) SetMemberList(s []string) {
  31260. m.member_list = &s
  31261. m.appendmember_list = nil
  31262. }
  31263. // MemberList returns the value of the "member_list" field in the mutation.
  31264. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  31265. v := m.member_list
  31266. if v == nil {
  31267. return
  31268. }
  31269. return *v, true
  31270. }
  31271. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  31272. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31274. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  31275. if !m.op.Is(OpUpdateOne) {
  31276. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  31277. }
  31278. if m.id == nil || m.oldValue == nil {
  31279. return v, errors.New("OldMemberList requires an ID field in the mutation")
  31280. }
  31281. oldValue, err := m.oldValue(ctx)
  31282. if err != nil {
  31283. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  31284. }
  31285. return oldValue.MemberList, nil
  31286. }
  31287. // AppendMemberList adds s to the "member_list" field.
  31288. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  31289. m.appendmember_list = append(m.appendmember_list, s...)
  31290. }
  31291. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  31292. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  31293. if len(m.appendmember_list) == 0 {
  31294. return nil, false
  31295. }
  31296. return m.appendmember_list, true
  31297. }
  31298. // ResetMemberList resets all changes to the "member_list" field.
  31299. func (m *WpChatroomMutation) ResetMemberList() {
  31300. m.member_list = nil
  31301. m.appendmember_list = nil
  31302. }
  31303. // Where appends a list predicates to the WpChatroomMutation builder.
  31304. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  31305. m.predicates = append(m.predicates, ps...)
  31306. }
  31307. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  31308. // users can use type-assertion to append predicates that do not depend on any generated package.
  31309. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  31310. p := make([]predicate.WpChatroom, len(ps))
  31311. for i := range ps {
  31312. p[i] = ps[i]
  31313. }
  31314. m.Where(p...)
  31315. }
  31316. // Op returns the operation name.
  31317. func (m *WpChatroomMutation) Op() Op {
  31318. return m.op
  31319. }
  31320. // SetOp allows setting the mutation operation.
  31321. func (m *WpChatroomMutation) SetOp(op Op) {
  31322. m.op = op
  31323. }
  31324. // Type returns the node type of this mutation (WpChatroom).
  31325. func (m *WpChatroomMutation) Type() string {
  31326. return m.typ
  31327. }
  31328. // Fields returns all fields that were changed during this mutation. Note that in
  31329. // order to get all numeric fields that were incremented/decremented, call
  31330. // AddedFields().
  31331. func (m *WpChatroomMutation) Fields() []string {
  31332. fields := make([]string, 0, 9)
  31333. if m.created_at != nil {
  31334. fields = append(fields, wpchatroom.FieldCreatedAt)
  31335. }
  31336. if m.updated_at != nil {
  31337. fields = append(fields, wpchatroom.FieldUpdatedAt)
  31338. }
  31339. if m.status != nil {
  31340. fields = append(fields, wpchatroom.FieldStatus)
  31341. }
  31342. if m.wx_wxid != nil {
  31343. fields = append(fields, wpchatroom.FieldWxWxid)
  31344. }
  31345. if m.chatroom_id != nil {
  31346. fields = append(fields, wpchatroom.FieldChatroomID)
  31347. }
  31348. if m.nickname != nil {
  31349. fields = append(fields, wpchatroom.FieldNickname)
  31350. }
  31351. if m.owner != nil {
  31352. fields = append(fields, wpchatroom.FieldOwner)
  31353. }
  31354. if m.avatar != nil {
  31355. fields = append(fields, wpchatroom.FieldAvatar)
  31356. }
  31357. if m.member_list != nil {
  31358. fields = append(fields, wpchatroom.FieldMemberList)
  31359. }
  31360. return fields
  31361. }
  31362. // Field returns the value of a field with the given name. The second boolean
  31363. // return value indicates that this field was not set, or was not defined in the
  31364. // schema.
  31365. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  31366. switch name {
  31367. case wpchatroom.FieldCreatedAt:
  31368. return m.CreatedAt()
  31369. case wpchatroom.FieldUpdatedAt:
  31370. return m.UpdatedAt()
  31371. case wpchatroom.FieldStatus:
  31372. return m.Status()
  31373. case wpchatroom.FieldWxWxid:
  31374. return m.WxWxid()
  31375. case wpchatroom.FieldChatroomID:
  31376. return m.ChatroomID()
  31377. case wpchatroom.FieldNickname:
  31378. return m.Nickname()
  31379. case wpchatroom.FieldOwner:
  31380. return m.Owner()
  31381. case wpchatroom.FieldAvatar:
  31382. return m.Avatar()
  31383. case wpchatroom.FieldMemberList:
  31384. return m.MemberList()
  31385. }
  31386. return nil, false
  31387. }
  31388. // OldField returns the old value of the field from the database. An error is
  31389. // returned if the mutation operation is not UpdateOne, or the query to the
  31390. // database failed.
  31391. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31392. switch name {
  31393. case wpchatroom.FieldCreatedAt:
  31394. return m.OldCreatedAt(ctx)
  31395. case wpchatroom.FieldUpdatedAt:
  31396. return m.OldUpdatedAt(ctx)
  31397. case wpchatroom.FieldStatus:
  31398. return m.OldStatus(ctx)
  31399. case wpchatroom.FieldWxWxid:
  31400. return m.OldWxWxid(ctx)
  31401. case wpchatroom.FieldChatroomID:
  31402. return m.OldChatroomID(ctx)
  31403. case wpchatroom.FieldNickname:
  31404. return m.OldNickname(ctx)
  31405. case wpchatroom.FieldOwner:
  31406. return m.OldOwner(ctx)
  31407. case wpchatroom.FieldAvatar:
  31408. return m.OldAvatar(ctx)
  31409. case wpchatroom.FieldMemberList:
  31410. return m.OldMemberList(ctx)
  31411. }
  31412. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  31413. }
  31414. // SetField sets the value of a field with the given name. It returns an error if
  31415. // the field is not defined in the schema, or if the type mismatched the field
  31416. // type.
  31417. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  31418. switch name {
  31419. case wpchatroom.FieldCreatedAt:
  31420. v, ok := value.(time.Time)
  31421. if !ok {
  31422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31423. }
  31424. m.SetCreatedAt(v)
  31425. return nil
  31426. case wpchatroom.FieldUpdatedAt:
  31427. v, ok := value.(time.Time)
  31428. if !ok {
  31429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31430. }
  31431. m.SetUpdatedAt(v)
  31432. return nil
  31433. case wpchatroom.FieldStatus:
  31434. v, ok := value.(uint8)
  31435. if !ok {
  31436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31437. }
  31438. m.SetStatus(v)
  31439. return nil
  31440. case wpchatroom.FieldWxWxid:
  31441. v, ok := value.(string)
  31442. if !ok {
  31443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31444. }
  31445. m.SetWxWxid(v)
  31446. return nil
  31447. case wpchatroom.FieldChatroomID:
  31448. v, ok := value.(string)
  31449. if !ok {
  31450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31451. }
  31452. m.SetChatroomID(v)
  31453. return nil
  31454. case wpchatroom.FieldNickname:
  31455. v, ok := value.(string)
  31456. if !ok {
  31457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31458. }
  31459. m.SetNickname(v)
  31460. return nil
  31461. case wpchatroom.FieldOwner:
  31462. v, ok := value.(string)
  31463. if !ok {
  31464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31465. }
  31466. m.SetOwner(v)
  31467. return nil
  31468. case wpchatroom.FieldAvatar:
  31469. v, ok := value.(string)
  31470. if !ok {
  31471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31472. }
  31473. m.SetAvatar(v)
  31474. return nil
  31475. case wpchatroom.FieldMemberList:
  31476. v, ok := value.([]string)
  31477. if !ok {
  31478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31479. }
  31480. m.SetMemberList(v)
  31481. return nil
  31482. }
  31483. return fmt.Errorf("unknown WpChatroom field %s", name)
  31484. }
  31485. // AddedFields returns all numeric fields that were incremented/decremented during
  31486. // this mutation.
  31487. func (m *WpChatroomMutation) AddedFields() []string {
  31488. var fields []string
  31489. if m.addstatus != nil {
  31490. fields = append(fields, wpchatroom.FieldStatus)
  31491. }
  31492. return fields
  31493. }
  31494. // AddedField returns the numeric value that was incremented/decremented on a field
  31495. // with the given name. The second boolean return value indicates that this field
  31496. // was not set, or was not defined in the schema.
  31497. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  31498. switch name {
  31499. case wpchatroom.FieldStatus:
  31500. return m.AddedStatus()
  31501. }
  31502. return nil, false
  31503. }
  31504. // AddField adds the value to the field with the given name. It returns an error if
  31505. // the field is not defined in the schema, or if the type mismatched the field
  31506. // type.
  31507. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  31508. switch name {
  31509. case wpchatroom.FieldStatus:
  31510. v, ok := value.(int8)
  31511. if !ok {
  31512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31513. }
  31514. m.AddStatus(v)
  31515. return nil
  31516. }
  31517. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  31518. }
  31519. // ClearedFields returns all nullable fields that were cleared during this
  31520. // mutation.
  31521. func (m *WpChatroomMutation) ClearedFields() []string {
  31522. var fields []string
  31523. if m.FieldCleared(wpchatroom.FieldStatus) {
  31524. fields = append(fields, wpchatroom.FieldStatus)
  31525. }
  31526. return fields
  31527. }
  31528. // FieldCleared returns a boolean indicating if a field with the given name was
  31529. // cleared in this mutation.
  31530. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  31531. _, ok := m.clearedFields[name]
  31532. return ok
  31533. }
  31534. // ClearField clears the value of the field with the given name. It returns an
  31535. // error if the field is not defined in the schema.
  31536. func (m *WpChatroomMutation) ClearField(name string) error {
  31537. switch name {
  31538. case wpchatroom.FieldStatus:
  31539. m.ClearStatus()
  31540. return nil
  31541. }
  31542. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  31543. }
  31544. // ResetField resets all changes in the mutation for the field with the given name.
  31545. // It returns an error if the field is not defined in the schema.
  31546. func (m *WpChatroomMutation) ResetField(name string) error {
  31547. switch name {
  31548. case wpchatroom.FieldCreatedAt:
  31549. m.ResetCreatedAt()
  31550. return nil
  31551. case wpchatroom.FieldUpdatedAt:
  31552. m.ResetUpdatedAt()
  31553. return nil
  31554. case wpchatroom.FieldStatus:
  31555. m.ResetStatus()
  31556. return nil
  31557. case wpchatroom.FieldWxWxid:
  31558. m.ResetWxWxid()
  31559. return nil
  31560. case wpchatroom.FieldChatroomID:
  31561. m.ResetChatroomID()
  31562. return nil
  31563. case wpchatroom.FieldNickname:
  31564. m.ResetNickname()
  31565. return nil
  31566. case wpchatroom.FieldOwner:
  31567. m.ResetOwner()
  31568. return nil
  31569. case wpchatroom.FieldAvatar:
  31570. m.ResetAvatar()
  31571. return nil
  31572. case wpchatroom.FieldMemberList:
  31573. m.ResetMemberList()
  31574. return nil
  31575. }
  31576. return fmt.Errorf("unknown WpChatroom field %s", name)
  31577. }
  31578. // AddedEdges returns all edge names that were set/added in this mutation.
  31579. func (m *WpChatroomMutation) AddedEdges() []string {
  31580. edges := make([]string, 0, 0)
  31581. return edges
  31582. }
  31583. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31584. // name in this mutation.
  31585. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  31586. return nil
  31587. }
  31588. // RemovedEdges returns all edge names that were removed in this mutation.
  31589. func (m *WpChatroomMutation) RemovedEdges() []string {
  31590. edges := make([]string, 0, 0)
  31591. return edges
  31592. }
  31593. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31594. // the given name in this mutation.
  31595. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  31596. return nil
  31597. }
  31598. // ClearedEdges returns all edge names that were cleared in this mutation.
  31599. func (m *WpChatroomMutation) ClearedEdges() []string {
  31600. edges := make([]string, 0, 0)
  31601. return edges
  31602. }
  31603. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31604. // was cleared in this mutation.
  31605. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  31606. return false
  31607. }
  31608. // ClearEdge clears the value of the edge with the given name. It returns an error
  31609. // if that edge is not defined in the schema.
  31610. func (m *WpChatroomMutation) ClearEdge(name string) error {
  31611. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  31612. }
  31613. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31614. // It returns an error if the edge is not defined in the schema.
  31615. func (m *WpChatroomMutation) ResetEdge(name string) error {
  31616. return fmt.Errorf("unknown WpChatroom edge %s", name)
  31617. }
  31618. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  31619. type WpChatroomMemberMutation struct {
  31620. config
  31621. op Op
  31622. typ string
  31623. id *uint64
  31624. created_at *time.Time
  31625. updated_at *time.Time
  31626. status *uint8
  31627. addstatus *int8
  31628. wx_wxid *string
  31629. wxid *string
  31630. nickname *string
  31631. avatar *string
  31632. clearedFields map[string]struct{}
  31633. done bool
  31634. oldValue func(context.Context) (*WpChatroomMember, error)
  31635. predicates []predicate.WpChatroomMember
  31636. }
  31637. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  31638. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  31639. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  31640. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  31641. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  31642. m := &WpChatroomMemberMutation{
  31643. config: c,
  31644. op: op,
  31645. typ: TypeWpChatroomMember,
  31646. clearedFields: make(map[string]struct{}),
  31647. }
  31648. for _, opt := range opts {
  31649. opt(m)
  31650. }
  31651. return m
  31652. }
  31653. // withWpChatroomMemberID sets the ID field of the mutation.
  31654. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  31655. return func(m *WpChatroomMemberMutation) {
  31656. var (
  31657. err error
  31658. once sync.Once
  31659. value *WpChatroomMember
  31660. )
  31661. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  31662. once.Do(func() {
  31663. if m.done {
  31664. err = errors.New("querying old values post mutation is not allowed")
  31665. } else {
  31666. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  31667. }
  31668. })
  31669. return value, err
  31670. }
  31671. m.id = &id
  31672. }
  31673. }
  31674. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  31675. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  31676. return func(m *WpChatroomMemberMutation) {
  31677. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  31678. return node, nil
  31679. }
  31680. m.id = &node.ID
  31681. }
  31682. }
  31683. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31684. // executed in a transaction (ent.Tx), a transactional client is returned.
  31685. func (m WpChatroomMemberMutation) Client() *Client {
  31686. client := &Client{config: m.config}
  31687. client.init()
  31688. return client
  31689. }
  31690. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31691. // it returns an error otherwise.
  31692. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  31693. if _, ok := m.driver.(*txDriver); !ok {
  31694. return nil, errors.New("ent: mutation is not running in a transaction")
  31695. }
  31696. tx := &Tx{config: m.config}
  31697. tx.init()
  31698. return tx, nil
  31699. }
  31700. // SetID sets the value of the id field. Note that this
  31701. // operation is only accepted on creation of WpChatroomMember entities.
  31702. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  31703. m.id = &id
  31704. }
  31705. // ID returns the ID value in the mutation. Note that the ID is only available
  31706. // if it was provided to the builder or after it was returned from the database.
  31707. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  31708. if m.id == nil {
  31709. return
  31710. }
  31711. return *m.id, true
  31712. }
  31713. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31714. // That means, if the mutation is applied within a transaction with an isolation level such
  31715. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31716. // or updated by the mutation.
  31717. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  31718. switch {
  31719. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31720. id, exists := m.ID()
  31721. if exists {
  31722. return []uint64{id}, nil
  31723. }
  31724. fallthrough
  31725. case m.op.Is(OpUpdate | OpDelete):
  31726. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  31727. default:
  31728. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31729. }
  31730. }
  31731. // SetCreatedAt sets the "created_at" field.
  31732. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  31733. m.created_at = &t
  31734. }
  31735. // CreatedAt returns the value of the "created_at" field in the mutation.
  31736. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  31737. v := m.created_at
  31738. if v == nil {
  31739. return
  31740. }
  31741. return *v, true
  31742. }
  31743. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  31744. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31746. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31747. if !m.op.Is(OpUpdateOne) {
  31748. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31749. }
  31750. if m.id == nil || m.oldValue == nil {
  31751. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31752. }
  31753. oldValue, err := m.oldValue(ctx)
  31754. if err != nil {
  31755. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31756. }
  31757. return oldValue.CreatedAt, nil
  31758. }
  31759. // ResetCreatedAt resets all changes to the "created_at" field.
  31760. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  31761. m.created_at = nil
  31762. }
  31763. // SetUpdatedAt sets the "updated_at" field.
  31764. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  31765. m.updated_at = &t
  31766. }
  31767. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31768. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  31769. v := m.updated_at
  31770. if v == nil {
  31771. return
  31772. }
  31773. return *v, true
  31774. }
  31775. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  31776. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31778. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31779. if !m.op.Is(OpUpdateOne) {
  31780. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31781. }
  31782. if m.id == nil || m.oldValue == nil {
  31783. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31784. }
  31785. oldValue, err := m.oldValue(ctx)
  31786. if err != nil {
  31787. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31788. }
  31789. return oldValue.UpdatedAt, nil
  31790. }
  31791. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31792. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  31793. m.updated_at = nil
  31794. }
  31795. // SetStatus sets the "status" field.
  31796. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  31797. m.status = &u
  31798. m.addstatus = nil
  31799. }
  31800. // Status returns the value of the "status" field in the mutation.
  31801. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  31802. v := m.status
  31803. if v == nil {
  31804. return
  31805. }
  31806. return *v, true
  31807. }
  31808. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  31809. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31811. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31812. if !m.op.Is(OpUpdateOne) {
  31813. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31814. }
  31815. if m.id == nil || m.oldValue == nil {
  31816. return v, errors.New("OldStatus requires an ID field in the mutation")
  31817. }
  31818. oldValue, err := m.oldValue(ctx)
  31819. if err != nil {
  31820. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31821. }
  31822. return oldValue.Status, nil
  31823. }
  31824. // AddStatus adds u to the "status" field.
  31825. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  31826. if m.addstatus != nil {
  31827. *m.addstatus += u
  31828. } else {
  31829. m.addstatus = &u
  31830. }
  31831. }
  31832. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31833. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  31834. v := m.addstatus
  31835. if v == nil {
  31836. return
  31837. }
  31838. return *v, true
  31839. }
  31840. // ClearStatus clears the value of the "status" field.
  31841. func (m *WpChatroomMemberMutation) ClearStatus() {
  31842. m.status = nil
  31843. m.addstatus = nil
  31844. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  31845. }
  31846. // StatusCleared returns if the "status" field was cleared in this mutation.
  31847. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  31848. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  31849. return ok
  31850. }
  31851. // ResetStatus resets all changes to the "status" field.
  31852. func (m *WpChatroomMemberMutation) ResetStatus() {
  31853. m.status = nil
  31854. m.addstatus = nil
  31855. delete(m.clearedFields, wpchatroommember.FieldStatus)
  31856. }
  31857. // SetWxWxid sets the "wx_wxid" field.
  31858. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  31859. m.wx_wxid = &s
  31860. }
  31861. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  31862. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  31863. v := m.wx_wxid
  31864. if v == nil {
  31865. return
  31866. }
  31867. return *v, true
  31868. }
  31869. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  31870. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31872. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  31873. if !m.op.Is(OpUpdateOne) {
  31874. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  31875. }
  31876. if m.id == nil || m.oldValue == nil {
  31877. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  31878. }
  31879. oldValue, err := m.oldValue(ctx)
  31880. if err != nil {
  31881. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  31882. }
  31883. return oldValue.WxWxid, nil
  31884. }
  31885. // ResetWxWxid resets all changes to the "wx_wxid" field.
  31886. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  31887. m.wx_wxid = nil
  31888. }
  31889. // SetWxid sets the "wxid" field.
  31890. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  31891. m.wxid = &s
  31892. }
  31893. // Wxid returns the value of the "wxid" field in the mutation.
  31894. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  31895. v := m.wxid
  31896. if v == nil {
  31897. return
  31898. }
  31899. return *v, true
  31900. }
  31901. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  31902. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31904. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  31905. if !m.op.Is(OpUpdateOne) {
  31906. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  31907. }
  31908. if m.id == nil || m.oldValue == nil {
  31909. return v, errors.New("OldWxid requires an ID field in the mutation")
  31910. }
  31911. oldValue, err := m.oldValue(ctx)
  31912. if err != nil {
  31913. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  31914. }
  31915. return oldValue.Wxid, nil
  31916. }
  31917. // ResetWxid resets all changes to the "wxid" field.
  31918. func (m *WpChatroomMemberMutation) ResetWxid() {
  31919. m.wxid = nil
  31920. }
  31921. // SetNickname sets the "nickname" field.
  31922. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  31923. m.nickname = &s
  31924. }
  31925. // Nickname returns the value of the "nickname" field in the mutation.
  31926. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  31927. v := m.nickname
  31928. if v == nil {
  31929. return
  31930. }
  31931. return *v, true
  31932. }
  31933. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  31934. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31936. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  31937. if !m.op.Is(OpUpdateOne) {
  31938. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  31939. }
  31940. if m.id == nil || m.oldValue == nil {
  31941. return v, errors.New("OldNickname requires an ID field in the mutation")
  31942. }
  31943. oldValue, err := m.oldValue(ctx)
  31944. if err != nil {
  31945. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  31946. }
  31947. return oldValue.Nickname, nil
  31948. }
  31949. // ResetNickname resets all changes to the "nickname" field.
  31950. func (m *WpChatroomMemberMutation) ResetNickname() {
  31951. m.nickname = nil
  31952. }
  31953. // SetAvatar sets the "avatar" field.
  31954. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  31955. m.avatar = &s
  31956. }
  31957. // Avatar returns the value of the "avatar" field in the mutation.
  31958. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  31959. v := m.avatar
  31960. if v == nil {
  31961. return
  31962. }
  31963. return *v, true
  31964. }
  31965. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  31966. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31968. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  31969. if !m.op.Is(OpUpdateOne) {
  31970. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  31971. }
  31972. if m.id == nil || m.oldValue == nil {
  31973. return v, errors.New("OldAvatar requires an ID field in the mutation")
  31974. }
  31975. oldValue, err := m.oldValue(ctx)
  31976. if err != nil {
  31977. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  31978. }
  31979. return oldValue.Avatar, nil
  31980. }
  31981. // ResetAvatar resets all changes to the "avatar" field.
  31982. func (m *WpChatroomMemberMutation) ResetAvatar() {
  31983. m.avatar = nil
  31984. }
  31985. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  31986. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  31987. m.predicates = append(m.predicates, ps...)
  31988. }
  31989. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  31990. // users can use type-assertion to append predicates that do not depend on any generated package.
  31991. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  31992. p := make([]predicate.WpChatroomMember, len(ps))
  31993. for i := range ps {
  31994. p[i] = ps[i]
  31995. }
  31996. m.Where(p...)
  31997. }
  31998. // Op returns the operation name.
  31999. func (m *WpChatroomMemberMutation) Op() Op {
  32000. return m.op
  32001. }
  32002. // SetOp allows setting the mutation operation.
  32003. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  32004. m.op = op
  32005. }
  32006. // Type returns the node type of this mutation (WpChatroomMember).
  32007. func (m *WpChatroomMemberMutation) Type() string {
  32008. return m.typ
  32009. }
  32010. // Fields returns all fields that were changed during this mutation. Note that in
  32011. // order to get all numeric fields that were incremented/decremented, call
  32012. // AddedFields().
  32013. func (m *WpChatroomMemberMutation) Fields() []string {
  32014. fields := make([]string, 0, 7)
  32015. if m.created_at != nil {
  32016. fields = append(fields, wpchatroommember.FieldCreatedAt)
  32017. }
  32018. if m.updated_at != nil {
  32019. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  32020. }
  32021. if m.status != nil {
  32022. fields = append(fields, wpchatroommember.FieldStatus)
  32023. }
  32024. if m.wx_wxid != nil {
  32025. fields = append(fields, wpchatroommember.FieldWxWxid)
  32026. }
  32027. if m.wxid != nil {
  32028. fields = append(fields, wpchatroommember.FieldWxid)
  32029. }
  32030. if m.nickname != nil {
  32031. fields = append(fields, wpchatroommember.FieldNickname)
  32032. }
  32033. if m.avatar != nil {
  32034. fields = append(fields, wpchatroommember.FieldAvatar)
  32035. }
  32036. return fields
  32037. }
  32038. // Field returns the value of a field with the given name. The second boolean
  32039. // return value indicates that this field was not set, or was not defined in the
  32040. // schema.
  32041. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  32042. switch name {
  32043. case wpchatroommember.FieldCreatedAt:
  32044. return m.CreatedAt()
  32045. case wpchatroommember.FieldUpdatedAt:
  32046. return m.UpdatedAt()
  32047. case wpchatroommember.FieldStatus:
  32048. return m.Status()
  32049. case wpchatroommember.FieldWxWxid:
  32050. return m.WxWxid()
  32051. case wpchatroommember.FieldWxid:
  32052. return m.Wxid()
  32053. case wpchatroommember.FieldNickname:
  32054. return m.Nickname()
  32055. case wpchatroommember.FieldAvatar:
  32056. return m.Avatar()
  32057. }
  32058. return nil, false
  32059. }
  32060. // OldField returns the old value of the field from the database. An error is
  32061. // returned if the mutation operation is not UpdateOne, or the query to the
  32062. // database failed.
  32063. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32064. switch name {
  32065. case wpchatroommember.FieldCreatedAt:
  32066. return m.OldCreatedAt(ctx)
  32067. case wpchatroommember.FieldUpdatedAt:
  32068. return m.OldUpdatedAt(ctx)
  32069. case wpchatroommember.FieldStatus:
  32070. return m.OldStatus(ctx)
  32071. case wpchatroommember.FieldWxWxid:
  32072. return m.OldWxWxid(ctx)
  32073. case wpchatroommember.FieldWxid:
  32074. return m.OldWxid(ctx)
  32075. case wpchatroommember.FieldNickname:
  32076. return m.OldNickname(ctx)
  32077. case wpchatroommember.FieldAvatar:
  32078. return m.OldAvatar(ctx)
  32079. }
  32080. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  32081. }
  32082. // SetField sets the value of a field with the given name. It returns an error if
  32083. // the field is not defined in the schema, or if the type mismatched the field
  32084. // type.
  32085. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  32086. switch name {
  32087. case wpchatroommember.FieldCreatedAt:
  32088. v, ok := value.(time.Time)
  32089. if !ok {
  32090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32091. }
  32092. m.SetCreatedAt(v)
  32093. return nil
  32094. case wpchatroommember.FieldUpdatedAt:
  32095. v, ok := value.(time.Time)
  32096. if !ok {
  32097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32098. }
  32099. m.SetUpdatedAt(v)
  32100. return nil
  32101. case wpchatroommember.FieldStatus:
  32102. v, ok := value.(uint8)
  32103. if !ok {
  32104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32105. }
  32106. m.SetStatus(v)
  32107. return nil
  32108. case wpchatroommember.FieldWxWxid:
  32109. v, ok := value.(string)
  32110. if !ok {
  32111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32112. }
  32113. m.SetWxWxid(v)
  32114. return nil
  32115. case wpchatroommember.FieldWxid:
  32116. v, ok := value.(string)
  32117. if !ok {
  32118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32119. }
  32120. m.SetWxid(v)
  32121. return nil
  32122. case wpchatroommember.FieldNickname:
  32123. v, ok := value.(string)
  32124. if !ok {
  32125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32126. }
  32127. m.SetNickname(v)
  32128. return nil
  32129. case wpchatroommember.FieldAvatar:
  32130. v, ok := value.(string)
  32131. if !ok {
  32132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32133. }
  32134. m.SetAvatar(v)
  32135. return nil
  32136. }
  32137. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  32138. }
  32139. // AddedFields returns all numeric fields that were incremented/decremented during
  32140. // this mutation.
  32141. func (m *WpChatroomMemberMutation) AddedFields() []string {
  32142. var fields []string
  32143. if m.addstatus != nil {
  32144. fields = append(fields, wpchatroommember.FieldStatus)
  32145. }
  32146. return fields
  32147. }
  32148. // AddedField returns the numeric value that was incremented/decremented on a field
  32149. // with the given name. The second boolean return value indicates that this field
  32150. // was not set, or was not defined in the schema.
  32151. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  32152. switch name {
  32153. case wpchatroommember.FieldStatus:
  32154. return m.AddedStatus()
  32155. }
  32156. return nil, false
  32157. }
  32158. // AddField adds the value to the field with the given name. It returns an error if
  32159. // the field is not defined in the schema, or if the type mismatched the field
  32160. // type.
  32161. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  32162. switch name {
  32163. case wpchatroommember.FieldStatus:
  32164. v, ok := value.(int8)
  32165. if !ok {
  32166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32167. }
  32168. m.AddStatus(v)
  32169. return nil
  32170. }
  32171. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  32172. }
  32173. // ClearedFields returns all nullable fields that were cleared during this
  32174. // mutation.
  32175. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  32176. var fields []string
  32177. if m.FieldCleared(wpchatroommember.FieldStatus) {
  32178. fields = append(fields, wpchatroommember.FieldStatus)
  32179. }
  32180. return fields
  32181. }
  32182. // FieldCleared returns a boolean indicating if a field with the given name was
  32183. // cleared in this mutation.
  32184. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  32185. _, ok := m.clearedFields[name]
  32186. return ok
  32187. }
  32188. // ClearField clears the value of the field with the given name. It returns an
  32189. // error if the field is not defined in the schema.
  32190. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  32191. switch name {
  32192. case wpchatroommember.FieldStatus:
  32193. m.ClearStatus()
  32194. return nil
  32195. }
  32196. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  32197. }
  32198. // ResetField resets all changes in the mutation for the field with the given name.
  32199. // It returns an error if the field is not defined in the schema.
  32200. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  32201. switch name {
  32202. case wpchatroommember.FieldCreatedAt:
  32203. m.ResetCreatedAt()
  32204. return nil
  32205. case wpchatroommember.FieldUpdatedAt:
  32206. m.ResetUpdatedAt()
  32207. return nil
  32208. case wpchatroommember.FieldStatus:
  32209. m.ResetStatus()
  32210. return nil
  32211. case wpchatroommember.FieldWxWxid:
  32212. m.ResetWxWxid()
  32213. return nil
  32214. case wpchatroommember.FieldWxid:
  32215. m.ResetWxid()
  32216. return nil
  32217. case wpchatroommember.FieldNickname:
  32218. m.ResetNickname()
  32219. return nil
  32220. case wpchatroommember.FieldAvatar:
  32221. m.ResetAvatar()
  32222. return nil
  32223. }
  32224. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  32225. }
  32226. // AddedEdges returns all edge names that were set/added in this mutation.
  32227. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  32228. edges := make([]string, 0, 0)
  32229. return edges
  32230. }
  32231. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32232. // name in this mutation.
  32233. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  32234. return nil
  32235. }
  32236. // RemovedEdges returns all edge names that were removed in this mutation.
  32237. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  32238. edges := make([]string, 0, 0)
  32239. return edges
  32240. }
  32241. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32242. // the given name in this mutation.
  32243. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  32244. return nil
  32245. }
  32246. // ClearedEdges returns all edge names that were cleared in this mutation.
  32247. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  32248. edges := make([]string, 0, 0)
  32249. return edges
  32250. }
  32251. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32252. // was cleared in this mutation.
  32253. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  32254. return false
  32255. }
  32256. // ClearEdge clears the value of the edge with the given name. It returns an error
  32257. // if that edge is not defined in the schema.
  32258. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  32259. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  32260. }
  32261. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32262. // It returns an error if the edge is not defined in the schema.
  32263. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  32264. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  32265. }
  32266. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  32267. type WxMutation struct {
  32268. config
  32269. op Op
  32270. typ string
  32271. id *uint64
  32272. created_at *time.Time
  32273. updated_at *time.Time
  32274. status *uint8
  32275. addstatus *int8
  32276. deleted_at *time.Time
  32277. port *string
  32278. process_id *string
  32279. callback *string
  32280. wxid *string
  32281. account *string
  32282. nickname *string
  32283. tel *string
  32284. head_big *string
  32285. organization_id *uint64
  32286. addorganization_id *int64
  32287. api_base *string
  32288. api_key *string
  32289. allow_list *[]string
  32290. appendallow_list []string
  32291. group_allow_list *[]string
  32292. appendgroup_allow_list []string
  32293. block_list *[]string
  32294. appendblock_list []string
  32295. group_block_list *[]string
  32296. appendgroup_block_list []string
  32297. clearedFields map[string]struct{}
  32298. server *uint64
  32299. clearedserver bool
  32300. agent *uint64
  32301. clearedagent bool
  32302. done bool
  32303. oldValue func(context.Context) (*Wx, error)
  32304. predicates []predicate.Wx
  32305. }
  32306. var _ ent.Mutation = (*WxMutation)(nil)
  32307. // wxOption allows management of the mutation configuration using functional options.
  32308. type wxOption func(*WxMutation)
  32309. // newWxMutation creates new mutation for the Wx entity.
  32310. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  32311. m := &WxMutation{
  32312. config: c,
  32313. op: op,
  32314. typ: TypeWx,
  32315. clearedFields: make(map[string]struct{}),
  32316. }
  32317. for _, opt := range opts {
  32318. opt(m)
  32319. }
  32320. return m
  32321. }
  32322. // withWxID sets the ID field of the mutation.
  32323. func withWxID(id uint64) wxOption {
  32324. return func(m *WxMutation) {
  32325. var (
  32326. err error
  32327. once sync.Once
  32328. value *Wx
  32329. )
  32330. m.oldValue = func(ctx context.Context) (*Wx, error) {
  32331. once.Do(func() {
  32332. if m.done {
  32333. err = errors.New("querying old values post mutation is not allowed")
  32334. } else {
  32335. value, err = m.Client().Wx.Get(ctx, id)
  32336. }
  32337. })
  32338. return value, err
  32339. }
  32340. m.id = &id
  32341. }
  32342. }
  32343. // withWx sets the old Wx of the mutation.
  32344. func withWx(node *Wx) wxOption {
  32345. return func(m *WxMutation) {
  32346. m.oldValue = func(context.Context) (*Wx, error) {
  32347. return node, nil
  32348. }
  32349. m.id = &node.ID
  32350. }
  32351. }
  32352. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32353. // executed in a transaction (ent.Tx), a transactional client is returned.
  32354. func (m WxMutation) Client() *Client {
  32355. client := &Client{config: m.config}
  32356. client.init()
  32357. return client
  32358. }
  32359. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32360. // it returns an error otherwise.
  32361. func (m WxMutation) Tx() (*Tx, error) {
  32362. if _, ok := m.driver.(*txDriver); !ok {
  32363. return nil, errors.New("ent: mutation is not running in a transaction")
  32364. }
  32365. tx := &Tx{config: m.config}
  32366. tx.init()
  32367. return tx, nil
  32368. }
  32369. // SetID sets the value of the id field. Note that this
  32370. // operation is only accepted on creation of Wx entities.
  32371. func (m *WxMutation) SetID(id uint64) {
  32372. m.id = &id
  32373. }
  32374. // ID returns the ID value in the mutation. Note that the ID is only available
  32375. // if it was provided to the builder or after it was returned from the database.
  32376. func (m *WxMutation) ID() (id uint64, exists bool) {
  32377. if m.id == nil {
  32378. return
  32379. }
  32380. return *m.id, true
  32381. }
  32382. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32383. // That means, if the mutation is applied within a transaction with an isolation level such
  32384. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32385. // or updated by the mutation.
  32386. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  32387. switch {
  32388. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32389. id, exists := m.ID()
  32390. if exists {
  32391. return []uint64{id}, nil
  32392. }
  32393. fallthrough
  32394. case m.op.Is(OpUpdate | OpDelete):
  32395. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  32396. default:
  32397. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32398. }
  32399. }
  32400. // SetCreatedAt sets the "created_at" field.
  32401. func (m *WxMutation) SetCreatedAt(t time.Time) {
  32402. m.created_at = &t
  32403. }
  32404. // CreatedAt returns the value of the "created_at" field in the mutation.
  32405. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  32406. v := m.created_at
  32407. if v == nil {
  32408. return
  32409. }
  32410. return *v, true
  32411. }
  32412. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  32413. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32415. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32416. if !m.op.Is(OpUpdateOne) {
  32417. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32418. }
  32419. if m.id == nil || m.oldValue == nil {
  32420. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32421. }
  32422. oldValue, err := m.oldValue(ctx)
  32423. if err != nil {
  32424. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32425. }
  32426. return oldValue.CreatedAt, nil
  32427. }
  32428. // ResetCreatedAt resets all changes to the "created_at" field.
  32429. func (m *WxMutation) ResetCreatedAt() {
  32430. m.created_at = nil
  32431. }
  32432. // SetUpdatedAt sets the "updated_at" field.
  32433. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  32434. m.updated_at = &t
  32435. }
  32436. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32437. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  32438. v := m.updated_at
  32439. if v == nil {
  32440. return
  32441. }
  32442. return *v, true
  32443. }
  32444. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  32445. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32447. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32448. if !m.op.Is(OpUpdateOne) {
  32449. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32450. }
  32451. if m.id == nil || m.oldValue == nil {
  32452. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32453. }
  32454. oldValue, err := m.oldValue(ctx)
  32455. if err != nil {
  32456. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32457. }
  32458. return oldValue.UpdatedAt, nil
  32459. }
  32460. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32461. func (m *WxMutation) ResetUpdatedAt() {
  32462. m.updated_at = nil
  32463. }
  32464. // SetStatus sets the "status" field.
  32465. func (m *WxMutation) SetStatus(u uint8) {
  32466. m.status = &u
  32467. m.addstatus = nil
  32468. }
  32469. // Status returns the value of the "status" field in the mutation.
  32470. func (m *WxMutation) Status() (r uint8, exists bool) {
  32471. v := m.status
  32472. if v == nil {
  32473. return
  32474. }
  32475. return *v, true
  32476. }
  32477. // OldStatus returns the old "status" field's value of the Wx entity.
  32478. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32480. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32481. if !m.op.Is(OpUpdateOne) {
  32482. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32483. }
  32484. if m.id == nil || m.oldValue == nil {
  32485. return v, errors.New("OldStatus requires an ID field in the mutation")
  32486. }
  32487. oldValue, err := m.oldValue(ctx)
  32488. if err != nil {
  32489. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32490. }
  32491. return oldValue.Status, nil
  32492. }
  32493. // AddStatus adds u to the "status" field.
  32494. func (m *WxMutation) AddStatus(u int8) {
  32495. if m.addstatus != nil {
  32496. *m.addstatus += u
  32497. } else {
  32498. m.addstatus = &u
  32499. }
  32500. }
  32501. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32502. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  32503. v := m.addstatus
  32504. if v == nil {
  32505. return
  32506. }
  32507. return *v, true
  32508. }
  32509. // ClearStatus clears the value of the "status" field.
  32510. func (m *WxMutation) ClearStatus() {
  32511. m.status = nil
  32512. m.addstatus = nil
  32513. m.clearedFields[wx.FieldStatus] = struct{}{}
  32514. }
  32515. // StatusCleared returns if the "status" field was cleared in this mutation.
  32516. func (m *WxMutation) StatusCleared() bool {
  32517. _, ok := m.clearedFields[wx.FieldStatus]
  32518. return ok
  32519. }
  32520. // ResetStatus resets all changes to the "status" field.
  32521. func (m *WxMutation) ResetStatus() {
  32522. m.status = nil
  32523. m.addstatus = nil
  32524. delete(m.clearedFields, wx.FieldStatus)
  32525. }
  32526. // SetDeletedAt sets the "deleted_at" field.
  32527. func (m *WxMutation) SetDeletedAt(t time.Time) {
  32528. m.deleted_at = &t
  32529. }
  32530. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32531. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  32532. v := m.deleted_at
  32533. if v == nil {
  32534. return
  32535. }
  32536. return *v, true
  32537. }
  32538. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  32539. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32541. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32542. if !m.op.Is(OpUpdateOne) {
  32543. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32544. }
  32545. if m.id == nil || m.oldValue == nil {
  32546. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32547. }
  32548. oldValue, err := m.oldValue(ctx)
  32549. if err != nil {
  32550. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32551. }
  32552. return oldValue.DeletedAt, nil
  32553. }
  32554. // ClearDeletedAt clears the value of the "deleted_at" field.
  32555. func (m *WxMutation) ClearDeletedAt() {
  32556. m.deleted_at = nil
  32557. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  32558. }
  32559. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32560. func (m *WxMutation) DeletedAtCleared() bool {
  32561. _, ok := m.clearedFields[wx.FieldDeletedAt]
  32562. return ok
  32563. }
  32564. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32565. func (m *WxMutation) ResetDeletedAt() {
  32566. m.deleted_at = nil
  32567. delete(m.clearedFields, wx.FieldDeletedAt)
  32568. }
  32569. // SetServerID sets the "server_id" field.
  32570. func (m *WxMutation) SetServerID(u uint64) {
  32571. m.server = &u
  32572. }
  32573. // ServerID returns the value of the "server_id" field in the mutation.
  32574. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  32575. v := m.server
  32576. if v == nil {
  32577. return
  32578. }
  32579. return *v, true
  32580. }
  32581. // OldServerID returns the old "server_id" field's value of the Wx entity.
  32582. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32584. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  32585. if !m.op.Is(OpUpdateOne) {
  32586. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  32587. }
  32588. if m.id == nil || m.oldValue == nil {
  32589. return v, errors.New("OldServerID requires an ID field in the mutation")
  32590. }
  32591. oldValue, err := m.oldValue(ctx)
  32592. if err != nil {
  32593. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  32594. }
  32595. return oldValue.ServerID, nil
  32596. }
  32597. // ClearServerID clears the value of the "server_id" field.
  32598. func (m *WxMutation) ClearServerID() {
  32599. m.server = nil
  32600. m.clearedFields[wx.FieldServerID] = struct{}{}
  32601. }
  32602. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  32603. func (m *WxMutation) ServerIDCleared() bool {
  32604. _, ok := m.clearedFields[wx.FieldServerID]
  32605. return ok
  32606. }
  32607. // ResetServerID resets all changes to the "server_id" field.
  32608. func (m *WxMutation) ResetServerID() {
  32609. m.server = nil
  32610. delete(m.clearedFields, wx.FieldServerID)
  32611. }
  32612. // SetPort sets the "port" field.
  32613. func (m *WxMutation) SetPort(s string) {
  32614. m.port = &s
  32615. }
  32616. // Port returns the value of the "port" field in the mutation.
  32617. func (m *WxMutation) Port() (r string, exists bool) {
  32618. v := m.port
  32619. if v == nil {
  32620. return
  32621. }
  32622. return *v, true
  32623. }
  32624. // OldPort returns the old "port" field's value of the Wx entity.
  32625. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32627. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  32628. if !m.op.Is(OpUpdateOne) {
  32629. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  32630. }
  32631. if m.id == nil || m.oldValue == nil {
  32632. return v, errors.New("OldPort requires an ID field in the mutation")
  32633. }
  32634. oldValue, err := m.oldValue(ctx)
  32635. if err != nil {
  32636. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  32637. }
  32638. return oldValue.Port, nil
  32639. }
  32640. // ResetPort resets all changes to the "port" field.
  32641. func (m *WxMutation) ResetPort() {
  32642. m.port = nil
  32643. }
  32644. // SetProcessID sets the "process_id" field.
  32645. func (m *WxMutation) SetProcessID(s string) {
  32646. m.process_id = &s
  32647. }
  32648. // ProcessID returns the value of the "process_id" field in the mutation.
  32649. func (m *WxMutation) ProcessID() (r string, exists bool) {
  32650. v := m.process_id
  32651. if v == nil {
  32652. return
  32653. }
  32654. return *v, true
  32655. }
  32656. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  32657. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32659. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  32660. if !m.op.Is(OpUpdateOne) {
  32661. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  32662. }
  32663. if m.id == nil || m.oldValue == nil {
  32664. return v, errors.New("OldProcessID requires an ID field in the mutation")
  32665. }
  32666. oldValue, err := m.oldValue(ctx)
  32667. if err != nil {
  32668. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  32669. }
  32670. return oldValue.ProcessID, nil
  32671. }
  32672. // ResetProcessID resets all changes to the "process_id" field.
  32673. func (m *WxMutation) ResetProcessID() {
  32674. m.process_id = nil
  32675. }
  32676. // SetCallback sets the "callback" field.
  32677. func (m *WxMutation) SetCallback(s string) {
  32678. m.callback = &s
  32679. }
  32680. // Callback returns the value of the "callback" field in the mutation.
  32681. func (m *WxMutation) Callback() (r string, exists bool) {
  32682. v := m.callback
  32683. if v == nil {
  32684. return
  32685. }
  32686. return *v, true
  32687. }
  32688. // OldCallback returns the old "callback" field's value of the Wx entity.
  32689. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32691. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  32692. if !m.op.Is(OpUpdateOne) {
  32693. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  32694. }
  32695. if m.id == nil || m.oldValue == nil {
  32696. return v, errors.New("OldCallback requires an ID field in the mutation")
  32697. }
  32698. oldValue, err := m.oldValue(ctx)
  32699. if err != nil {
  32700. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  32701. }
  32702. return oldValue.Callback, nil
  32703. }
  32704. // ResetCallback resets all changes to the "callback" field.
  32705. func (m *WxMutation) ResetCallback() {
  32706. m.callback = nil
  32707. }
  32708. // SetWxid sets the "wxid" field.
  32709. func (m *WxMutation) SetWxid(s string) {
  32710. m.wxid = &s
  32711. }
  32712. // Wxid returns the value of the "wxid" field in the mutation.
  32713. func (m *WxMutation) Wxid() (r string, exists bool) {
  32714. v := m.wxid
  32715. if v == nil {
  32716. return
  32717. }
  32718. return *v, true
  32719. }
  32720. // OldWxid returns the old "wxid" field's value of the Wx entity.
  32721. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32723. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  32724. if !m.op.Is(OpUpdateOne) {
  32725. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  32726. }
  32727. if m.id == nil || m.oldValue == nil {
  32728. return v, errors.New("OldWxid requires an ID field in the mutation")
  32729. }
  32730. oldValue, err := m.oldValue(ctx)
  32731. if err != nil {
  32732. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  32733. }
  32734. return oldValue.Wxid, nil
  32735. }
  32736. // ResetWxid resets all changes to the "wxid" field.
  32737. func (m *WxMutation) ResetWxid() {
  32738. m.wxid = nil
  32739. }
  32740. // SetAccount sets the "account" field.
  32741. func (m *WxMutation) SetAccount(s string) {
  32742. m.account = &s
  32743. }
  32744. // Account returns the value of the "account" field in the mutation.
  32745. func (m *WxMutation) Account() (r string, exists bool) {
  32746. v := m.account
  32747. if v == nil {
  32748. return
  32749. }
  32750. return *v, true
  32751. }
  32752. // OldAccount returns the old "account" field's value of the Wx entity.
  32753. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32755. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  32756. if !m.op.Is(OpUpdateOne) {
  32757. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  32758. }
  32759. if m.id == nil || m.oldValue == nil {
  32760. return v, errors.New("OldAccount requires an ID field in the mutation")
  32761. }
  32762. oldValue, err := m.oldValue(ctx)
  32763. if err != nil {
  32764. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  32765. }
  32766. return oldValue.Account, nil
  32767. }
  32768. // ResetAccount resets all changes to the "account" field.
  32769. func (m *WxMutation) ResetAccount() {
  32770. m.account = nil
  32771. }
  32772. // SetNickname sets the "nickname" field.
  32773. func (m *WxMutation) SetNickname(s string) {
  32774. m.nickname = &s
  32775. }
  32776. // Nickname returns the value of the "nickname" field in the mutation.
  32777. func (m *WxMutation) Nickname() (r string, exists bool) {
  32778. v := m.nickname
  32779. if v == nil {
  32780. return
  32781. }
  32782. return *v, true
  32783. }
  32784. // OldNickname returns the old "nickname" field's value of the Wx entity.
  32785. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32787. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  32788. if !m.op.Is(OpUpdateOne) {
  32789. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  32790. }
  32791. if m.id == nil || m.oldValue == nil {
  32792. return v, errors.New("OldNickname requires an ID field in the mutation")
  32793. }
  32794. oldValue, err := m.oldValue(ctx)
  32795. if err != nil {
  32796. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  32797. }
  32798. return oldValue.Nickname, nil
  32799. }
  32800. // ResetNickname resets all changes to the "nickname" field.
  32801. func (m *WxMutation) ResetNickname() {
  32802. m.nickname = nil
  32803. }
  32804. // SetTel sets the "tel" field.
  32805. func (m *WxMutation) SetTel(s string) {
  32806. m.tel = &s
  32807. }
  32808. // Tel returns the value of the "tel" field in the mutation.
  32809. func (m *WxMutation) Tel() (r string, exists bool) {
  32810. v := m.tel
  32811. if v == nil {
  32812. return
  32813. }
  32814. return *v, true
  32815. }
  32816. // OldTel returns the old "tel" field's value of the Wx entity.
  32817. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32819. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  32820. if !m.op.Is(OpUpdateOne) {
  32821. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  32822. }
  32823. if m.id == nil || m.oldValue == nil {
  32824. return v, errors.New("OldTel requires an ID field in the mutation")
  32825. }
  32826. oldValue, err := m.oldValue(ctx)
  32827. if err != nil {
  32828. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  32829. }
  32830. return oldValue.Tel, nil
  32831. }
  32832. // ResetTel resets all changes to the "tel" field.
  32833. func (m *WxMutation) ResetTel() {
  32834. m.tel = nil
  32835. }
  32836. // SetHeadBig sets the "head_big" field.
  32837. func (m *WxMutation) SetHeadBig(s string) {
  32838. m.head_big = &s
  32839. }
  32840. // HeadBig returns the value of the "head_big" field in the mutation.
  32841. func (m *WxMutation) HeadBig() (r string, exists bool) {
  32842. v := m.head_big
  32843. if v == nil {
  32844. return
  32845. }
  32846. return *v, true
  32847. }
  32848. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  32849. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32851. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  32852. if !m.op.Is(OpUpdateOne) {
  32853. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  32854. }
  32855. if m.id == nil || m.oldValue == nil {
  32856. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  32857. }
  32858. oldValue, err := m.oldValue(ctx)
  32859. if err != nil {
  32860. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  32861. }
  32862. return oldValue.HeadBig, nil
  32863. }
  32864. // ResetHeadBig resets all changes to the "head_big" field.
  32865. func (m *WxMutation) ResetHeadBig() {
  32866. m.head_big = nil
  32867. }
  32868. // SetOrganizationID sets the "organization_id" field.
  32869. func (m *WxMutation) SetOrganizationID(u uint64) {
  32870. m.organization_id = &u
  32871. m.addorganization_id = nil
  32872. }
  32873. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32874. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  32875. v := m.organization_id
  32876. if v == nil {
  32877. return
  32878. }
  32879. return *v, true
  32880. }
  32881. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  32882. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32884. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32885. if !m.op.Is(OpUpdateOne) {
  32886. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32887. }
  32888. if m.id == nil || m.oldValue == nil {
  32889. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32890. }
  32891. oldValue, err := m.oldValue(ctx)
  32892. if err != nil {
  32893. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32894. }
  32895. return oldValue.OrganizationID, nil
  32896. }
  32897. // AddOrganizationID adds u to the "organization_id" field.
  32898. func (m *WxMutation) AddOrganizationID(u int64) {
  32899. if m.addorganization_id != nil {
  32900. *m.addorganization_id += u
  32901. } else {
  32902. m.addorganization_id = &u
  32903. }
  32904. }
  32905. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32906. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  32907. v := m.addorganization_id
  32908. if v == nil {
  32909. return
  32910. }
  32911. return *v, true
  32912. }
  32913. // ClearOrganizationID clears the value of the "organization_id" field.
  32914. func (m *WxMutation) ClearOrganizationID() {
  32915. m.organization_id = nil
  32916. m.addorganization_id = nil
  32917. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  32918. }
  32919. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32920. func (m *WxMutation) OrganizationIDCleared() bool {
  32921. _, ok := m.clearedFields[wx.FieldOrganizationID]
  32922. return ok
  32923. }
  32924. // ResetOrganizationID resets all changes to the "organization_id" field.
  32925. func (m *WxMutation) ResetOrganizationID() {
  32926. m.organization_id = nil
  32927. m.addorganization_id = nil
  32928. delete(m.clearedFields, wx.FieldOrganizationID)
  32929. }
  32930. // SetAgentID sets the "agent_id" field.
  32931. func (m *WxMutation) SetAgentID(u uint64) {
  32932. m.agent = &u
  32933. }
  32934. // AgentID returns the value of the "agent_id" field in the mutation.
  32935. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  32936. v := m.agent
  32937. if v == nil {
  32938. return
  32939. }
  32940. return *v, true
  32941. }
  32942. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  32943. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32945. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  32946. if !m.op.Is(OpUpdateOne) {
  32947. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  32948. }
  32949. if m.id == nil || m.oldValue == nil {
  32950. return v, errors.New("OldAgentID requires an ID field in the mutation")
  32951. }
  32952. oldValue, err := m.oldValue(ctx)
  32953. if err != nil {
  32954. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  32955. }
  32956. return oldValue.AgentID, nil
  32957. }
  32958. // ResetAgentID resets all changes to the "agent_id" field.
  32959. func (m *WxMutation) ResetAgentID() {
  32960. m.agent = nil
  32961. }
  32962. // SetAPIBase sets the "api_base" field.
  32963. func (m *WxMutation) SetAPIBase(s string) {
  32964. m.api_base = &s
  32965. }
  32966. // APIBase returns the value of the "api_base" field in the mutation.
  32967. func (m *WxMutation) APIBase() (r string, exists bool) {
  32968. v := m.api_base
  32969. if v == nil {
  32970. return
  32971. }
  32972. return *v, true
  32973. }
  32974. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  32975. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32977. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  32978. if !m.op.Is(OpUpdateOne) {
  32979. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  32980. }
  32981. if m.id == nil || m.oldValue == nil {
  32982. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  32983. }
  32984. oldValue, err := m.oldValue(ctx)
  32985. if err != nil {
  32986. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  32987. }
  32988. return oldValue.APIBase, nil
  32989. }
  32990. // ClearAPIBase clears the value of the "api_base" field.
  32991. func (m *WxMutation) ClearAPIBase() {
  32992. m.api_base = nil
  32993. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  32994. }
  32995. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  32996. func (m *WxMutation) APIBaseCleared() bool {
  32997. _, ok := m.clearedFields[wx.FieldAPIBase]
  32998. return ok
  32999. }
  33000. // ResetAPIBase resets all changes to the "api_base" field.
  33001. func (m *WxMutation) ResetAPIBase() {
  33002. m.api_base = nil
  33003. delete(m.clearedFields, wx.FieldAPIBase)
  33004. }
  33005. // SetAPIKey sets the "api_key" field.
  33006. func (m *WxMutation) SetAPIKey(s string) {
  33007. m.api_key = &s
  33008. }
  33009. // APIKey returns the value of the "api_key" field in the mutation.
  33010. func (m *WxMutation) APIKey() (r string, exists bool) {
  33011. v := m.api_key
  33012. if v == nil {
  33013. return
  33014. }
  33015. return *v, true
  33016. }
  33017. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  33018. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33020. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  33021. if !m.op.Is(OpUpdateOne) {
  33022. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  33023. }
  33024. if m.id == nil || m.oldValue == nil {
  33025. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  33026. }
  33027. oldValue, err := m.oldValue(ctx)
  33028. if err != nil {
  33029. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  33030. }
  33031. return oldValue.APIKey, nil
  33032. }
  33033. // ClearAPIKey clears the value of the "api_key" field.
  33034. func (m *WxMutation) ClearAPIKey() {
  33035. m.api_key = nil
  33036. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  33037. }
  33038. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  33039. func (m *WxMutation) APIKeyCleared() bool {
  33040. _, ok := m.clearedFields[wx.FieldAPIKey]
  33041. return ok
  33042. }
  33043. // ResetAPIKey resets all changes to the "api_key" field.
  33044. func (m *WxMutation) ResetAPIKey() {
  33045. m.api_key = nil
  33046. delete(m.clearedFields, wx.FieldAPIKey)
  33047. }
  33048. // SetAllowList sets the "allow_list" field.
  33049. func (m *WxMutation) SetAllowList(s []string) {
  33050. m.allow_list = &s
  33051. m.appendallow_list = nil
  33052. }
  33053. // AllowList returns the value of the "allow_list" field in the mutation.
  33054. func (m *WxMutation) AllowList() (r []string, exists bool) {
  33055. v := m.allow_list
  33056. if v == nil {
  33057. return
  33058. }
  33059. return *v, true
  33060. }
  33061. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  33062. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33064. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  33065. if !m.op.Is(OpUpdateOne) {
  33066. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  33067. }
  33068. if m.id == nil || m.oldValue == nil {
  33069. return v, errors.New("OldAllowList requires an ID field in the mutation")
  33070. }
  33071. oldValue, err := m.oldValue(ctx)
  33072. if err != nil {
  33073. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  33074. }
  33075. return oldValue.AllowList, nil
  33076. }
  33077. // AppendAllowList adds s to the "allow_list" field.
  33078. func (m *WxMutation) AppendAllowList(s []string) {
  33079. m.appendallow_list = append(m.appendallow_list, s...)
  33080. }
  33081. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  33082. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  33083. if len(m.appendallow_list) == 0 {
  33084. return nil, false
  33085. }
  33086. return m.appendallow_list, true
  33087. }
  33088. // ResetAllowList resets all changes to the "allow_list" field.
  33089. func (m *WxMutation) ResetAllowList() {
  33090. m.allow_list = nil
  33091. m.appendallow_list = nil
  33092. }
  33093. // SetGroupAllowList sets the "group_allow_list" field.
  33094. func (m *WxMutation) SetGroupAllowList(s []string) {
  33095. m.group_allow_list = &s
  33096. m.appendgroup_allow_list = nil
  33097. }
  33098. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  33099. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  33100. v := m.group_allow_list
  33101. if v == nil {
  33102. return
  33103. }
  33104. return *v, true
  33105. }
  33106. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  33107. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33109. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  33110. if !m.op.Is(OpUpdateOne) {
  33111. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  33112. }
  33113. if m.id == nil || m.oldValue == nil {
  33114. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  33115. }
  33116. oldValue, err := m.oldValue(ctx)
  33117. if err != nil {
  33118. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  33119. }
  33120. return oldValue.GroupAllowList, nil
  33121. }
  33122. // AppendGroupAllowList adds s to the "group_allow_list" field.
  33123. func (m *WxMutation) AppendGroupAllowList(s []string) {
  33124. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  33125. }
  33126. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  33127. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  33128. if len(m.appendgroup_allow_list) == 0 {
  33129. return nil, false
  33130. }
  33131. return m.appendgroup_allow_list, true
  33132. }
  33133. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  33134. func (m *WxMutation) ResetGroupAllowList() {
  33135. m.group_allow_list = nil
  33136. m.appendgroup_allow_list = nil
  33137. }
  33138. // SetBlockList sets the "block_list" field.
  33139. func (m *WxMutation) SetBlockList(s []string) {
  33140. m.block_list = &s
  33141. m.appendblock_list = nil
  33142. }
  33143. // BlockList returns the value of the "block_list" field in the mutation.
  33144. func (m *WxMutation) BlockList() (r []string, exists bool) {
  33145. v := m.block_list
  33146. if v == nil {
  33147. return
  33148. }
  33149. return *v, true
  33150. }
  33151. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  33152. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33154. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  33155. if !m.op.Is(OpUpdateOne) {
  33156. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  33157. }
  33158. if m.id == nil || m.oldValue == nil {
  33159. return v, errors.New("OldBlockList requires an ID field in the mutation")
  33160. }
  33161. oldValue, err := m.oldValue(ctx)
  33162. if err != nil {
  33163. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  33164. }
  33165. return oldValue.BlockList, nil
  33166. }
  33167. // AppendBlockList adds s to the "block_list" field.
  33168. func (m *WxMutation) AppendBlockList(s []string) {
  33169. m.appendblock_list = append(m.appendblock_list, s...)
  33170. }
  33171. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  33172. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  33173. if len(m.appendblock_list) == 0 {
  33174. return nil, false
  33175. }
  33176. return m.appendblock_list, true
  33177. }
  33178. // ResetBlockList resets all changes to the "block_list" field.
  33179. func (m *WxMutation) ResetBlockList() {
  33180. m.block_list = nil
  33181. m.appendblock_list = nil
  33182. }
  33183. // SetGroupBlockList sets the "group_block_list" field.
  33184. func (m *WxMutation) SetGroupBlockList(s []string) {
  33185. m.group_block_list = &s
  33186. m.appendgroup_block_list = nil
  33187. }
  33188. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  33189. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  33190. v := m.group_block_list
  33191. if v == nil {
  33192. return
  33193. }
  33194. return *v, true
  33195. }
  33196. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  33197. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33199. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  33200. if !m.op.Is(OpUpdateOne) {
  33201. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  33202. }
  33203. if m.id == nil || m.oldValue == nil {
  33204. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  33205. }
  33206. oldValue, err := m.oldValue(ctx)
  33207. if err != nil {
  33208. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  33209. }
  33210. return oldValue.GroupBlockList, nil
  33211. }
  33212. // AppendGroupBlockList adds s to the "group_block_list" field.
  33213. func (m *WxMutation) AppendGroupBlockList(s []string) {
  33214. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  33215. }
  33216. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  33217. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  33218. if len(m.appendgroup_block_list) == 0 {
  33219. return nil, false
  33220. }
  33221. return m.appendgroup_block_list, true
  33222. }
  33223. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  33224. func (m *WxMutation) ResetGroupBlockList() {
  33225. m.group_block_list = nil
  33226. m.appendgroup_block_list = nil
  33227. }
  33228. // ClearServer clears the "server" edge to the Server entity.
  33229. func (m *WxMutation) ClearServer() {
  33230. m.clearedserver = true
  33231. m.clearedFields[wx.FieldServerID] = struct{}{}
  33232. }
  33233. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  33234. func (m *WxMutation) ServerCleared() bool {
  33235. return m.ServerIDCleared() || m.clearedserver
  33236. }
  33237. // ServerIDs returns the "server" edge IDs in the mutation.
  33238. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33239. // ServerID instead. It exists only for internal usage by the builders.
  33240. func (m *WxMutation) ServerIDs() (ids []uint64) {
  33241. if id := m.server; id != nil {
  33242. ids = append(ids, *id)
  33243. }
  33244. return
  33245. }
  33246. // ResetServer resets all changes to the "server" edge.
  33247. func (m *WxMutation) ResetServer() {
  33248. m.server = nil
  33249. m.clearedserver = false
  33250. }
  33251. // ClearAgent clears the "agent" edge to the Agent entity.
  33252. func (m *WxMutation) ClearAgent() {
  33253. m.clearedagent = true
  33254. m.clearedFields[wx.FieldAgentID] = struct{}{}
  33255. }
  33256. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  33257. func (m *WxMutation) AgentCleared() bool {
  33258. return m.clearedagent
  33259. }
  33260. // AgentIDs returns the "agent" edge IDs in the mutation.
  33261. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33262. // AgentID instead. It exists only for internal usage by the builders.
  33263. func (m *WxMutation) AgentIDs() (ids []uint64) {
  33264. if id := m.agent; id != nil {
  33265. ids = append(ids, *id)
  33266. }
  33267. return
  33268. }
  33269. // ResetAgent resets all changes to the "agent" edge.
  33270. func (m *WxMutation) ResetAgent() {
  33271. m.agent = nil
  33272. m.clearedagent = false
  33273. }
  33274. // Where appends a list predicates to the WxMutation builder.
  33275. func (m *WxMutation) Where(ps ...predicate.Wx) {
  33276. m.predicates = append(m.predicates, ps...)
  33277. }
  33278. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  33279. // users can use type-assertion to append predicates that do not depend on any generated package.
  33280. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  33281. p := make([]predicate.Wx, len(ps))
  33282. for i := range ps {
  33283. p[i] = ps[i]
  33284. }
  33285. m.Where(p...)
  33286. }
  33287. // Op returns the operation name.
  33288. func (m *WxMutation) Op() Op {
  33289. return m.op
  33290. }
  33291. // SetOp allows setting the mutation operation.
  33292. func (m *WxMutation) SetOp(op Op) {
  33293. m.op = op
  33294. }
  33295. // Type returns the node type of this mutation (Wx).
  33296. func (m *WxMutation) Type() string {
  33297. return m.typ
  33298. }
  33299. // Fields returns all fields that were changed during this mutation. Note that in
  33300. // order to get all numeric fields that were incremented/decremented, call
  33301. // AddedFields().
  33302. func (m *WxMutation) Fields() []string {
  33303. fields := make([]string, 0, 21)
  33304. if m.created_at != nil {
  33305. fields = append(fields, wx.FieldCreatedAt)
  33306. }
  33307. if m.updated_at != nil {
  33308. fields = append(fields, wx.FieldUpdatedAt)
  33309. }
  33310. if m.status != nil {
  33311. fields = append(fields, wx.FieldStatus)
  33312. }
  33313. if m.deleted_at != nil {
  33314. fields = append(fields, wx.FieldDeletedAt)
  33315. }
  33316. if m.server != nil {
  33317. fields = append(fields, wx.FieldServerID)
  33318. }
  33319. if m.port != nil {
  33320. fields = append(fields, wx.FieldPort)
  33321. }
  33322. if m.process_id != nil {
  33323. fields = append(fields, wx.FieldProcessID)
  33324. }
  33325. if m.callback != nil {
  33326. fields = append(fields, wx.FieldCallback)
  33327. }
  33328. if m.wxid != nil {
  33329. fields = append(fields, wx.FieldWxid)
  33330. }
  33331. if m.account != nil {
  33332. fields = append(fields, wx.FieldAccount)
  33333. }
  33334. if m.nickname != nil {
  33335. fields = append(fields, wx.FieldNickname)
  33336. }
  33337. if m.tel != nil {
  33338. fields = append(fields, wx.FieldTel)
  33339. }
  33340. if m.head_big != nil {
  33341. fields = append(fields, wx.FieldHeadBig)
  33342. }
  33343. if m.organization_id != nil {
  33344. fields = append(fields, wx.FieldOrganizationID)
  33345. }
  33346. if m.agent != nil {
  33347. fields = append(fields, wx.FieldAgentID)
  33348. }
  33349. if m.api_base != nil {
  33350. fields = append(fields, wx.FieldAPIBase)
  33351. }
  33352. if m.api_key != nil {
  33353. fields = append(fields, wx.FieldAPIKey)
  33354. }
  33355. if m.allow_list != nil {
  33356. fields = append(fields, wx.FieldAllowList)
  33357. }
  33358. if m.group_allow_list != nil {
  33359. fields = append(fields, wx.FieldGroupAllowList)
  33360. }
  33361. if m.block_list != nil {
  33362. fields = append(fields, wx.FieldBlockList)
  33363. }
  33364. if m.group_block_list != nil {
  33365. fields = append(fields, wx.FieldGroupBlockList)
  33366. }
  33367. return fields
  33368. }
  33369. // Field returns the value of a field with the given name. The second boolean
  33370. // return value indicates that this field was not set, or was not defined in the
  33371. // schema.
  33372. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  33373. switch name {
  33374. case wx.FieldCreatedAt:
  33375. return m.CreatedAt()
  33376. case wx.FieldUpdatedAt:
  33377. return m.UpdatedAt()
  33378. case wx.FieldStatus:
  33379. return m.Status()
  33380. case wx.FieldDeletedAt:
  33381. return m.DeletedAt()
  33382. case wx.FieldServerID:
  33383. return m.ServerID()
  33384. case wx.FieldPort:
  33385. return m.Port()
  33386. case wx.FieldProcessID:
  33387. return m.ProcessID()
  33388. case wx.FieldCallback:
  33389. return m.Callback()
  33390. case wx.FieldWxid:
  33391. return m.Wxid()
  33392. case wx.FieldAccount:
  33393. return m.Account()
  33394. case wx.FieldNickname:
  33395. return m.Nickname()
  33396. case wx.FieldTel:
  33397. return m.Tel()
  33398. case wx.FieldHeadBig:
  33399. return m.HeadBig()
  33400. case wx.FieldOrganizationID:
  33401. return m.OrganizationID()
  33402. case wx.FieldAgentID:
  33403. return m.AgentID()
  33404. case wx.FieldAPIBase:
  33405. return m.APIBase()
  33406. case wx.FieldAPIKey:
  33407. return m.APIKey()
  33408. case wx.FieldAllowList:
  33409. return m.AllowList()
  33410. case wx.FieldGroupAllowList:
  33411. return m.GroupAllowList()
  33412. case wx.FieldBlockList:
  33413. return m.BlockList()
  33414. case wx.FieldGroupBlockList:
  33415. return m.GroupBlockList()
  33416. }
  33417. return nil, false
  33418. }
  33419. // OldField returns the old value of the field from the database. An error is
  33420. // returned if the mutation operation is not UpdateOne, or the query to the
  33421. // database failed.
  33422. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33423. switch name {
  33424. case wx.FieldCreatedAt:
  33425. return m.OldCreatedAt(ctx)
  33426. case wx.FieldUpdatedAt:
  33427. return m.OldUpdatedAt(ctx)
  33428. case wx.FieldStatus:
  33429. return m.OldStatus(ctx)
  33430. case wx.FieldDeletedAt:
  33431. return m.OldDeletedAt(ctx)
  33432. case wx.FieldServerID:
  33433. return m.OldServerID(ctx)
  33434. case wx.FieldPort:
  33435. return m.OldPort(ctx)
  33436. case wx.FieldProcessID:
  33437. return m.OldProcessID(ctx)
  33438. case wx.FieldCallback:
  33439. return m.OldCallback(ctx)
  33440. case wx.FieldWxid:
  33441. return m.OldWxid(ctx)
  33442. case wx.FieldAccount:
  33443. return m.OldAccount(ctx)
  33444. case wx.FieldNickname:
  33445. return m.OldNickname(ctx)
  33446. case wx.FieldTel:
  33447. return m.OldTel(ctx)
  33448. case wx.FieldHeadBig:
  33449. return m.OldHeadBig(ctx)
  33450. case wx.FieldOrganizationID:
  33451. return m.OldOrganizationID(ctx)
  33452. case wx.FieldAgentID:
  33453. return m.OldAgentID(ctx)
  33454. case wx.FieldAPIBase:
  33455. return m.OldAPIBase(ctx)
  33456. case wx.FieldAPIKey:
  33457. return m.OldAPIKey(ctx)
  33458. case wx.FieldAllowList:
  33459. return m.OldAllowList(ctx)
  33460. case wx.FieldGroupAllowList:
  33461. return m.OldGroupAllowList(ctx)
  33462. case wx.FieldBlockList:
  33463. return m.OldBlockList(ctx)
  33464. case wx.FieldGroupBlockList:
  33465. return m.OldGroupBlockList(ctx)
  33466. }
  33467. return nil, fmt.Errorf("unknown Wx field %s", name)
  33468. }
  33469. // SetField sets the value of a field with the given name. It returns an error if
  33470. // the field is not defined in the schema, or if the type mismatched the field
  33471. // type.
  33472. func (m *WxMutation) SetField(name string, value ent.Value) error {
  33473. switch name {
  33474. case wx.FieldCreatedAt:
  33475. v, ok := value.(time.Time)
  33476. if !ok {
  33477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33478. }
  33479. m.SetCreatedAt(v)
  33480. return nil
  33481. case wx.FieldUpdatedAt:
  33482. v, ok := value.(time.Time)
  33483. if !ok {
  33484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33485. }
  33486. m.SetUpdatedAt(v)
  33487. return nil
  33488. case wx.FieldStatus:
  33489. v, ok := value.(uint8)
  33490. if !ok {
  33491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33492. }
  33493. m.SetStatus(v)
  33494. return nil
  33495. case wx.FieldDeletedAt:
  33496. v, ok := value.(time.Time)
  33497. if !ok {
  33498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33499. }
  33500. m.SetDeletedAt(v)
  33501. return nil
  33502. case wx.FieldServerID:
  33503. v, ok := value.(uint64)
  33504. if !ok {
  33505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33506. }
  33507. m.SetServerID(v)
  33508. return nil
  33509. case wx.FieldPort:
  33510. v, ok := value.(string)
  33511. if !ok {
  33512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33513. }
  33514. m.SetPort(v)
  33515. return nil
  33516. case wx.FieldProcessID:
  33517. v, ok := value.(string)
  33518. if !ok {
  33519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33520. }
  33521. m.SetProcessID(v)
  33522. return nil
  33523. case wx.FieldCallback:
  33524. v, ok := value.(string)
  33525. if !ok {
  33526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33527. }
  33528. m.SetCallback(v)
  33529. return nil
  33530. case wx.FieldWxid:
  33531. v, ok := value.(string)
  33532. if !ok {
  33533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33534. }
  33535. m.SetWxid(v)
  33536. return nil
  33537. case wx.FieldAccount:
  33538. v, ok := value.(string)
  33539. if !ok {
  33540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33541. }
  33542. m.SetAccount(v)
  33543. return nil
  33544. case wx.FieldNickname:
  33545. v, ok := value.(string)
  33546. if !ok {
  33547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33548. }
  33549. m.SetNickname(v)
  33550. return nil
  33551. case wx.FieldTel:
  33552. v, ok := value.(string)
  33553. if !ok {
  33554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33555. }
  33556. m.SetTel(v)
  33557. return nil
  33558. case wx.FieldHeadBig:
  33559. v, ok := value.(string)
  33560. if !ok {
  33561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33562. }
  33563. m.SetHeadBig(v)
  33564. return nil
  33565. case wx.FieldOrganizationID:
  33566. v, ok := value.(uint64)
  33567. if !ok {
  33568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33569. }
  33570. m.SetOrganizationID(v)
  33571. return nil
  33572. case wx.FieldAgentID:
  33573. v, ok := value.(uint64)
  33574. if !ok {
  33575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33576. }
  33577. m.SetAgentID(v)
  33578. return nil
  33579. case wx.FieldAPIBase:
  33580. v, ok := value.(string)
  33581. if !ok {
  33582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33583. }
  33584. m.SetAPIBase(v)
  33585. return nil
  33586. case wx.FieldAPIKey:
  33587. v, ok := value.(string)
  33588. if !ok {
  33589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33590. }
  33591. m.SetAPIKey(v)
  33592. return nil
  33593. case wx.FieldAllowList:
  33594. v, ok := value.([]string)
  33595. if !ok {
  33596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33597. }
  33598. m.SetAllowList(v)
  33599. return nil
  33600. case wx.FieldGroupAllowList:
  33601. v, ok := value.([]string)
  33602. if !ok {
  33603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33604. }
  33605. m.SetGroupAllowList(v)
  33606. return nil
  33607. case wx.FieldBlockList:
  33608. v, ok := value.([]string)
  33609. if !ok {
  33610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33611. }
  33612. m.SetBlockList(v)
  33613. return nil
  33614. case wx.FieldGroupBlockList:
  33615. v, ok := value.([]string)
  33616. if !ok {
  33617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33618. }
  33619. m.SetGroupBlockList(v)
  33620. return nil
  33621. }
  33622. return fmt.Errorf("unknown Wx field %s", name)
  33623. }
  33624. // AddedFields returns all numeric fields that were incremented/decremented during
  33625. // this mutation.
  33626. func (m *WxMutation) AddedFields() []string {
  33627. var fields []string
  33628. if m.addstatus != nil {
  33629. fields = append(fields, wx.FieldStatus)
  33630. }
  33631. if m.addorganization_id != nil {
  33632. fields = append(fields, wx.FieldOrganizationID)
  33633. }
  33634. return fields
  33635. }
  33636. // AddedField returns the numeric value that was incremented/decremented on a field
  33637. // with the given name. The second boolean return value indicates that this field
  33638. // was not set, or was not defined in the schema.
  33639. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  33640. switch name {
  33641. case wx.FieldStatus:
  33642. return m.AddedStatus()
  33643. case wx.FieldOrganizationID:
  33644. return m.AddedOrganizationID()
  33645. }
  33646. return nil, false
  33647. }
  33648. // AddField adds the value to the field with the given name. It returns an error if
  33649. // the field is not defined in the schema, or if the type mismatched the field
  33650. // type.
  33651. func (m *WxMutation) AddField(name string, value ent.Value) error {
  33652. switch name {
  33653. case wx.FieldStatus:
  33654. v, ok := value.(int8)
  33655. if !ok {
  33656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33657. }
  33658. m.AddStatus(v)
  33659. return nil
  33660. case wx.FieldOrganizationID:
  33661. v, ok := value.(int64)
  33662. if !ok {
  33663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33664. }
  33665. m.AddOrganizationID(v)
  33666. return nil
  33667. }
  33668. return fmt.Errorf("unknown Wx numeric field %s", name)
  33669. }
  33670. // ClearedFields returns all nullable fields that were cleared during this
  33671. // mutation.
  33672. func (m *WxMutation) ClearedFields() []string {
  33673. var fields []string
  33674. if m.FieldCleared(wx.FieldStatus) {
  33675. fields = append(fields, wx.FieldStatus)
  33676. }
  33677. if m.FieldCleared(wx.FieldDeletedAt) {
  33678. fields = append(fields, wx.FieldDeletedAt)
  33679. }
  33680. if m.FieldCleared(wx.FieldServerID) {
  33681. fields = append(fields, wx.FieldServerID)
  33682. }
  33683. if m.FieldCleared(wx.FieldOrganizationID) {
  33684. fields = append(fields, wx.FieldOrganizationID)
  33685. }
  33686. if m.FieldCleared(wx.FieldAPIBase) {
  33687. fields = append(fields, wx.FieldAPIBase)
  33688. }
  33689. if m.FieldCleared(wx.FieldAPIKey) {
  33690. fields = append(fields, wx.FieldAPIKey)
  33691. }
  33692. return fields
  33693. }
  33694. // FieldCleared returns a boolean indicating if a field with the given name was
  33695. // cleared in this mutation.
  33696. func (m *WxMutation) FieldCleared(name string) bool {
  33697. _, ok := m.clearedFields[name]
  33698. return ok
  33699. }
  33700. // ClearField clears the value of the field with the given name. It returns an
  33701. // error if the field is not defined in the schema.
  33702. func (m *WxMutation) ClearField(name string) error {
  33703. switch name {
  33704. case wx.FieldStatus:
  33705. m.ClearStatus()
  33706. return nil
  33707. case wx.FieldDeletedAt:
  33708. m.ClearDeletedAt()
  33709. return nil
  33710. case wx.FieldServerID:
  33711. m.ClearServerID()
  33712. return nil
  33713. case wx.FieldOrganizationID:
  33714. m.ClearOrganizationID()
  33715. return nil
  33716. case wx.FieldAPIBase:
  33717. m.ClearAPIBase()
  33718. return nil
  33719. case wx.FieldAPIKey:
  33720. m.ClearAPIKey()
  33721. return nil
  33722. }
  33723. return fmt.Errorf("unknown Wx nullable field %s", name)
  33724. }
  33725. // ResetField resets all changes in the mutation for the field with the given name.
  33726. // It returns an error if the field is not defined in the schema.
  33727. func (m *WxMutation) ResetField(name string) error {
  33728. switch name {
  33729. case wx.FieldCreatedAt:
  33730. m.ResetCreatedAt()
  33731. return nil
  33732. case wx.FieldUpdatedAt:
  33733. m.ResetUpdatedAt()
  33734. return nil
  33735. case wx.FieldStatus:
  33736. m.ResetStatus()
  33737. return nil
  33738. case wx.FieldDeletedAt:
  33739. m.ResetDeletedAt()
  33740. return nil
  33741. case wx.FieldServerID:
  33742. m.ResetServerID()
  33743. return nil
  33744. case wx.FieldPort:
  33745. m.ResetPort()
  33746. return nil
  33747. case wx.FieldProcessID:
  33748. m.ResetProcessID()
  33749. return nil
  33750. case wx.FieldCallback:
  33751. m.ResetCallback()
  33752. return nil
  33753. case wx.FieldWxid:
  33754. m.ResetWxid()
  33755. return nil
  33756. case wx.FieldAccount:
  33757. m.ResetAccount()
  33758. return nil
  33759. case wx.FieldNickname:
  33760. m.ResetNickname()
  33761. return nil
  33762. case wx.FieldTel:
  33763. m.ResetTel()
  33764. return nil
  33765. case wx.FieldHeadBig:
  33766. m.ResetHeadBig()
  33767. return nil
  33768. case wx.FieldOrganizationID:
  33769. m.ResetOrganizationID()
  33770. return nil
  33771. case wx.FieldAgentID:
  33772. m.ResetAgentID()
  33773. return nil
  33774. case wx.FieldAPIBase:
  33775. m.ResetAPIBase()
  33776. return nil
  33777. case wx.FieldAPIKey:
  33778. m.ResetAPIKey()
  33779. return nil
  33780. case wx.FieldAllowList:
  33781. m.ResetAllowList()
  33782. return nil
  33783. case wx.FieldGroupAllowList:
  33784. m.ResetGroupAllowList()
  33785. return nil
  33786. case wx.FieldBlockList:
  33787. m.ResetBlockList()
  33788. return nil
  33789. case wx.FieldGroupBlockList:
  33790. m.ResetGroupBlockList()
  33791. return nil
  33792. }
  33793. return fmt.Errorf("unknown Wx field %s", name)
  33794. }
  33795. // AddedEdges returns all edge names that were set/added in this mutation.
  33796. func (m *WxMutation) AddedEdges() []string {
  33797. edges := make([]string, 0, 2)
  33798. if m.server != nil {
  33799. edges = append(edges, wx.EdgeServer)
  33800. }
  33801. if m.agent != nil {
  33802. edges = append(edges, wx.EdgeAgent)
  33803. }
  33804. return edges
  33805. }
  33806. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33807. // name in this mutation.
  33808. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  33809. switch name {
  33810. case wx.EdgeServer:
  33811. if id := m.server; id != nil {
  33812. return []ent.Value{*id}
  33813. }
  33814. case wx.EdgeAgent:
  33815. if id := m.agent; id != nil {
  33816. return []ent.Value{*id}
  33817. }
  33818. }
  33819. return nil
  33820. }
  33821. // RemovedEdges returns all edge names that were removed in this mutation.
  33822. func (m *WxMutation) RemovedEdges() []string {
  33823. edges := make([]string, 0, 2)
  33824. return edges
  33825. }
  33826. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33827. // the given name in this mutation.
  33828. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  33829. return nil
  33830. }
  33831. // ClearedEdges returns all edge names that were cleared in this mutation.
  33832. func (m *WxMutation) ClearedEdges() []string {
  33833. edges := make([]string, 0, 2)
  33834. if m.clearedserver {
  33835. edges = append(edges, wx.EdgeServer)
  33836. }
  33837. if m.clearedagent {
  33838. edges = append(edges, wx.EdgeAgent)
  33839. }
  33840. return edges
  33841. }
  33842. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33843. // was cleared in this mutation.
  33844. func (m *WxMutation) EdgeCleared(name string) bool {
  33845. switch name {
  33846. case wx.EdgeServer:
  33847. return m.clearedserver
  33848. case wx.EdgeAgent:
  33849. return m.clearedagent
  33850. }
  33851. return false
  33852. }
  33853. // ClearEdge clears the value of the edge with the given name. It returns an error
  33854. // if that edge is not defined in the schema.
  33855. func (m *WxMutation) ClearEdge(name string) error {
  33856. switch name {
  33857. case wx.EdgeServer:
  33858. m.ClearServer()
  33859. return nil
  33860. case wx.EdgeAgent:
  33861. m.ClearAgent()
  33862. return nil
  33863. }
  33864. return fmt.Errorf("unknown Wx unique edge %s", name)
  33865. }
  33866. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33867. // It returns an error if the edge is not defined in the schema.
  33868. func (m *WxMutation) ResetEdge(name string) error {
  33869. switch name {
  33870. case wx.EdgeServer:
  33871. m.ResetServer()
  33872. return nil
  33873. case wx.EdgeAgent:
  33874. m.ResetAgent()
  33875. return nil
  33876. }
  33877. return fmt.Errorf("unknown Wx edge %s", name)
  33878. }
  33879. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  33880. type WxCardMutation struct {
  33881. config
  33882. op Op
  33883. typ string
  33884. id *uint64
  33885. created_at *time.Time
  33886. updated_at *time.Time
  33887. deleted_at *time.Time
  33888. user_id *uint64
  33889. adduser_id *int64
  33890. wx_user_id *uint64
  33891. addwx_user_id *int64
  33892. avatar *string
  33893. logo *string
  33894. name *string
  33895. company *string
  33896. address *string
  33897. phone *string
  33898. official_account *string
  33899. wechat_account *string
  33900. email *string
  33901. api_base *string
  33902. api_key *string
  33903. ai_info *string
  33904. intro *string
  33905. clearedFields map[string]struct{}
  33906. done bool
  33907. oldValue func(context.Context) (*WxCard, error)
  33908. predicates []predicate.WxCard
  33909. }
  33910. var _ ent.Mutation = (*WxCardMutation)(nil)
  33911. // wxcardOption allows management of the mutation configuration using functional options.
  33912. type wxcardOption func(*WxCardMutation)
  33913. // newWxCardMutation creates new mutation for the WxCard entity.
  33914. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  33915. m := &WxCardMutation{
  33916. config: c,
  33917. op: op,
  33918. typ: TypeWxCard,
  33919. clearedFields: make(map[string]struct{}),
  33920. }
  33921. for _, opt := range opts {
  33922. opt(m)
  33923. }
  33924. return m
  33925. }
  33926. // withWxCardID sets the ID field of the mutation.
  33927. func withWxCardID(id uint64) wxcardOption {
  33928. return func(m *WxCardMutation) {
  33929. var (
  33930. err error
  33931. once sync.Once
  33932. value *WxCard
  33933. )
  33934. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  33935. once.Do(func() {
  33936. if m.done {
  33937. err = errors.New("querying old values post mutation is not allowed")
  33938. } else {
  33939. value, err = m.Client().WxCard.Get(ctx, id)
  33940. }
  33941. })
  33942. return value, err
  33943. }
  33944. m.id = &id
  33945. }
  33946. }
  33947. // withWxCard sets the old WxCard of the mutation.
  33948. func withWxCard(node *WxCard) wxcardOption {
  33949. return func(m *WxCardMutation) {
  33950. m.oldValue = func(context.Context) (*WxCard, error) {
  33951. return node, nil
  33952. }
  33953. m.id = &node.ID
  33954. }
  33955. }
  33956. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33957. // executed in a transaction (ent.Tx), a transactional client is returned.
  33958. func (m WxCardMutation) Client() *Client {
  33959. client := &Client{config: m.config}
  33960. client.init()
  33961. return client
  33962. }
  33963. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33964. // it returns an error otherwise.
  33965. func (m WxCardMutation) Tx() (*Tx, error) {
  33966. if _, ok := m.driver.(*txDriver); !ok {
  33967. return nil, errors.New("ent: mutation is not running in a transaction")
  33968. }
  33969. tx := &Tx{config: m.config}
  33970. tx.init()
  33971. return tx, nil
  33972. }
  33973. // SetID sets the value of the id field. Note that this
  33974. // operation is only accepted on creation of WxCard entities.
  33975. func (m *WxCardMutation) SetID(id uint64) {
  33976. m.id = &id
  33977. }
  33978. // ID returns the ID value in the mutation. Note that the ID is only available
  33979. // if it was provided to the builder or after it was returned from the database.
  33980. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  33981. if m.id == nil {
  33982. return
  33983. }
  33984. return *m.id, true
  33985. }
  33986. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33987. // That means, if the mutation is applied within a transaction with an isolation level such
  33988. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33989. // or updated by the mutation.
  33990. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  33991. switch {
  33992. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33993. id, exists := m.ID()
  33994. if exists {
  33995. return []uint64{id}, nil
  33996. }
  33997. fallthrough
  33998. case m.op.Is(OpUpdate | OpDelete):
  33999. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  34000. default:
  34001. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34002. }
  34003. }
  34004. // SetCreatedAt sets the "created_at" field.
  34005. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  34006. m.created_at = &t
  34007. }
  34008. // CreatedAt returns the value of the "created_at" field in the mutation.
  34009. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  34010. v := m.created_at
  34011. if v == nil {
  34012. return
  34013. }
  34014. return *v, true
  34015. }
  34016. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  34017. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34019. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34020. if !m.op.Is(OpUpdateOne) {
  34021. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34022. }
  34023. if m.id == nil || m.oldValue == nil {
  34024. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34025. }
  34026. oldValue, err := m.oldValue(ctx)
  34027. if err != nil {
  34028. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34029. }
  34030. return oldValue.CreatedAt, nil
  34031. }
  34032. // ResetCreatedAt resets all changes to the "created_at" field.
  34033. func (m *WxCardMutation) ResetCreatedAt() {
  34034. m.created_at = nil
  34035. }
  34036. // SetUpdatedAt sets the "updated_at" field.
  34037. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  34038. m.updated_at = &t
  34039. }
  34040. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34041. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  34042. v := m.updated_at
  34043. if v == nil {
  34044. return
  34045. }
  34046. return *v, true
  34047. }
  34048. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  34049. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34051. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34052. if !m.op.Is(OpUpdateOne) {
  34053. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34054. }
  34055. if m.id == nil || m.oldValue == nil {
  34056. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34057. }
  34058. oldValue, err := m.oldValue(ctx)
  34059. if err != nil {
  34060. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34061. }
  34062. return oldValue.UpdatedAt, nil
  34063. }
  34064. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34065. func (m *WxCardMutation) ResetUpdatedAt() {
  34066. m.updated_at = nil
  34067. }
  34068. // SetDeletedAt sets the "deleted_at" field.
  34069. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  34070. m.deleted_at = &t
  34071. }
  34072. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34073. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  34074. v := m.deleted_at
  34075. if v == nil {
  34076. return
  34077. }
  34078. return *v, true
  34079. }
  34080. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  34081. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34083. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34084. if !m.op.Is(OpUpdateOne) {
  34085. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34086. }
  34087. if m.id == nil || m.oldValue == nil {
  34088. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34089. }
  34090. oldValue, err := m.oldValue(ctx)
  34091. if err != nil {
  34092. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34093. }
  34094. return oldValue.DeletedAt, nil
  34095. }
  34096. // ClearDeletedAt clears the value of the "deleted_at" field.
  34097. func (m *WxCardMutation) ClearDeletedAt() {
  34098. m.deleted_at = nil
  34099. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  34100. }
  34101. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34102. func (m *WxCardMutation) DeletedAtCleared() bool {
  34103. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  34104. return ok
  34105. }
  34106. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34107. func (m *WxCardMutation) ResetDeletedAt() {
  34108. m.deleted_at = nil
  34109. delete(m.clearedFields, wxcard.FieldDeletedAt)
  34110. }
  34111. // SetUserID sets the "user_id" field.
  34112. func (m *WxCardMutation) SetUserID(u uint64) {
  34113. m.user_id = &u
  34114. m.adduser_id = nil
  34115. }
  34116. // UserID returns the value of the "user_id" field in the mutation.
  34117. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  34118. v := m.user_id
  34119. if v == nil {
  34120. return
  34121. }
  34122. return *v, true
  34123. }
  34124. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  34125. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34127. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  34128. if !m.op.Is(OpUpdateOne) {
  34129. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  34130. }
  34131. if m.id == nil || m.oldValue == nil {
  34132. return v, errors.New("OldUserID requires an ID field in the mutation")
  34133. }
  34134. oldValue, err := m.oldValue(ctx)
  34135. if err != nil {
  34136. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  34137. }
  34138. return oldValue.UserID, nil
  34139. }
  34140. // AddUserID adds u to the "user_id" field.
  34141. func (m *WxCardMutation) AddUserID(u int64) {
  34142. if m.adduser_id != nil {
  34143. *m.adduser_id += u
  34144. } else {
  34145. m.adduser_id = &u
  34146. }
  34147. }
  34148. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  34149. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  34150. v := m.adduser_id
  34151. if v == nil {
  34152. return
  34153. }
  34154. return *v, true
  34155. }
  34156. // ClearUserID clears the value of the "user_id" field.
  34157. func (m *WxCardMutation) ClearUserID() {
  34158. m.user_id = nil
  34159. m.adduser_id = nil
  34160. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  34161. }
  34162. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  34163. func (m *WxCardMutation) UserIDCleared() bool {
  34164. _, ok := m.clearedFields[wxcard.FieldUserID]
  34165. return ok
  34166. }
  34167. // ResetUserID resets all changes to the "user_id" field.
  34168. func (m *WxCardMutation) ResetUserID() {
  34169. m.user_id = nil
  34170. m.adduser_id = nil
  34171. delete(m.clearedFields, wxcard.FieldUserID)
  34172. }
  34173. // SetWxUserID sets the "wx_user_id" field.
  34174. func (m *WxCardMutation) SetWxUserID(u uint64) {
  34175. m.wx_user_id = &u
  34176. m.addwx_user_id = nil
  34177. }
  34178. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  34179. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  34180. v := m.wx_user_id
  34181. if v == nil {
  34182. return
  34183. }
  34184. return *v, true
  34185. }
  34186. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  34187. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34189. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  34190. if !m.op.Is(OpUpdateOne) {
  34191. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  34192. }
  34193. if m.id == nil || m.oldValue == nil {
  34194. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  34195. }
  34196. oldValue, err := m.oldValue(ctx)
  34197. if err != nil {
  34198. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  34199. }
  34200. return oldValue.WxUserID, nil
  34201. }
  34202. // AddWxUserID adds u to the "wx_user_id" field.
  34203. func (m *WxCardMutation) AddWxUserID(u int64) {
  34204. if m.addwx_user_id != nil {
  34205. *m.addwx_user_id += u
  34206. } else {
  34207. m.addwx_user_id = &u
  34208. }
  34209. }
  34210. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  34211. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  34212. v := m.addwx_user_id
  34213. if v == nil {
  34214. return
  34215. }
  34216. return *v, true
  34217. }
  34218. // ClearWxUserID clears the value of the "wx_user_id" field.
  34219. func (m *WxCardMutation) ClearWxUserID() {
  34220. m.wx_user_id = nil
  34221. m.addwx_user_id = nil
  34222. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  34223. }
  34224. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  34225. func (m *WxCardMutation) WxUserIDCleared() bool {
  34226. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  34227. return ok
  34228. }
  34229. // ResetWxUserID resets all changes to the "wx_user_id" field.
  34230. func (m *WxCardMutation) ResetWxUserID() {
  34231. m.wx_user_id = nil
  34232. m.addwx_user_id = nil
  34233. delete(m.clearedFields, wxcard.FieldWxUserID)
  34234. }
  34235. // SetAvatar sets the "avatar" field.
  34236. func (m *WxCardMutation) SetAvatar(s string) {
  34237. m.avatar = &s
  34238. }
  34239. // Avatar returns the value of the "avatar" field in the mutation.
  34240. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  34241. v := m.avatar
  34242. if v == nil {
  34243. return
  34244. }
  34245. return *v, true
  34246. }
  34247. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  34248. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34250. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  34251. if !m.op.Is(OpUpdateOne) {
  34252. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  34253. }
  34254. if m.id == nil || m.oldValue == nil {
  34255. return v, errors.New("OldAvatar requires an ID field in the mutation")
  34256. }
  34257. oldValue, err := m.oldValue(ctx)
  34258. if err != nil {
  34259. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  34260. }
  34261. return oldValue.Avatar, nil
  34262. }
  34263. // ResetAvatar resets all changes to the "avatar" field.
  34264. func (m *WxCardMutation) ResetAvatar() {
  34265. m.avatar = nil
  34266. }
  34267. // SetLogo sets the "logo" field.
  34268. func (m *WxCardMutation) SetLogo(s string) {
  34269. m.logo = &s
  34270. }
  34271. // Logo returns the value of the "logo" field in the mutation.
  34272. func (m *WxCardMutation) Logo() (r string, exists bool) {
  34273. v := m.logo
  34274. if v == nil {
  34275. return
  34276. }
  34277. return *v, true
  34278. }
  34279. // OldLogo returns the old "logo" field's value of the WxCard entity.
  34280. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34282. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  34283. if !m.op.Is(OpUpdateOne) {
  34284. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  34285. }
  34286. if m.id == nil || m.oldValue == nil {
  34287. return v, errors.New("OldLogo requires an ID field in the mutation")
  34288. }
  34289. oldValue, err := m.oldValue(ctx)
  34290. if err != nil {
  34291. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  34292. }
  34293. return oldValue.Logo, nil
  34294. }
  34295. // ResetLogo resets all changes to the "logo" field.
  34296. func (m *WxCardMutation) ResetLogo() {
  34297. m.logo = nil
  34298. }
  34299. // SetName sets the "name" field.
  34300. func (m *WxCardMutation) SetName(s string) {
  34301. m.name = &s
  34302. }
  34303. // Name returns the value of the "name" field in the mutation.
  34304. func (m *WxCardMutation) Name() (r string, exists bool) {
  34305. v := m.name
  34306. if v == nil {
  34307. return
  34308. }
  34309. return *v, true
  34310. }
  34311. // OldName returns the old "name" field's value of the WxCard entity.
  34312. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34314. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  34315. if !m.op.Is(OpUpdateOne) {
  34316. return v, errors.New("OldName is only allowed on UpdateOne operations")
  34317. }
  34318. if m.id == nil || m.oldValue == nil {
  34319. return v, errors.New("OldName requires an ID field in the mutation")
  34320. }
  34321. oldValue, err := m.oldValue(ctx)
  34322. if err != nil {
  34323. return v, fmt.Errorf("querying old value for OldName: %w", err)
  34324. }
  34325. return oldValue.Name, nil
  34326. }
  34327. // ResetName resets all changes to the "name" field.
  34328. func (m *WxCardMutation) ResetName() {
  34329. m.name = nil
  34330. }
  34331. // SetCompany sets the "company" field.
  34332. func (m *WxCardMutation) SetCompany(s string) {
  34333. m.company = &s
  34334. }
  34335. // Company returns the value of the "company" field in the mutation.
  34336. func (m *WxCardMutation) Company() (r string, exists bool) {
  34337. v := m.company
  34338. if v == nil {
  34339. return
  34340. }
  34341. return *v, true
  34342. }
  34343. // OldCompany returns the old "company" field's value of the WxCard entity.
  34344. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34346. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  34347. if !m.op.Is(OpUpdateOne) {
  34348. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  34349. }
  34350. if m.id == nil || m.oldValue == nil {
  34351. return v, errors.New("OldCompany requires an ID field in the mutation")
  34352. }
  34353. oldValue, err := m.oldValue(ctx)
  34354. if err != nil {
  34355. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  34356. }
  34357. return oldValue.Company, nil
  34358. }
  34359. // ResetCompany resets all changes to the "company" field.
  34360. func (m *WxCardMutation) ResetCompany() {
  34361. m.company = nil
  34362. }
  34363. // SetAddress sets the "address" field.
  34364. func (m *WxCardMutation) SetAddress(s string) {
  34365. m.address = &s
  34366. }
  34367. // Address returns the value of the "address" field in the mutation.
  34368. func (m *WxCardMutation) Address() (r string, exists bool) {
  34369. v := m.address
  34370. if v == nil {
  34371. return
  34372. }
  34373. return *v, true
  34374. }
  34375. // OldAddress returns the old "address" field's value of the WxCard entity.
  34376. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34378. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  34379. if !m.op.Is(OpUpdateOne) {
  34380. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  34381. }
  34382. if m.id == nil || m.oldValue == nil {
  34383. return v, errors.New("OldAddress requires an ID field in the mutation")
  34384. }
  34385. oldValue, err := m.oldValue(ctx)
  34386. if err != nil {
  34387. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  34388. }
  34389. return oldValue.Address, nil
  34390. }
  34391. // ResetAddress resets all changes to the "address" field.
  34392. func (m *WxCardMutation) ResetAddress() {
  34393. m.address = nil
  34394. }
  34395. // SetPhone sets the "phone" field.
  34396. func (m *WxCardMutation) SetPhone(s string) {
  34397. m.phone = &s
  34398. }
  34399. // Phone returns the value of the "phone" field in the mutation.
  34400. func (m *WxCardMutation) Phone() (r string, exists bool) {
  34401. v := m.phone
  34402. if v == nil {
  34403. return
  34404. }
  34405. return *v, true
  34406. }
  34407. // OldPhone returns the old "phone" field's value of the WxCard entity.
  34408. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34410. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  34411. if !m.op.Is(OpUpdateOne) {
  34412. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34413. }
  34414. if m.id == nil || m.oldValue == nil {
  34415. return v, errors.New("OldPhone requires an ID field in the mutation")
  34416. }
  34417. oldValue, err := m.oldValue(ctx)
  34418. if err != nil {
  34419. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34420. }
  34421. return oldValue.Phone, nil
  34422. }
  34423. // ResetPhone resets all changes to the "phone" field.
  34424. func (m *WxCardMutation) ResetPhone() {
  34425. m.phone = nil
  34426. }
  34427. // SetOfficialAccount sets the "official_account" field.
  34428. func (m *WxCardMutation) SetOfficialAccount(s string) {
  34429. m.official_account = &s
  34430. }
  34431. // OfficialAccount returns the value of the "official_account" field in the mutation.
  34432. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  34433. v := m.official_account
  34434. if v == nil {
  34435. return
  34436. }
  34437. return *v, true
  34438. }
  34439. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  34440. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34442. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  34443. if !m.op.Is(OpUpdateOne) {
  34444. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  34445. }
  34446. if m.id == nil || m.oldValue == nil {
  34447. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  34448. }
  34449. oldValue, err := m.oldValue(ctx)
  34450. if err != nil {
  34451. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  34452. }
  34453. return oldValue.OfficialAccount, nil
  34454. }
  34455. // ResetOfficialAccount resets all changes to the "official_account" field.
  34456. func (m *WxCardMutation) ResetOfficialAccount() {
  34457. m.official_account = nil
  34458. }
  34459. // SetWechatAccount sets the "wechat_account" field.
  34460. func (m *WxCardMutation) SetWechatAccount(s string) {
  34461. m.wechat_account = &s
  34462. }
  34463. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  34464. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  34465. v := m.wechat_account
  34466. if v == nil {
  34467. return
  34468. }
  34469. return *v, true
  34470. }
  34471. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  34472. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34474. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  34475. if !m.op.Is(OpUpdateOne) {
  34476. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  34477. }
  34478. if m.id == nil || m.oldValue == nil {
  34479. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  34480. }
  34481. oldValue, err := m.oldValue(ctx)
  34482. if err != nil {
  34483. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  34484. }
  34485. return oldValue.WechatAccount, nil
  34486. }
  34487. // ResetWechatAccount resets all changes to the "wechat_account" field.
  34488. func (m *WxCardMutation) ResetWechatAccount() {
  34489. m.wechat_account = nil
  34490. }
  34491. // SetEmail sets the "email" field.
  34492. func (m *WxCardMutation) SetEmail(s string) {
  34493. m.email = &s
  34494. }
  34495. // Email returns the value of the "email" field in the mutation.
  34496. func (m *WxCardMutation) Email() (r string, exists bool) {
  34497. v := m.email
  34498. if v == nil {
  34499. return
  34500. }
  34501. return *v, true
  34502. }
  34503. // OldEmail returns the old "email" field's value of the WxCard entity.
  34504. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34506. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  34507. if !m.op.Is(OpUpdateOne) {
  34508. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  34509. }
  34510. if m.id == nil || m.oldValue == nil {
  34511. return v, errors.New("OldEmail requires an ID field in the mutation")
  34512. }
  34513. oldValue, err := m.oldValue(ctx)
  34514. if err != nil {
  34515. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  34516. }
  34517. return oldValue.Email, nil
  34518. }
  34519. // ClearEmail clears the value of the "email" field.
  34520. func (m *WxCardMutation) ClearEmail() {
  34521. m.email = nil
  34522. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  34523. }
  34524. // EmailCleared returns if the "email" field was cleared in this mutation.
  34525. func (m *WxCardMutation) EmailCleared() bool {
  34526. _, ok := m.clearedFields[wxcard.FieldEmail]
  34527. return ok
  34528. }
  34529. // ResetEmail resets all changes to the "email" field.
  34530. func (m *WxCardMutation) ResetEmail() {
  34531. m.email = nil
  34532. delete(m.clearedFields, wxcard.FieldEmail)
  34533. }
  34534. // SetAPIBase sets the "api_base" field.
  34535. func (m *WxCardMutation) SetAPIBase(s string) {
  34536. m.api_base = &s
  34537. }
  34538. // APIBase returns the value of the "api_base" field in the mutation.
  34539. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  34540. v := m.api_base
  34541. if v == nil {
  34542. return
  34543. }
  34544. return *v, true
  34545. }
  34546. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  34547. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34549. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34550. if !m.op.Is(OpUpdateOne) {
  34551. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34552. }
  34553. if m.id == nil || m.oldValue == nil {
  34554. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34555. }
  34556. oldValue, err := m.oldValue(ctx)
  34557. if err != nil {
  34558. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34559. }
  34560. return oldValue.APIBase, nil
  34561. }
  34562. // ClearAPIBase clears the value of the "api_base" field.
  34563. func (m *WxCardMutation) ClearAPIBase() {
  34564. m.api_base = nil
  34565. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  34566. }
  34567. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34568. func (m *WxCardMutation) APIBaseCleared() bool {
  34569. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  34570. return ok
  34571. }
  34572. // ResetAPIBase resets all changes to the "api_base" field.
  34573. func (m *WxCardMutation) ResetAPIBase() {
  34574. m.api_base = nil
  34575. delete(m.clearedFields, wxcard.FieldAPIBase)
  34576. }
  34577. // SetAPIKey sets the "api_key" field.
  34578. func (m *WxCardMutation) SetAPIKey(s string) {
  34579. m.api_key = &s
  34580. }
  34581. // APIKey returns the value of the "api_key" field in the mutation.
  34582. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  34583. v := m.api_key
  34584. if v == nil {
  34585. return
  34586. }
  34587. return *v, true
  34588. }
  34589. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  34590. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34592. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34593. if !m.op.Is(OpUpdateOne) {
  34594. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34595. }
  34596. if m.id == nil || m.oldValue == nil {
  34597. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34598. }
  34599. oldValue, err := m.oldValue(ctx)
  34600. if err != nil {
  34601. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34602. }
  34603. return oldValue.APIKey, nil
  34604. }
  34605. // ClearAPIKey clears the value of the "api_key" field.
  34606. func (m *WxCardMutation) ClearAPIKey() {
  34607. m.api_key = nil
  34608. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  34609. }
  34610. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34611. func (m *WxCardMutation) APIKeyCleared() bool {
  34612. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  34613. return ok
  34614. }
  34615. // ResetAPIKey resets all changes to the "api_key" field.
  34616. func (m *WxCardMutation) ResetAPIKey() {
  34617. m.api_key = nil
  34618. delete(m.clearedFields, wxcard.FieldAPIKey)
  34619. }
  34620. // SetAiInfo sets the "ai_info" field.
  34621. func (m *WxCardMutation) SetAiInfo(s string) {
  34622. m.ai_info = &s
  34623. }
  34624. // AiInfo returns the value of the "ai_info" field in the mutation.
  34625. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  34626. v := m.ai_info
  34627. if v == nil {
  34628. return
  34629. }
  34630. return *v, true
  34631. }
  34632. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  34633. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34635. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  34636. if !m.op.Is(OpUpdateOne) {
  34637. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  34638. }
  34639. if m.id == nil || m.oldValue == nil {
  34640. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  34641. }
  34642. oldValue, err := m.oldValue(ctx)
  34643. if err != nil {
  34644. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  34645. }
  34646. return oldValue.AiInfo, nil
  34647. }
  34648. // ClearAiInfo clears the value of the "ai_info" field.
  34649. func (m *WxCardMutation) ClearAiInfo() {
  34650. m.ai_info = nil
  34651. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  34652. }
  34653. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  34654. func (m *WxCardMutation) AiInfoCleared() bool {
  34655. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  34656. return ok
  34657. }
  34658. // ResetAiInfo resets all changes to the "ai_info" field.
  34659. func (m *WxCardMutation) ResetAiInfo() {
  34660. m.ai_info = nil
  34661. delete(m.clearedFields, wxcard.FieldAiInfo)
  34662. }
  34663. // SetIntro sets the "intro" field.
  34664. func (m *WxCardMutation) SetIntro(s string) {
  34665. m.intro = &s
  34666. }
  34667. // Intro returns the value of the "intro" field in the mutation.
  34668. func (m *WxCardMutation) Intro() (r string, exists bool) {
  34669. v := m.intro
  34670. if v == nil {
  34671. return
  34672. }
  34673. return *v, true
  34674. }
  34675. // OldIntro returns the old "intro" field's value of the WxCard entity.
  34676. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34678. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  34679. if !m.op.Is(OpUpdateOne) {
  34680. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  34681. }
  34682. if m.id == nil || m.oldValue == nil {
  34683. return v, errors.New("OldIntro requires an ID field in the mutation")
  34684. }
  34685. oldValue, err := m.oldValue(ctx)
  34686. if err != nil {
  34687. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  34688. }
  34689. return oldValue.Intro, nil
  34690. }
  34691. // ClearIntro clears the value of the "intro" field.
  34692. func (m *WxCardMutation) ClearIntro() {
  34693. m.intro = nil
  34694. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  34695. }
  34696. // IntroCleared returns if the "intro" field was cleared in this mutation.
  34697. func (m *WxCardMutation) IntroCleared() bool {
  34698. _, ok := m.clearedFields[wxcard.FieldIntro]
  34699. return ok
  34700. }
  34701. // ResetIntro resets all changes to the "intro" field.
  34702. func (m *WxCardMutation) ResetIntro() {
  34703. m.intro = nil
  34704. delete(m.clearedFields, wxcard.FieldIntro)
  34705. }
  34706. // Where appends a list predicates to the WxCardMutation builder.
  34707. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  34708. m.predicates = append(m.predicates, ps...)
  34709. }
  34710. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  34711. // users can use type-assertion to append predicates that do not depend on any generated package.
  34712. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  34713. p := make([]predicate.WxCard, len(ps))
  34714. for i := range ps {
  34715. p[i] = ps[i]
  34716. }
  34717. m.Where(p...)
  34718. }
  34719. // Op returns the operation name.
  34720. func (m *WxCardMutation) Op() Op {
  34721. return m.op
  34722. }
  34723. // SetOp allows setting the mutation operation.
  34724. func (m *WxCardMutation) SetOp(op Op) {
  34725. m.op = op
  34726. }
  34727. // Type returns the node type of this mutation (WxCard).
  34728. func (m *WxCardMutation) Type() string {
  34729. return m.typ
  34730. }
  34731. // Fields returns all fields that were changed during this mutation. Note that in
  34732. // order to get all numeric fields that were incremented/decremented, call
  34733. // AddedFields().
  34734. func (m *WxCardMutation) Fields() []string {
  34735. fields := make([]string, 0, 18)
  34736. if m.created_at != nil {
  34737. fields = append(fields, wxcard.FieldCreatedAt)
  34738. }
  34739. if m.updated_at != nil {
  34740. fields = append(fields, wxcard.FieldUpdatedAt)
  34741. }
  34742. if m.deleted_at != nil {
  34743. fields = append(fields, wxcard.FieldDeletedAt)
  34744. }
  34745. if m.user_id != nil {
  34746. fields = append(fields, wxcard.FieldUserID)
  34747. }
  34748. if m.wx_user_id != nil {
  34749. fields = append(fields, wxcard.FieldWxUserID)
  34750. }
  34751. if m.avatar != nil {
  34752. fields = append(fields, wxcard.FieldAvatar)
  34753. }
  34754. if m.logo != nil {
  34755. fields = append(fields, wxcard.FieldLogo)
  34756. }
  34757. if m.name != nil {
  34758. fields = append(fields, wxcard.FieldName)
  34759. }
  34760. if m.company != nil {
  34761. fields = append(fields, wxcard.FieldCompany)
  34762. }
  34763. if m.address != nil {
  34764. fields = append(fields, wxcard.FieldAddress)
  34765. }
  34766. if m.phone != nil {
  34767. fields = append(fields, wxcard.FieldPhone)
  34768. }
  34769. if m.official_account != nil {
  34770. fields = append(fields, wxcard.FieldOfficialAccount)
  34771. }
  34772. if m.wechat_account != nil {
  34773. fields = append(fields, wxcard.FieldWechatAccount)
  34774. }
  34775. if m.email != nil {
  34776. fields = append(fields, wxcard.FieldEmail)
  34777. }
  34778. if m.api_base != nil {
  34779. fields = append(fields, wxcard.FieldAPIBase)
  34780. }
  34781. if m.api_key != nil {
  34782. fields = append(fields, wxcard.FieldAPIKey)
  34783. }
  34784. if m.ai_info != nil {
  34785. fields = append(fields, wxcard.FieldAiInfo)
  34786. }
  34787. if m.intro != nil {
  34788. fields = append(fields, wxcard.FieldIntro)
  34789. }
  34790. return fields
  34791. }
  34792. // Field returns the value of a field with the given name. The second boolean
  34793. // return value indicates that this field was not set, or was not defined in the
  34794. // schema.
  34795. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  34796. switch name {
  34797. case wxcard.FieldCreatedAt:
  34798. return m.CreatedAt()
  34799. case wxcard.FieldUpdatedAt:
  34800. return m.UpdatedAt()
  34801. case wxcard.FieldDeletedAt:
  34802. return m.DeletedAt()
  34803. case wxcard.FieldUserID:
  34804. return m.UserID()
  34805. case wxcard.FieldWxUserID:
  34806. return m.WxUserID()
  34807. case wxcard.FieldAvatar:
  34808. return m.Avatar()
  34809. case wxcard.FieldLogo:
  34810. return m.Logo()
  34811. case wxcard.FieldName:
  34812. return m.Name()
  34813. case wxcard.FieldCompany:
  34814. return m.Company()
  34815. case wxcard.FieldAddress:
  34816. return m.Address()
  34817. case wxcard.FieldPhone:
  34818. return m.Phone()
  34819. case wxcard.FieldOfficialAccount:
  34820. return m.OfficialAccount()
  34821. case wxcard.FieldWechatAccount:
  34822. return m.WechatAccount()
  34823. case wxcard.FieldEmail:
  34824. return m.Email()
  34825. case wxcard.FieldAPIBase:
  34826. return m.APIBase()
  34827. case wxcard.FieldAPIKey:
  34828. return m.APIKey()
  34829. case wxcard.FieldAiInfo:
  34830. return m.AiInfo()
  34831. case wxcard.FieldIntro:
  34832. return m.Intro()
  34833. }
  34834. return nil, false
  34835. }
  34836. // OldField returns the old value of the field from the database. An error is
  34837. // returned if the mutation operation is not UpdateOne, or the query to the
  34838. // database failed.
  34839. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34840. switch name {
  34841. case wxcard.FieldCreatedAt:
  34842. return m.OldCreatedAt(ctx)
  34843. case wxcard.FieldUpdatedAt:
  34844. return m.OldUpdatedAt(ctx)
  34845. case wxcard.FieldDeletedAt:
  34846. return m.OldDeletedAt(ctx)
  34847. case wxcard.FieldUserID:
  34848. return m.OldUserID(ctx)
  34849. case wxcard.FieldWxUserID:
  34850. return m.OldWxUserID(ctx)
  34851. case wxcard.FieldAvatar:
  34852. return m.OldAvatar(ctx)
  34853. case wxcard.FieldLogo:
  34854. return m.OldLogo(ctx)
  34855. case wxcard.FieldName:
  34856. return m.OldName(ctx)
  34857. case wxcard.FieldCompany:
  34858. return m.OldCompany(ctx)
  34859. case wxcard.FieldAddress:
  34860. return m.OldAddress(ctx)
  34861. case wxcard.FieldPhone:
  34862. return m.OldPhone(ctx)
  34863. case wxcard.FieldOfficialAccount:
  34864. return m.OldOfficialAccount(ctx)
  34865. case wxcard.FieldWechatAccount:
  34866. return m.OldWechatAccount(ctx)
  34867. case wxcard.FieldEmail:
  34868. return m.OldEmail(ctx)
  34869. case wxcard.FieldAPIBase:
  34870. return m.OldAPIBase(ctx)
  34871. case wxcard.FieldAPIKey:
  34872. return m.OldAPIKey(ctx)
  34873. case wxcard.FieldAiInfo:
  34874. return m.OldAiInfo(ctx)
  34875. case wxcard.FieldIntro:
  34876. return m.OldIntro(ctx)
  34877. }
  34878. return nil, fmt.Errorf("unknown WxCard field %s", name)
  34879. }
  34880. // SetField sets the value of a field with the given name. It returns an error if
  34881. // the field is not defined in the schema, or if the type mismatched the field
  34882. // type.
  34883. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  34884. switch name {
  34885. case wxcard.FieldCreatedAt:
  34886. v, ok := value.(time.Time)
  34887. if !ok {
  34888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34889. }
  34890. m.SetCreatedAt(v)
  34891. return nil
  34892. case wxcard.FieldUpdatedAt:
  34893. v, ok := value.(time.Time)
  34894. if !ok {
  34895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34896. }
  34897. m.SetUpdatedAt(v)
  34898. return nil
  34899. case wxcard.FieldDeletedAt:
  34900. v, ok := value.(time.Time)
  34901. if !ok {
  34902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34903. }
  34904. m.SetDeletedAt(v)
  34905. return nil
  34906. case wxcard.FieldUserID:
  34907. v, ok := value.(uint64)
  34908. if !ok {
  34909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34910. }
  34911. m.SetUserID(v)
  34912. return nil
  34913. case wxcard.FieldWxUserID:
  34914. v, ok := value.(uint64)
  34915. if !ok {
  34916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34917. }
  34918. m.SetWxUserID(v)
  34919. return nil
  34920. case wxcard.FieldAvatar:
  34921. v, ok := value.(string)
  34922. if !ok {
  34923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34924. }
  34925. m.SetAvatar(v)
  34926. return nil
  34927. case wxcard.FieldLogo:
  34928. v, ok := value.(string)
  34929. if !ok {
  34930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34931. }
  34932. m.SetLogo(v)
  34933. return nil
  34934. case wxcard.FieldName:
  34935. v, ok := value.(string)
  34936. if !ok {
  34937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34938. }
  34939. m.SetName(v)
  34940. return nil
  34941. case wxcard.FieldCompany:
  34942. v, ok := value.(string)
  34943. if !ok {
  34944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34945. }
  34946. m.SetCompany(v)
  34947. return nil
  34948. case wxcard.FieldAddress:
  34949. v, ok := value.(string)
  34950. if !ok {
  34951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34952. }
  34953. m.SetAddress(v)
  34954. return nil
  34955. case wxcard.FieldPhone:
  34956. v, ok := value.(string)
  34957. if !ok {
  34958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34959. }
  34960. m.SetPhone(v)
  34961. return nil
  34962. case wxcard.FieldOfficialAccount:
  34963. v, ok := value.(string)
  34964. if !ok {
  34965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34966. }
  34967. m.SetOfficialAccount(v)
  34968. return nil
  34969. case wxcard.FieldWechatAccount:
  34970. v, ok := value.(string)
  34971. if !ok {
  34972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34973. }
  34974. m.SetWechatAccount(v)
  34975. return nil
  34976. case wxcard.FieldEmail:
  34977. v, ok := value.(string)
  34978. if !ok {
  34979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34980. }
  34981. m.SetEmail(v)
  34982. return nil
  34983. case wxcard.FieldAPIBase:
  34984. v, ok := value.(string)
  34985. if !ok {
  34986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34987. }
  34988. m.SetAPIBase(v)
  34989. return nil
  34990. case wxcard.FieldAPIKey:
  34991. v, ok := value.(string)
  34992. if !ok {
  34993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34994. }
  34995. m.SetAPIKey(v)
  34996. return nil
  34997. case wxcard.FieldAiInfo:
  34998. v, ok := value.(string)
  34999. if !ok {
  35000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35001. }
  35002. m.SetAiInfo(v)
  35003. return nil
  35004. case wxcard.FieldIntro:
  35005. v, ok := value.(string)
  35006. if !ok {
  35007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35008. }
  35009. m.SetIntro(v)
  35010. return nil
  35011. }
  35012. return fmt.Errorf("unknown WxCard field %s", name)
  35013. }
  35014. // AddedFields returns all numeric fields that were incremented/decremented during
  35015. // this mutation.
  35016. func (m *WxCardMutation) AddedFields() []string {
  35017. var fields []string
  35018. if m.adduser_id != nil {
  35019. fields = append(fields, wxcard.FieldUserID)
  35020. }
  35021. if m.addwx_user_id != nil {
  35022. fields = append(fields, wxcard.FieldWxUserID)
  35023. }
  35024. return fields
  35025. }
  35026. // AddedField returns the numeric value that was incremented/decremented on a field
  35027. // with the given name. The second boolean return value indicates that this field
  35028. // was not set, or was not defined in the schema.
  35029. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  35030. switch name {
  35031. case wxcard.FieldUserID:
  35032. return m.AddedUserID()
  35033. case wxcard.FieldWxUserID:
  35034. return m.AddedWxUserID()
  35035. }
  35036. return nil, false
  35037. }
  35038. // AddField adds the value to the field with the given name. It returns an error if
  35039. // the field is not defined in the schema, or if the type mismatched the field
  35040. // type.
  35041. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  35042. switch name {
  35043. case wxcard.FieldUserID:
  35044. v, ok := value.(int64)
  35045. if !ok {
  35046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35047. }
  35048. m.AddUserID(v)
  35049. return nil
  35050. case wxcard.FieldWxUserID:
  35051. v, ok := value.(int64)
  35052. if !ok {
  35053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35054. }
  35055. m.AddWxUserID(v)
  35056. return nil
  35057. }
  35058. return fmt.Errorf("unknown WxCard numeric field %s", name)
  35059. }
  35060. // ClearedFields returns all nullable fields that were cleared during this
  35061. // mutation.
  35062. func (m *WxCardMutation) ClearedFields() []string {
  35063. var fields []string
  35064. if m.FieldCleared(wxcard.FieldDeletedAt) {
  35065. fields = append(fields, wxcard.FieldDeletedAt)
  35066. }
  35067. if m.FieldCleared(wxcard.FieldUserID) {
  35068. fields = append(fields, wxcard.FieldUserID)
  35069. }
  35070. if m.FieldCleared(wxcard.FieldWxUserID) {
  35071. fields = append(fields, wxcard.FieldWxUserID)
  35072. }
  35073. if m.FieldCleared(wxcard.FieldEmail) {
  35074. fields = append(fields, wxcard.FieldEmail)
  35075. }
  35076. if m.FieldCleared(wxcard.FieldAPIBase) {
  35077. fields = append(fields, wxcard.FieldAPIBase)
  35078. }
  35079. if m.FieldCleared(wxcard.FieldAPIKey) {
  35080. fields = append(fields, wxcard.FieldAPIKey)
  35081. }
  35082. if m.FieldCleared(wxcard.FieldAiInfo) {
  35083. fields = append(fields, wxcard.FieldAiInfo)
  35084. }
  35085. if m.FieldCleared(wxcard.FieldIntro) {
  35086. fields = append(fields, wxcard.FieldIntro)
  35087. }
  35088. return fields
  35089. }
  35090. // FieldCleared returns a boolean indicating if a field with the given name was
  35091. // cleared in this mutation.
  35092. func (m *WxCardMutation) FieldCleared(name string) bool {
  35093. _, ok := m.clearedFields[name]
  35094. return ok
  35095. }
  35096. // ClearField clears the value of the field with the given name. It returns an
  35097. // error if the field is not defined in the schema.
  35098. func (m *WxCardMutation) ClearField(name string) error {
  35099. switch name {
  35100. case wxcard.FieldDeletedAt:
  35101. m.ClearDeletedAt()
  35102. return nil
  35103. case wxcard.FieldUserID:
  35104. m.ClearUserID()
  35105. return nil
  35106. case wxcard.FieldWxUserID:
  35107. m.ClearWxUserID()
  35108. return nil
  35109. case wxcard.FieldEmail:
  35110. m.ClearEmail()
  35111. return nil
  35112. case wxcard.FieldAPIBase:
  35113. m.ClearAPIBase()
  35114. return nil
  35115. case wxcard.FieldAPIKey:
  35116. m.ClearAPIKey()
  35117. return nil
  35118. case wxcard.FieldAiInfo:
  35119. m.ClearAiInfo()
  35120. return nil
  35121. case wxcard.FieldIntro:
  35122. m.ClearIntro()
  35123. return nil
  35124. }
  35125. return fmt.Errorf("unknown WxCard nullable field %s", name)
  35126. }
  35127. // ResetField resets all changes in the mutation for the field with the given name.
  35128. // It returns an error if the field is not defined in the schema.
  35129. func (m *WxCardMutation) ResetField(name string) error {
  35130. switch name {
  35131. case wxcard.FieldCreatedAt:
  35132. m.ResetCreatedAt()
  35133. return nil
  35134. case wxcard.FieldUpdatedAt:
  35135. m.ResetUpdatedAt()
  35136. return nil
  35137. case wxcard.FieldDeletedAt:
  35138. m.ResetDeletedAt()
  35139. return nil
  35140. case wxcard.FieldUserID:
  35141. m.ResetUserID()
  35142. return nil
  35143. case wxcard.FieldWxUserID:
  35144. m.ResetWxUserID()
  35145. return nil
  35146. case wxcard.FieldAvatar:
  35147. m.ResetAvatar()
  35148. return nil
  35149. case wxcard.FieldLogo:
  35150. m.ResetLogo()
  35151. return nil
  35152. case wxcard.FieldName:
  35153. m.ResetName()
  35154. return nil
  35155. case wxcard.FieldCompany:
  35156. m.ResetCompany()
  35157. return nil
  35158. case wxcard.FieldAddress:
  35159. m.ResetAddress()
  35160. return nil
  35161. case wxcard.FieldPhone:
  35162. m.ResetPhone()
  35163. return nil
  35164. case wxcard.FieldOfficialAccount:
  35165. m.ResetOfficialAccount()
  35166. return nil
  35167. case wxcard.FieldWechatAccount:
  35168. m.ResetWechatAccount()
  35169. return nil
  35170. case wxcard.FieldEmail:
  35171. m.ResetEmail()
  35172. return nil
  35173. case wxcard.FieldAPIBase:
  35174. m.ResetAPIBase()
  35175. return nil
  35176. case wxcard.FieldAPIKey:
  35177. m.ResetAPIKey()
  35178. return nil
  35179. case wxcard.FieldAiInfo:
  35180. m.ResetAiInfo()
  35181. return nil
  35182. case wxcard.FieldIntro:
  35183. m.ResetIntro()
  35184. return nil
  35185. }
  35186. return fmt.Errorf("unknown WxCard field %s", name)
  35187. }
  35188. // AddedEdges returns all edge names that were set/added in this mutation.
  35189. func (m *WxCardMutation) AddedEdges() []string {
  35190. edges := make([]string, 0, 0)
  35191. return edges
  35192. }
  35193. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35194. // name in this mutation.
  35195. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  35196. return nil
  35197. }
  35198. // RemovedEdges returns all edge names that were removed in this mutation.
  35199. func (m *WxCardMutation) RemovedEdges() []string {
  35200. edges := make([]string, 0, 0)
  35201. return edges
  35202. }
  35203. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35204. // the given name in this mutation.
  35205. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  35206. return nil
  35207. }
  35208. // ClearedEdges returns all edge names that were cleared in this mutation.
  35209. func (m *WxCardMutation) ClearedEdges() []string {
  35210. edges := make([]string, 0, 0)
  35211. return edges
  35212. }
  35213. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35214. // was cleared in this mutation.
  35215. func (m *WxCardMutation) EdgeCleared(name string) bool {
  35216. return false
  35217. }
  35218. // ClearEdge clears the value of the edge with the given name. It returns an error
  35219. // if that edge is not defined in the schema.
  35220. func (m *WxCardMutation) ClearEdge(name string) error {
  35221. return fmt.Errorf("unknown WxCard unique edge %s", name)
  35222. }
  35223. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35224. // It returns an error if the edge is not defined in the schema.
  35225. func (m *WxCardMutation) ResetEdge(name string) error {
  35226. return fmt.Errorf("unknown WxCard edge %s", name)
  35227. }
  35228. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  35229. type WxCardUserMutation struct {
  35230. config
  35231. op Op
  35232. typ string
  35233. id *uint64
  35234. created_at *time.Time
  35235. updated_at *time.Time
  35236. deleted_at *time.Time
  35237. wxid *string
  35238. account *string
  35239. avatar *string
  35240. nickname *string
  35241. remark *string
  35242. phone *string
  35243. open_id *string
  35244. union_id *string
  35245. session_key *string
  35246. is_vip *int
  35247. addis_vip *int
  35248. clearedFields map[string]struct{}
  35249. done bool
  35250. oldValue func(context.Context) (*WxCardUser, error)
  35251. predicates []predicate.WxCardUser
  35252. }
  35253. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  35254. // wxcarduserOption allows management of the mutation configuration using functional options.
  35255. type wxcarduserOption func(*WxCardUserMutation)
  35256. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  35257. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  35258. m := &WxCardUserMutation{
  35259. config: c,
  35260. op: op,
  35261. typ: TypeWxCardUser,
  35262. clearedFields: make(map[string]struct{}),
  35263. }
  35264. for _, opt := range opts {
  35265. opt(m)
  35266. }
  35267. return m
  35268. }
  35269. // withWxCardUserID sets the ID field of the mutation.
  35270. func withWxCardUserID(id uint64) wxcarduserOption {
  35271. return func(m *WxCardUserMutation) {
  35272. var (
  35273. err error
  35274. once sync.Once
  35275. value *WxCardUser
  35276. )
  35277. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  35278. once.Do(func() {
  35279. if m.done {
  35280. err = errors.New("querying old values post mutation is not allowed")
  35281. } else {
  35282. value, err = m.Client().WxCardUser.Get(ctx, id)
  35283. }
  35284. })
  35285. return value, err
  35286. }
  35287. m.id = &id
  35288. }
  35289. }
  35290. // withWxCardUser sets the old WxCardUser of the mutation.
  35291. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  35292. return func(m *WxCardUserMutation) {
  35293. m.oldValue = func(context.Context) (*WxCardUser, error) {
  35294. return node, nil
  35295. }
  35296. m.id = &node.ID
  35297. }
  35298. }
  35299. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35300. // executed in a transaction (ent.Tx), a transactional client is returned.
  35301. func (m WxCardUserMutation) Client() *Client {
  35302. client := &Client{config: m.config}
  35303. client.init()
  35304. return client
  35305. }
  35306. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35307. // it returns an error otherwise.
  35308. func (m WxCardUserMutation) Tx() (*Tx, error) {
  35309. if _, ok := m.driver.(*txDriver); !ok {
  35310. return nil, errors.New("ent: mutation is not running in a transaction")
  35311. }
  35312. tx := &Tx{config: m.config}
  35313. tx.init()
  35314. return tx, nil
  35315. }
  35316. // SetID sets the value of the id field. Note that this
  35317. // operation is only accepted on creation of WxCardUser entities.
  35318. func (m *WxCardUserMutation) SetID(id uint64) {
  35319. m.id = &id
  35320. }
  35321. // ID returns the ID value in the mutation. Note that the ID is only available
  35322. // if it was provided to the builder or after it was returned from the database.
  35323. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  35324. if m.id == nil {
  35325. return
  35326. }
  35327. return *m.id, true
  35328. }
  35329. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35330. // That means, if the mutation is applied within a transaction with an isolation level such
  35331. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35332. // or updated by the mutation.
  35333. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  35334. switch {
  35335. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35336. id, exists := m.ID()
  35337. if exists {
  35338. return []uint64{id}, nil
  35339. }
  35340. fallthrough
  35341. case m.op.Is(OpUpdate | OpDelete):
  35342. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  35343. default:
  35344. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35345. }
  35346. }
  35347. // SetCreatedAt sets the "created_at" field.
  35348. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  35349. m.created_at = &t
  35350. }
  35351. // CreatedAt returns the value of the "created_at" field in the mutation.
  35352. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  35353. v := m.created_at
  35354. if v == nil {
  35355. return
  35356. }
  35357. return *v, true
  35358. }
  35359. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  35360. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35362. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35363. if !m.op.Is(OpUpdateOne) {
  35364. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35365. }
  35366. if m.id == nil || m.oldValue == nil {
  35367. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35368. }
  35369. oldValue, err := m.oldValue(ctx)
  35370. if err != nil {
  35371. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35372. }
  35373. return oldValue.CreatedAt, nil
  35374. }
  35375. // ResetCreatedAt resets all changes to the "created_at" field.
  35376. func (m *WxCardUserMutation) ResetCreatedAt() {
  35377. m.created_at = nil
  35378. }
  35379. // SetUpdatedAt sets the "updated_at" field.
  35380. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  35381. m.updated_at = &t
  35382. }
  35383. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35384. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  35385. v := m.updated_at
  35386. if v == nil {
  35387. return
  35388. }
  35389. return *v, true
  35390. }
  35391. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  35392. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35394. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35395. if !m.op.Is(OpUpdateOne) {
  35396. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35397. }
  35398. if m.id == nil || m.oldValue == nil {
  35399. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35400. }
  35401. oldValue, err := m.oldValue(ctx)
  35402. if err != nil {
  35403. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35404. }
  35405. return oldValue.UpdatedAt, nil
  35406. }
  35407. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35408. func (m *WxCardUserMutation) ResetUpdatedAt() {
  35409. m.updated_at = nil
  35410. }
  35411. // SetDeletedAt sets the "deleted_at" field.
  35412. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  35413. m.deleted_at = &t
  35414. }
  35415. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35416. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  35417. v := m.deleted_at
  35418. if v == nil {
  35419. return
  35420. }
  35421. return *v, true
  35422. }
  35423. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  35424. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35426. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35427. if !m.op.Is(OpUpdateOne) {
  35428. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35429. }
  35430. if m.id == nil || m.oldValue == nil {
  35431. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35432. }
  35433. oldValue, err := m.oldValue(ctx)
  35434. if err != nil {
  35435. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35436. }
  35437. return oldValue.DeletedAt, nil
  35438. }
  35439. // ClearDeletedAt clears the value of the "deleted_at" field.
  35440. func (m *WxCardUserMutation) ClearDeletedAt() {
  35441. m.deleted_at = nil
  35442. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  35443. }
  35444. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35445. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  35446. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  35447. return ok
  35448. }
  35449. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35450. func (m *WxCardUserMutation) ResetDeletedAt() {
  35451. m.deleted_at = nil
  35452. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  35453. }
  35454. // SetWxid sets the "wxid" field.
  35455. func (m *WxCardUserMutation) SetWxid(s string) {
  35456. m.wxid = &s
  35457. }
  35458. // Wxid returns the value of the "wxid" field in the mutation.
  35459. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  35460. v := m.wxid
  35461. if v == nil {
  35462. return
  35463. }
  35464. return *v, true
  35465. }
  35466. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  35467. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35469. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  35470. if !m.op.Is(OpUpdateOne) {
  35471. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  35472. }
  35473. if m.id == nil || m.oldValue == nil {
  35474. return v, errors.New("OldWxid requires an ID field in the mutation")
  35475. }
  35476. oldValue, err := m.oldValue(ctx)
  35477. if err != nil {
  35478. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  35479. }
  35480. return oldValue.Wxid, nil
  35481. }
  35482. // ResetWxid resets all changes to the "wxid" field.
  35483. func (m *WxCardUserMutation) ResetWxid() {
  35484. m.wxid = nil
  35485. }
  35486. // SetAccount sets the "account" field.
  35487. func (m *WxCardUserMutation) SetAccount(s string) {
  35488. m.account = &s
  35489. }
  35490. // Account returns the value of the "account" field in the mutation.
  35491. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  35492. v := m.account
  35493. if v == nil {
  35494. return
  35495. }
  35496. return *v, true
  35497. }
  35498. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  35499. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35501. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  35502. if !m.op.Is(OpUpdateOne) {
  35503. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  35504. }
  35505. if m.id == nil || m.oldValue == nil {
  35506. return v, errors.New("OldAccount requires an ID field in the mutation")
  35507. }
  35508. oldValue, err := m.oldValue(ctx)
  35509. if err != nil {
  35510. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  35511. }
  35512. return oldValue.Account, nil
  35513. }
  35514. // ResetAccount resets all changes to the "account" field.
  35515. func (m *WxCardUserMutation) ResetAccount() {
  35516. m.account = nil
  35517. }
  35518. // SetAvatar sets the "avatar" field.
  35519. func (m *WxCardUserMutation) SetAvatar(s string) {
  35520. m.avatar = &s
  35521. }
  35522. // Avatar returns the value of the "avatar" field in the mutation.
  35523. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  35524. v := m.avatar
  35525. if v == nil {
  35526. return
  35527. }
  35528. return *v, true
  35529. }
  35530. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  35531. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35533. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  35534. if !m.op.Is(OpUpdateOne) {
  35535. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  35536. }
  35537. if m.id == nil || m.oldValue == nil {
  35538. return v, errors.New("OldAvatar requires an ID field in the mutation")
  35539. }
  35540. oldValue, err := m.oldValue(ctx)
  35541. if err != nil {
  35542. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  35543. }
  35544. return oldValue.Avatar, nil
  35545. }
  35546. // ResetAvatar resets all changes to the "avatar" field.
  35547. func (m *WxCardUserMutation) ResetAvatar() {
  35548. m.avatar = nil
  35549. }
  35550. // SetNickname sets the "nickname" field.
  35551. func (m *WxCardUserMutation) SetNickname(s string) {
  35552. m.nickname = &s
  35553. }
  35554. // Nickname returns the value of the "nickname" field in the mutation.
  35555. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  35556. v := m.nickname
  35557. if v == nil {
  35558. return
  35559. }
  35560. return *v, true
  35561. }
  35562. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  35563. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35565. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  35566. if !m.op.Is(OpUpdateOne) {
  35567. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  35568. }
  35569. if m.id == nil || m.oldValue == nil {
  35570. return v, errors.New("OldNickname requires an ID field in the mutation")
  35571. }
  35572. oldValue, err := m.oldValue(ctx)
  35573. if err != nil {
  35574. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  35575. }
  35576. return oldValue.Nickname, nil
  35577. }
  35578. // ResetNickname resets all changes to the "nickname" field.
  35579. func (m *WxCardUserMutation) ResetNickname() {
  35580. m.nickname = nil
  35581. }
  35582. // SetRemark sets the "remark" field.
  35583. func (m *WxCardUserMutation) SetRemark(s string) {
  35584. m.remark = &s
  35585. }
  35586. // Remark returns the value of the "remark" field in the mutation.
  35587. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  35588. v := m.remark
  35589. if v == nil {
  35590. return
  35591. }
  35592. return *v, true
  35593. }
  35594. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  35595. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35597. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  35598. if !m.op.Is(OpUpdateOne) {
  35599. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  35600. }
  35601. if m.id == nil || m.oldValue == nil {
  35602. return v, errors.New("OldRemark requires an ID field in the mutation")
  35603. }
  35604. oldValue, err := m.oldValue(ctx)
  35605. if err != nil {
  35606. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  35607. }
  35608. return oldValue.Remark, nil
  35609. }
  35610. // ResetRemark resets all changes to the "remark" field.
  35611. func (m *WxCardUserMutation) ResetRemark() {
  35612. m.remark = nil
  35613. }
  35614. // SetPhone sets the "phone" field.
  35615. func (m *WxCardUserMutation) SetPhone(s string) {
  35616. m.phone = &s
  35617. }
  35618. // Phone returns the value of the "phone" field in the mutation.
  35619. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  35620. v := m.phone
  35621. if v == nil {
  35622. return
  35623. }
  35624. return *v, true
  35625. }
  35626. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  35627. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35629. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  35630. if !m.op.Is(OpUpdateOne) {
  35631. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35632. }
  35633. if m.id == nil || m.oldValue == nil {
  35634. return v, errors.New("OldPhone requires an ID field in the mutation")
  35635. }
  35636. oldValue, err := m.oldValue(ctx)
  35637. if err != nil {
  35638. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35639. }
  35640. return oldValue.Phone, nil
  35641. }
  35642. // ResetPhone resets all changes to the "phone" field.
  35643. func (m *WxCardUserMutation) ResetPhone() {
  35644. m.phone = nil
  35645. }
  35646. // SetOpenID sets the "open_id" field.
  35647. func (m *WxCardUserMutation) SetOpenID(s string) {
  35648. m.open_id = &s
  35649. }
  35650. // OpenID returns the value of the "open_id" field in the mutation.
  35651. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  35652. v := m.open_id
  35653. if v == nil {
  35654. return
  35655. }
  35656. return *v, true
  35657. }
  35658. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  35659. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35661. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  35662. if !m.op.Is(OpUpdateOne) {
  35663. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  35664. }
  35665. if m.id == nil || m.oldValue == nil {
  35666. return v, errors.New("OldOpenID requires an ID field in the mutation")
  35667. }
  35668. oldValue, err := m.oldValue(ctx)
  35669. if err != nil {
  35670. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  35671. }
  35672. return oldValue.OpenID, nil
  35673. }
  35674. // ResetOpenID resets all changes to the "open_id" field.
  35675. func (m *WxCardUserMutation) ResetOpenID() {
  35676. m.open_id = nil
  35677. }
  35678. // SetUnionID sets the "union_id" field.
  35679. func (m *WxCardUserMutation) SetUnionID(s string) {
  35680. m.union_id = &s
  35681. }
  35682. // UnionID returns the value of the "union_id" field in the mutation.
  35683. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  35684. v := m.union_id
  35685. if v == nil {
  35686. return
  35687. }
  35688. return *v, true
  35689. }
  35690. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  35691. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35693. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  35694. if !m.op.Is(OpUpdateOne) {
  35695. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  35696. }
  35697. if m.id == nil || m.oldValue == nil {
  35698. return v, errors.New("OldUnionID requires an ID field in the mutation")
  35699. }
  35700. oldValue, err := m.oldValue(ctx)
  35701. if err != nil {
  35702. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  35703. }
  35704. return oldValue.UnionID, nil
  35705. }
  35706. // ResetUnionID resets all changes to the "union_id" field.
  35707. func (m *WxCardUserMutation) ResetUnionID() {
  35708. m.union_id = nil
  35709. }
  35710. // SetSessionKey sets the "session_key" field.
  35711. func (m *WxCardUserMutation) SetSessionKey(s string) {
  35712. m.session_key = &s
  35713. }
  35714. // SessionKey returns the value of the "session_key" field in the mutation.
  35715. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  35716. v := m.session_key
  35717. if v == nil {
  35718. return
  35719. }
  35720. return *v, true
  35721. }
  35722. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  35723. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35725. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  35726. if !m.op.Is(OpUpdateOne) {
  35727. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  35728. }
  35729. if m.id == nil || m.oldValue == nil {
  35730. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  35731. }
  35732. oldValue, err := m.oldValue(ctx)
  35733. if err != nil {
  35734. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  35735. }
  35736. return oldValue.SessionKey, nil
  35737. }
  35738. // ResetSessionKey resets all changes to the "session_key" field.
  35739. func (m *WxCardUserMutation) ResetSessionKey() {
  35740. m.session_key = nil
  35741. }
  35742. // SetIsVip sets the "is_vip" field.
  35743. func (m *WxCardUserMutation) SetIsVip(i int) {
  35744. m.is_vip = &i
  35745. m.addis_vip = nil
  35746. }
  35747. // IsVip returns the value of the "is_vip" field in the mutation.
  35748. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  35749. v := m.is_vip
  35750. if v == nil {
  35751. return
  35752. }
  35753. return *v, true
  35754. }
  35755. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  35756. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35758. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  35759. if !m.op.Is(OpUpdateOne) {
  35760. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  35761. }
  35762. if m.id == nil || m.oldValue == nil {
  35763. return v, errors.New("OldIsVip requires an ID field in the mutation")
  35764. }
  35765. oldValue, err := m.oldValue(ctx)
  35766. if err != nil {
  35767. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  35768. }
  35769. return oldValue.IsVip, nil
  35770. }
  35771. // AddIsVip adds i to the "is_vip" field.
  35772. func (m *WxCardUserMutation) AddIsVip(i int) {
  35773. if m.addis_vip != nil {
  35774. *m.addis_vip += i
  35775. } else {
  35776. m.addis_vip = &i
  35777. }
  35778. }
  35779. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  35780. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  35781. v := m.addis_vip
  35782. if v == nil {
  35783. return
  35784. }
  35785. return *v, true
  35786. }
  35787. // ResetIsVip resets all changes to the "is_vip" field.
  35788. func (m *WxCardUserMutation) ResetIsVip() {
  35789. m.is_vip = nil
  35790. m.addis_vip = nil
  35791. }
  35792. // Where appends a list predicates to the WxCardUserMutation builder.
  35793. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  35794. m.predicates = append(m.predicates, ps...)
  35795. }
  35796. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  35797. // users can use type-assertion to append predicates that do not depend on any generated package.
  35798. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  35799. p := make([]predicate.WxCardUser, len(ps))
  35800. for i := range ps {
  35801. p[i] = ps[i]
  35802. }
  35803. m.Where(p...)
  35804. }
  35805. // Op returns the operation name.
  35806. func (m *WxCardUserMutation) Op() Op {
  35807. return m.op
  35808. }
  35809. // SetOp allows setting the mutation operation.
  35810. func (m *WxCardUserMutation) SetOp(op Op) {
  35811. m.op = op
  35812. }
  35813. // Type returns the node type of this mutation (WxCardUser).
  35814. func (m *WxCardUserMutation) Type() string {
  35815. return m.typ
  35816. }
  35817. // Fields returns all fields that were changed during this mutation. Note that in
  35818. // order to get all numeric fields that were incremented/decremented, call
  35819. // AddedFields().
  35820. func (m *WxCardUserMutation) Fields() []string {
  35821. fields := make([]string, 0, 13)
  35822. if m.created_at != nil {
  35823. fields = append(fields, wxcarduser.FieldCreatedAt)
  35824. }
  35825. if m.updated_at != nil {
  35826. fields = append(fields, wxcarduser.FieldUpdatedAt)
  35827. }
  35828. if m.deleted_at != nil {
  35829. fields = append(fields, wxcarduser.FieldDeletedAt)
  35830. }
  35831. if m.wxid != nil {
  35832. fields = append(fields, wxcarduser.FieldWxid)
  35833. }
  35834. if m.account != nil {
  35835. fields = append(fields, wxcarduser.FieldAccount)
  35836. }
  35837. if m.avatar != nil {
  35838. fields = append(fields, wxcarduser.FieldAvatar)
  35839. }
  35840. if m.nickname != nil {
  35841. fields = append(fields, wxcarduser.FieldNickname)
  35842. }
  35843. if m.remark != nil {
  35844. fields = append(fields, wxcarduser.FieldRemark)
  35845. }
  35846. if m.phone != nil {
  35847. fields = append(fields, wxcarduser.FieldPhone)
  35848. }
  35849. if m.open_id != nil {
  35850. fields = append(fields, wxcarduser.FieldOpenID)
  35851. }
  35852. if m.union_id != nil {
  35853. fields = append(fields, wxcarduser.FieldUnionID)
  35854. }
  35855. if m.session_key != nil {
  35856. fields = append(fields, wxcarduser.FieldSessionKey)
  35857. }
  35858. if m.is_vip != nil {
  35859. fields = append(fields, wxcarduser.FieldIsVip)
  35860. }
  35861. return fields
  35862. }
  35863. // Field returns the value of a field with the given name. The second boolean
  35864. // return value indicates that this field was not set, or was not defined in the
  35865. // schema.
  35866. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  35867. switch name {
  35868. case wxcarduser.FieldCreatedAt:
  35869. return m.CreatedAt()
  35870. case wxcarduser.FieldUpdatedAt:
  35871. return m.UpdatedAt()
  35872. case wxcarduser.FieldDeletedAt:
  35873. return m.DeletedAt()
  35874. case wxcarduser.FieldWxid:
  35875. return m.Wxid()
  35876. case wxcarduser.FieldAccount:
  35877. return m.Account()
  35878. case wxcarduser.FieldAvatar:
  35879. return m.Avatar()
  35880. case wxcarduser.FieldNickname:
  35881. return m.Nickname()
  35882. case wxcarduser.FieldRemark:
  35883. return m.Remark()
  35884. case wxcarduser.FieldPhone:
  35885. return m.Phone()
  35886. case wxcarduser.FieldOpenID:
  35887. return m.OpenID()
  35888. case wxcarduser.FieldUnionID:
  35889. return m.UnionID()
  35890. case wxcarduser.FieldSessionKey:
  35891. return m.SessionKey()
  35892. case wxcarduser.FieldIsVip:
  35893. return m.IsVip()
  35894. }
  35895. return nil, false
  35896. }
  35897. // OldField returns the old value of the field from the database. An error is
  35898. // returned if the mutation operation is not UpdateOne, or the query to the
  35899. // database failed.
  35900. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35901. switch name {
  35902. case wxcarduser.FieldCreatedAt:
  35903. return m.OldCreatedAt(ctx)
  35904. case wxcarduser.FieldUpdatedAt:
  35905. return m.OldUpdatedAt(ctx)
  35906. case wxcarduser.FieldDeletedAt:
  35907. return m.OldDeletedAt(ctx)
  35908. case wxcarduser.FieldWxid:
  35909. return m.OldWxid(ctx)
  35910. case wxcarduser.FieldAccount:
  35911. return m.OldAccount(ctx)
  35912. case wxcarduser.FieldAvatar:
  35913. return m.OldAvatar(ctx)
  35914. case wxcarduser.FieldNickname:
  35915. return m.OldNickname(ctx)
  35916. case wxcarduser.FieldRemark:
  35917. return m.OldRemark(ctx)
  35918. case wxcarduser.FieldPhone:
  35919. return m.OldPhone(ctx)
  35920. case wxcarduser.FieldOpenID:
  35921. return m.OldOpenID(ctx)
  35922. case wxcarduser.FieldUnionID:
  35923. return m.OldUnionID(ctx)
  35924. case wxcarduser.FieldSessionKey:
  35925. return m.OldSessionKey(ctx)
  35926. case wxcarduser.FieldIsVip:
  35927. return m.OldIsVip(ctx)
  35928. }
  35929. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  35930. }
  35931. // SetField sets the value of a field with the given name. It returns an error if
  35932. // the field is not defined in the schema, or if the type mismatched the field
  35933. // type.
  35934. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  35935. switch name {
  35936. case wxcarduser.FieldCreatedAt:
  35937. v, ok := value.(time.Time)
  35938. if !ok {
  35939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35940. }
  35941. m.SetCreatedAt(v)
  35942. return nil
  35943. case wxcarduser.FieldUpdatedAt:
  35944. v, ok := value.(time.Time)
  35945. if !ok {
  35946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35947. }
  35948. m.SetUpdatedAt(v)
  35949. return nil
  35950. case wxcarduser.FieldDeletedAt:
  35951. v, ok := value.(time.Time)
  35952. if !ok {
  35953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35954. }
  35955. m.SetDeletedAt(v)
  35956. return nil
  35957. case wxcarduser.FieldWxid:
  35958. v, ok := value.(string)
  35959. if !ok {
  35960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35961. }
  35962. m.SetWxid(v)
  35963. return nil
  35964. case wxcarduser.FieldAccount:
  35965. v, ok := value.(string)
  35966. if !ok {
  35967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35968. }
  35969. m.SetAccount(v)
  35970. return nil
  35971. case wxcarduser.FieldAvatar:
  35972. v, ok := value.(string)
  35973. if !ok {
  35974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35975. }
  35976. m.SetAvatar(v)
  35977. return nil
  35978. case wxcarduser.FieldNickname:
  35979. v, ok := value.(string)
  35980. if !ok {
  35981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35982. }
  35983. m.SetNickname(v)
  35984. return nil
  35985. case wxcarduser.FieldRemark:
  35986. v, ok := value.(string)
  35987. if !ok {
  35988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35989. }
  35990. m.SetRemark(v)
  35991. return nil
  35992. case wxcarduser.FieldPhone:
  35993. v, ok := value.(string)
  35994. if !ok {
  35995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35996. }
  35997. m.SetPhone(v)
  35998. return nil
  35999. case wxcarduser.FieldOpenID:
  36000. v, ok := value.(string)
  36001. if !ok {
  36002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36003. }
  36004. m.SetOpenID(v)
  36005. return nil
  36006. case wxcarduser.FieldUnionID:
  36007. v, ok := value.(string)
  36008. if !ok {
  36009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36010. }
  36011. m.SetUnionID(v)
  36012. return nil
  36013. case wxcarduser.FieldSessionKey:
  36014. v, ok := value.(string)
  36015. if !ok {
  36016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36017. }
  36018. m.SetSessionKey(v)
  36019. return nil
  36020. case wxcarduser.FieldIsVip:
  36021. v, ok := value.(int)
  36022. if !ok {
  36023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36024. }
  36025. m.SetIsVip(v)
  36026. return nil
  36027. }
  36028. return fmt.Errorf("unknown WxCardUser field %s", name)
  36029. }
  36030. // AddedFields returns all numeric fields that were incremented/decremented during
  36031. // this mutation.
  36032. func (m *WxCardUserMutation) AddedFields() []string {
  36033. var fields []string
  36034. if m.addis_vip != nil {
  36035. fields = append(fields, wxcarduser.FieldIsVip)
  36036. }
  36037. return fields
  36038. }
  36039. // AddedField returns the numeric value that was incremented/decremented on a field
  36040. // with the given name. The second boolean return value indicates that this field
  36041. // was not set, or was not defined in the schema.
  36042. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  36043. switch name {
  36044. case wxcarduser.FieldIsVip:
  36045. return m.AddedIsVip()
  36046. }
  36047. return nil, false
  36048. }
  36049. // AddField adds the value to the field with the given name. It returns an error if
  36050. // the field is not defined in the schema, or if the type mismatched the field
  36051. // type.
  36052. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  36053. switch name {
  36054. case wxcarduser.FieldIsVip:
  36055. v, ok := value.(int)
  36056. if !ok {
  36057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36058. }
  36059. m.AddIsVip(v)
  36060. return nil
  36061. }
  36062. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  36063. }
  36064. // ClearedFields returns all nullable fields that were cleared during this
  36065. // mutation.
  36066. func (m *WxCardUserMutation) ClearedFields() []string {
  36067. var fields []string
  36068. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  36069. fields = append(fields, wxcarduser.FieldDeletedAt)
  36070. }
  36071. return fields
  36072. }
  36073. // FieldCleared returns a boolean indicating if a field with the given name was
  36074. // cleared in this mutation.
  36075. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  36076. _, ok := m.clearedFields[name]
  36077. return ok
  36078. }
  36079. // ClearField clears the value of the field with the given name. It returns an
  36080. // error if the field is not defined in the schema.
  36081. func (m *WxCardUserMutation) ClearField(name string) error {
  36082. switch name {
  36083. case wxcarduser.FieldDeletedAt:
  36084. m.ClearDeletedAt()
  36085. return nil
  36086. }
  36087. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  36088. }
  36089. // ResetField resets all changes in the mutation for the field with the given name.
  36090. // It returns an error if the field is not defined in the schema.
  36091. func (m *WxCardUserMutation) ResetField(name string) error {
  36092. switch name {
  36093. case wxcarduser.FieldCreatedAt:
  36094. m.ResetCreatedAt()
  36095. return nil
  36096. case wxcarduser.FieldUpdatedAt:
  36097. m.ResetUpdatedAt()
  36098. return nil
  36099. case wxcarduser.FieldDeletedAt:
  36100. m.ResetDeletedAt()
  36101. return nil
  36102. case wxcarduser.FieldWxid:
  36103. m.ResetWxid()
  36104. return nil
  36105. case wxcarduser.FieldAccount:
  36106. m.ResetAccount()
  36107. return nil
  36108. case wxcarduser.FieldAvatar:
  36109. m.ResetAvatar()
  36110. return nil
  36111. case wxcarduser.FieldNickname:
  36112. m.ResetNickname()
  36113. return nil
  36114. case wxcarduser.FieldRemark:
  36115. m.ResetRemark()
  36116. return nil
  36117. case wxcarduser.FieldPhone:
  36118. m.ResetPhone()
  36119. return nil
  36120. case wxcarduser.FieldOpenID:
  36121. m.ResetOpenID()
  36122. return nil
  36123. case wxcarduser.FieldUnionID:
  36124. m.ResetUnionID()
  36125. return nil
  36126. case wxcarduser.FieldSessionKey:
  36127. m.ResetSessionKey()
  36128. return nil
  36129. case wxcarduser.FieldIsVip:
  36130. m.ResetIsVip()
  36131. return nil
  36132. }
  36133. return fmt.Errorf("unknown WxCardUser field %s", name)
  36134. }
  36135. // AddedEdges returns all edge names that were set/added in this mutation.
  36136. func (m *WxCardUserMutation) AddedEdges() []string {
  36137. edges := make([]string, 0, 0)
  36138. return edges
  36139. }
  36140. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36141. // name in this mutation.
  36142. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  36143. return nil
  36144. }
  36145. // RemovedEdges returns all edge names that were removed in this mutation.
  36146. func (m *WxCardUserMutation) RemovedEdges() []string {
  36147. edges := make([]string, 0, 0)
  36148. return edges
  36149. }
  36150. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36151. // the given name in this mutation.
  36152. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  36153. return nil
  36154. }
  36155. // ClearedEdges returns all edge names that were cleared in this mutation.
  36156. func (m *WxCardUserMutation) ClearedEdges() []string {
  36157. edges := make([]string, 0, 0)
  36158. return edges
  36159. }
  36160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36161. // was cleared in this mutation.
  36162. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  36163. return false
  36164. }
  36165. // ClearEdge clears the value of the edge with the given name. It returns an error
  36166. // if that edge is not defined in the schema.
  36167. func (m *WxCardUserMutation) ClearEdge(name string) error {
  36168. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  36169. }
  36170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36171. // It returns an error if the edge is not defined in the schema.
  36172. func (m *WxCardUserMutation) ResetEdge(name string) error {
  36173. return fmt.Errorf("unknown WxCardUser edge %s", name)
  36174. }
  36175. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  36176. type WxCardVisitMutation struct {
  36177. config
  36178. op Op
  36179. typ string
  36180. id *uint64
  36181. created_at *time.Time
  36182. updated_at *time.Time
  36183. deleted_at *time.Time
  36184. user_id *uint64
  36185. adduser_id *int64
  36186. bot_id *uint64
  36187. addbot_id *int64
  36188. bot_type *uint8
  36189. addbot_type *int8
  36190. clearedFields map[string]struct{}
  36191. done bool
  36192. oldValue func(context.Context) (*WxCardVisit, error)
  36193. predicates []predicate.WxCardVisit
  36194. }
  36195. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  36196. // wxcardvisitOption allows management of the mutation configuration using functional options.
  36197. type wxcardvisitOption func(*WxCardVisitMutation)
  36198. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  36199. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  36200. m := &WxCardVisitMutation{
  36201. config: c,
  36202. op: op,
  36203. typ: TypeWxCardVisit,
  36204. clearedFields: make(map[string]struct{}),
  36205. }
  36206. for _, opt := range opts {
  36207. opt(m)
  36208. }
  36209. return m
  36210. }
  36211. // withWxCardVisitID sets the ID field of the mutation.
  36212. func withWxCardVisitID(id uint64) wxcardvisitOption {
  36213. return func(m *WxCardVisitMutation) {
  36214. var (
  36215. err error
  36216. once sync.Once
  36217. value *WxCardVisit
  36218. )
  36219. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  36220. once.Do(func() {
  36221. if m.done {
  36222. err = errors.New("querying old values post mutation is not allowed")
  36223. } else {
  36224. value, err = m.Client().WxCardVisit.Get(ctx, id)
  36225. }
  36226. })
  36227. return value, err
  36228. }
  36229. m.id = &id
  36230. }
  36231. }
  36232. // withWxCardVisit sets the old WxCardVisit of the mutation.
  36233. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  36234. return func(m *WxCardVisitMutation) {
  36235. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  36236. return node, nil
  36237. }
  36238. m.id = &node.ID
  36239. }
  36240. }
  36241. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36242. // executed in a transaction (ent.Tx), a transactional client is returned.
  36243. func (m WxCardVisitMutation) Client() *Client {
  36244. client := &Client{config: m.config}
  36245. client.init()
  36246. return client
  36247. }
  36248. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36249. // it returns an error otherwise.
  36250. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  36251. if _, ok := m.driver.(*txDriver); !ok {
  36252. return nil, errors.New("ent: mutation is not running in a transaction")
  36253. }
  36254. tx := &Tx{config: m.config}
  36255. tx.init()
  36256. return tx, nil
  36257. }
  36258. // SetID sets the value of the id field. Note that this
  36259. // operation is only accepted on creation of WxCardVisit entities.
  36260. func (m *WxCardVisitMutation) SetID(id uint64) {
  36261. m.id = &id
  36262. }
  36263. // ID returns the ID value in the mutation. Note that the ID is only available
  36264. // if it was provided to the builder or after it was returned from the database.
  36265. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  36266. if m.id == nil {
  36267. return
  36268. }
  36269. return *m.id, true
  36270. }
  36271. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36272. // That means, if the mutation is applied within a transaction with an isolation level such
  36273. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36274. // or updated by the mutation.
  36275. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  36276. switch {
  36277. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36278. id, exists := m.ID()
  36279. if exists {
  36280. return []uint64{id}, nil
  36281. }
  36282. fallthrough
  36283. case m.op.Is(OpUpdate | OpDelete):
  36284. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  36285. default:
  36286. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36287. }
  36288. }
  36289. // SetCreatedAt sets the "created_at" field.
  36290. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  36291. m.created_at = &t
  36292. }
  36293. // CreatedAt returns the value of the "created_at" field in the mutation.
  36294. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  36295. v := m.created_at
  36296. if v == nil {
  36297. return
  36298. }
  36299. return *v, true
  36300. }
  36301. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  36302. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36304. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36305. if !m.op.Is(OpUpdateOne) {
  36306. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36307. }
  36308. if m.id == nil || m.oldValue == nil {
  36309. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36310. }
  36311. oldValue, err := m.oldValue(ctx)
  36312. if err != nil {
  36313. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36314. }
  36315. return oldValue.CreatedAt, nil
  36316. }
  36317. // ResetCreatedAt resets all changes to the "created_at" field.
  36318. func (m *WxCardVisitMutation) ResetCreatedAt() {
  36319. m.created_at = nil
  36320. }
  36321. // SetUpdatedAt sets the "updated_at" field.
  36322. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  36323. m.updated_at = &t
  36324. }
  36325. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36326. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  36327. v := m.updated_at
  36328. if v == nil {
  36329. return
  36330. }
  36331. return *v, true
  36332. }
  36333. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  36334. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36336. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36337. if !m.op.Is(OpUpdateOne) {
  36338. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36339. }
  36340. if m.id == nil || m.oldValue == nil {
  36341. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36342. }
  36343. oldValue, err := m.oldValue(ctx)
  36344. if err != nil {
  36345. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36346. }
  36347. return oldValue.UpdatedAt, nil
  36348. }
  36349. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36350. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  36351. m.updated_at = nil
  36352. }
  36353. // SetDeletedAt sets the "deleted_at" field.
  36354. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  36355. m.deleted_at = &t
  36356. }
  36357. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36358. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  36359. v := m.deleted_at
  36360. if v == nil {
  36361. return
  36362. }
  36363. return *v, true
  36364. }
  36365. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  36366. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36368. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36369. if !m.op.Is(OpUpdateOne) {
  36370. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36371. }
  36372. if m.id == nil || m.oldValue == nil {
  36373. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36374. }
  36375. oldValue, err := m.oldValue(ctx)
  36376. if err != nil {
  36377. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36378. }
  36379. return oldValue.DeletedAt, nil
  36380. }
  36381. // ClearDeletedAt clears the value of the "deleted_at" field.
  36382. func (m *WxCardVisitMutation) ClearDeletedAt() {
  36383. m.deleted_at = nil
  36384. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  36385. }
  36386. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36387. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  36388. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  36389. return ok
  36390. }
  36391. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36392. func (m *WxCardVisitMutation) ResetDeletedAt() {
  36393. m.deleted_at = nil
  36394. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  36395. }
  36396. // SetUserID sets the "user_id" field.
  36397. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  36398. m.user_id = &u
  36399. m.adduser_id = nil
  36400. }
  36401. // UserID returns the value of the "user_id" field in the mutation.
  36402. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  36403. v := m.user_id
  36404. if v == nil {
  36405. return
  36406. }
  36407. return *v, true
  36408. }
  36409. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  36410. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36412. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  36413. if !m.op.Is(OpUpdateOne) {
  36414. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  36415. }
  36416. if m.id == nil || m.oldValue == nil {
  36417. return v, errors.New("OldUserID requires an ID field in the mutation")
  36418. }
  36419. oldValue, err := m.oldValue(ctx)
  36420. if err != nil {
  36421. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  36422. }
  36423. return oldValue.UserID, nil
  36424. }
  36425. // AddUserID adds u to the "user_id" field.
  36426. func (m *WxCardVisitMutation) AddUserID(u int64) {
  36427. if m.adduser_id != nil {
  36428. *m.adduser_id += u
  36429. } else {
  36430. m.adduser_id = &u
  36431. }
  36432. }
  36433. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  36434. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  36435. v := m.adduser_id
  36436. if v == nil {
  36437. return
  36438. }
  36439. return *v, true
  36440. }
  36441. // ClearUserID clears the value of the "user_id" field.
  36442. func (m *WxCardVisitMutation) ClearUserID() {
  36443. m.user_id = nil
  36444. m.adduser_id = nil
  36445. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  36446. }
  36447. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  36448. func (m *WxCardVisitMutation) UserIDCleared() bool {
  36449. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  36450. return ok
  36451. }
  36452. // ResetUserID resets all changes to the "user_id" field.
  36453. func (m *WxCardVisitMutation) ResetUserID() {
  36454. m.user_id = nil
  36455. m.adduser_id = nil
  36456. delete(m.clearedFields, wxcardvisit.FieldUserID)
  36457. }
  36458. // SetBotID sets the "bot_id" field.
  36459. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  36460. m.bot_id = &u
  36461. m.addbot_id = nil
  36462. }
  36463. // BotID returns the value of the "bot_id" field in the mutation.
  36464. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  36465. v := m.bot_id
  36466. if v == nil {
  36467. return
  36468. }
  36469. return *v, true
  36470. }
  36471. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  36472. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36474. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  36475. if !m.op.Is(OpUpdateOne) {
  36476. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36477. }
  36478. if m.id == nil || m.oldValue == nil {
  36479. return v, errors.New("OldBotID requires an ID field in the mutation")
  36480. }
  36481. oldValue, err := m.oldValue(ctx)
  36482. if err != nil {
  36483. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36484. }
  36485. return oldValue.BotID, nil
  36486. }
  36487. // AddBotID adds u to the "bot_id" field.
  36488. func (m *WxCardVisitMutation) AddBotID(u int64) {
  36489. if m.addbot_id != nil {
  36490. *m.addbot_id += u
  36491. } else {
  36492. m.addbot_id = &u
  36493. }
  36494. }
  36495. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  36496. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  36497. v := m.addbot_id
  36498. if v == nil {
  36499. return
  36500. }
  36501. return *v, true
  36502. }
  36503. // ResetBotID resets all changes to the "bot_id" field.
  36504. func (m *WxCardVisitMutation) ResetBotID() {
  36505. m.bot_id = nil
  36506. m.addbot_id = nil
  36507. }
  36508. // SetBotType sets the "bot_type" field.
  36509. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  36510. m.bot_type = &u
  36511. m.addbot_type = nil
  36512. }
  36513. // BotType returns the value of the "bot_type" field in the mutation.
  36514. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  36515. v := m.bot_type
  36516. if v == nil {
  36517. return
  36518. }
  36519. return *v, true
  36520. }
  36521. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  36522. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36524. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  36525. if !m.op.Is(OpUpdateOne) {
  36526. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  36527. }
  36528. if m.id == nil || m.oldValue == nil {
  36529. return v, errors.New("OldBotType requires an ID field in the mutation")
  36530. }
  36531. oldValue, err := m.oldValue(ctx)
  36532. if err != nil {
  36533. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  36534. }
  36535. return oldValue.BotType, nil
  36536. }
  36537. // AddBotType adds u to the "bot_type" field.
  36538. func (m *WxCardVisitMutation) AddBotType(u int8) {
  36539. if m.addbot_type != nil {
  36540. *m.addbot_type += u
  36541. } else {
  36542. m.addbot_type = &u
  36543. }
  36544. }
  36545. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  36546. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  36547. v := m.addbot_type
  36548. if v == nil {
  36549. return
  36550. }
  36551. return *v, true
  36552. }
  36553. // ResetBotType resets all changes to the "bot_type" field.
  36554. func (m *WxCardVisitMutation) ResetBotType() {
  36555. m.bot_type = nil
  36556. m.addbot_type = nil
  36557. }
  36558. // Where appends a list predicates to the WxCardVisitMutation builder.
  36559. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  36560. m.predicates = append(m.predicates, ps...)
  36561. }
  36562. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  36563. // users can use type-assertion to append predicates that do not depend on any generated package.
  36564. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  36565. p := make([]predicate.WxCardVisit, len(ps))
  36566. for i := range ps {
  36567. p[i] = ps[i]
  36568. }
  36569. m.Where(p...)
  36570. }
  36571. // Op returns the operation name.
  36572. func (m *WxCardVisitMutation) Op() Op {
  36573. return m.op
  36574. }
  36575. // SetOp allows setting the mutation operation.
  36576. func (m *WxCardVisitMutation) SetOp(op Op) {
  36577. m.op = op
  36578. }
  36579. // Type returns the node type of this mutation (WxCardVisit).
  36580. func (m *WxCardVisitMutation) Type() string {
  36581. return m.typ
  36582. }
  36583. // Fields returns all fields that were changed during this mutation. Note that in
  36584. // order to get all numeric fields that were incremented/decremented, call
  36585. // AddedFields().
  36586. func (m *WxCardVisitMutation) Fields() []string {
  36587. fields := make([]string, 0, 6)
  36588. if m.created_at != nil {
  36589. fields = append(fields, wxcardvisit.FieldCreatedAt)
  36590. }
  36591. if m.updated_at != nil {
  36592. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  36593. }
  36594. if m.deleted_at != nil {
  36595. fields = append(fields, wxcardvisit.FieldDeletedAt)
  36596. }
  36597. if m.user_id != nil {
  36598. fields = append(fields, wxcardvisit.FieldUserID)
  36599. }
  36600. if m.bot_id != nil {
  36601. fields = append(fields, wxcardvisit.FieldBotID)
  36602. }
  36603. if m.bot_type != nil {
  36604. fields = append(fields, wxcardvisit.FieldBotType)
  36605. }
  36606. return fields
  36607. }
  36608. // Field returns the value of a field with the given name. The second boolean
  36609. // return value indicates that this field was not set, or was not defined in the
  36610. // schema.
  36611. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  36612. switch name {
  36613. case wxcardvisit.FieldCreatedAt:
  36614. return m.CreatedAt()
  36615. case wxcardvisit.FieldUpdatedAt:
  36616. return m.UpdatedAt()
  36617. case wxcardvisit.FieldDeletedAt:
  36618. return m.DeletedAt()
  36619. case wxcardvisit.FieldUserID:
  36620. return m.UserID()
  36621. case wxcardvisit.FieldBotID:
  36622. return m.BotID()
  36623. case wxcardvisit.FieldBotType:
  36624. return m.BotType()
  36625. }
  36626. return nil, false
  36627. }
  36628. // OldField returns the old value of the field from the database. An error is
  36629. // returned if the mutation operation is not UpdateOne, or the query to the
  36630. // database failed.
  36631. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36632. switch name {
  36633. case wxcardvisit.FieldCreatedAt:
  36634. return m.OldCreatedAt(ctx)
  36635. case wxcardvisit.FieldUpdatedAt:
  36636. return m.OldUpdatedAt(ctx)
  36637. case wxcardvisit.FieldDeletedAt:
  36638. return m.OldDeletedAt(ctx)
  36639. case wxcardvisit.FieldUserID:
  36640. return m.OldUserID(ctx)
  36641. case wxcardvisit.FieldBotID:
  36642. return m.OldBotID(ctx)
  36643. case wxcardvisit.FieldBotType:
  36644. return m.OldBotType(ctx)
  36645. }
  36646. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  36647. }
  36648. // SetField sets the value of a field with the given name. It returns an error if
  36649. // the field is not defined in the schema, or if the type mismatched the field
  36650. // type.
  36651. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  36652. switch name {
  36653. case wxcardvisit.FieldCreatedAt:
  36654. v, ok := value.(time.Time)
  36655. if !ok {
  36656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36657. }
  36658. m.SetCreatedAt(v)
  36659. return nil
  36660. case wxcardvisit.FieldUpdatedAt:
  36661. v, ok := value.(time.Time)
  36662. if !ok {
  36663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36664. }
  36665. m.SetUpdatedAt(v)
  36666. return nil
  36667. case wxcardvisit.FieldDeletedAt:
  36668. v, ok := value.(time.Time)
  36669. if !ok {
  36670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36671. }
  36672. m.SetDeletedAt(v)
  36673. return nil
  36674. case wxcardvisit.FieldUserID:
  36675. v, ok := value.(uint64)
  36676. if !ok {
  36677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36678. }
  36679. m.SetUserID(v)
  36680. return nil
  36681. case wxcardvisit.FieldBotID:
  36682. v, ok := value.(uint64)
  36683. if !ok {
  36684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36685. }
  36686. m.SetBotID(v)
  36687. return nil
  36688. case wxcardvisit.FieldBotType:
  36689. v, ok := value.(uint8)
  36690. if !ok {
  36691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36692. }
  36693. m.SetBotType(v)
  36694. return nil
  36695. }
  36696. return fmt.Errorf("unknown WxCardVisit field %s", name)
  36697. }
  36698. // AddedFields returns all numeric fields that were incremented/decremented during
  36699. // this mutation.
  36700. func (m *WxCardVisitMutation) AddedFields() []string {
  36701. var fields []string
  36702. if m.adduser_id != nil {
  36703. fields = append(fields, wxcardvisit.FieldUserID)
  36704. }
  36705. if m.addbot_id != nil {
  36706. fields = append(fields, wxcardvisit.FieldBotID)
  36707. }
  36708. if m.addbot_type != nil {
  36709. fields = append(fields, wxcardvisit.FieldBotType)
  36710. }
  36711. return fields
  36712. }
  36713. // AddedField returns the numeric value that was incremented/decremented on a field
  36714. // with the given name. The second boolean return value indicates that this field
  36715. // was not set, or was not defined in the schema.
  36716. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  36717. switch name {
  36718. case wxcardvisit.FieldUserID:
  36719. return m.AddedUserID()
  36720. case wxcardvisit.FieldBotID:
  36721. return m.AddedBotID()
  36722. case wxcardvisit.FieldBotType:
  36723. return m.AddedBotType()
  36724. }
  36725. return nil, false
  36726. }
  36727. // AddField adds the value to the field with the given name. It returns an error if
  36728. // the field is not defined in the schema, or if the type mismatched the field
  36729. // type.
  36730. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  36731. switch name {
  36732. case wxcardvisit.FieldUserID:
  36733. v, ok := value.(int64)
  36734. if !ok {
  36735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36736. }
  36737. m.AddUserID(v)
  36738. return nil
  36739. case wxcardvisit.FieldBotID:
  36740. v, ok := value.(int64)
  36741. if !ok {
  36742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36743. }
  36744. m.AddBotID(v)
  36745. return nil
  36746. case wxcardvisit.FieldBotType:
  36747. v, ok := value.(int8)
  36748. if !ok {
  36749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36750. }
  36751. m.AddBotType(v)
  36752. return nil
  36753. }
  36754. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  36755. }
  36756. // ClearedFields returns all nullable fields that were cleared during this
  36757. // mutation.
  36758. func (m *WxCardVisitMutation) ClearedFields() []string {
  36759. var fields []string
  36760. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  36761. fields = append(fields, wxcardvisit.FieldDeletedAt)
  36762. }
  36763. if m.FieldCleared(wxcardvisit.FieldUserID) {
  36764. fields = append(fields, wxcardvisit.FieldUserID)
  36765. }
  36766. return fields
  36767. }
  36768. // FieldCleared returns a boolean indicating if a field with the given name was
  36769. // cleared in this mutation.
  36770. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  36771. _, ok := m.clearedFields[name]
  36772. return ok
  36773. }
  36774. // ClearField clears the value of the field with the given name. It returns an
  36775. // error if the field is not defined in the schema.
  36776. func (m *WxCardVisitMutation) ClearField(name string) error {
  36777. switch name {
  36778. case wxcardvisit.FieldDeletedAt:
  36779. m.ClearDeletedAt()
  36780. return nil
  36781. case wxcardvisit.FieldUserID:
  36782. m.ClearUserID()
  36783. return nil
  36784. }
  36785. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  36786. }
  36787. // ResetField resets all changes in the mutation for the field with the given name.
  36788. // It returns an error if the field is not defined in the schema.
  36789. func (m *WxCardVisitMutation) ResetField(name string) error {
  36790. switch name {
  36791. case wxcardvisit.FieldCreatedAt:
  36792. m.ResetCreatedAt()
  36793. return nil
  36794. case wxcardvisit.FieldUpdatedAt:
  36795. m.ResetUpdatedAt()
  36796. return nil
  36797. case wxcardvisit.FieldDeletedAt:
  36798. m.ResetDeletedAt()
  36799. return nil
  36800. case wxcardvisit.FieldUserID:
  36801. m.ResetUserID()
  36802. return nil
  36803. case wxcardvisit.FieldBotID:
  36804. m.ResetBotID()
  36805. return nil
  36806. case wxcardvisit.FieldBotType:
  36807. m.ResetBotType()
  36808. return nil
  36809. }
  36810. return fmt.Errorf("unknown WxCardVisit field %s", name)
  36811. }
  36812. // AddedEdges returns all edge names that were set/added in this mutation.
  36813. func (m *WxCardVisitMutation) AddedEdges() []string {
  36814. edges := make([]string, 0, 0)
  36815. return edges
  36816. }
  36817. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36818. // name in this mutation.
  36819. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  36820. return nil
  36821. }
  36822. // RemovedEdges returns all edge names that were removed in this mutation.
  36823. func (m *WxCardVisitMutation) RemovedEdges() []string {
  36824. edges := make([]string, 0, 0)
  36825. return edges
  36826. }
  36827. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36828. // the given name in this mutation.
  36829. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  36830. return nil
  36831. }
  36832. // ClearedEdges returns all edge names that were cleared in this mutation.
  36833. func (m *WxCardVisitMutation) ClearedEdges() []string {
  36834. edges := make([]string, 0, 0)
  36835. return edges
  36836. }
  36837. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36838. // was cleared in this mutation.
  36839. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  36840. return false
  36841. }
  36842. // ClearEdge clears the value of the edge with the given name. It returns an error
  36843. // if that edge is not defined in the schema.
  36844. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  36845. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  36846. }
  36847. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36848. // It returns an error if the edge is not defined in the schema.
  36849. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  36850. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  36851. }